mirror of
https://github.com/eclipse-cdt/cdt
synced 2025-04-29 19:45:01 +02:00
Patch for John Camelon:
CORE Fixed error in Elaborated Enumeration Types. Fixed Bug36559 - Parsing Templates... Fixed Bug36634 - Enum start line error TESTS Updated DOMTests::testBug36600(). Updated LineNumberTest::testDOMLineNos(). Added DOMTests::testBug36559().
This commit is contained in:
parent
8fc0923c61
commit
ec6fd870a4
7 changed files with 94 additions and 19 deletions
|
@ -338,7 +338,10 @@ public class DOMBuilder implements IParserCallback
|
|||
break;
|
||||
case Token.t_union:
|
||||
kind = ClassKey.t_union;
|
||||
break;
|
||||
break;
|
||||
case Token.t_enum:
|
||||
kind = ClassKey.t_enum;
|
||||
break;
|
||||
}
|
||||
|
||||
ElaboratedTypeSpecifier elab = null;
|
||||
|
@ -637,7 +640,7 @@ public class DOMBuilder implements IParserCallback
|
|||
es.setStartToken(enumKey);
|
||||
decl.setTypeSpecifier(es);
|
||||
((IOffsetable)es).setStartingOffset( enumKey.getOffset() );
|
||||
((IOffsetable)es).setStartingOffset( parser.getLineNumberForOffset(enumKey.getOffset()) );
|
||||
((IOffsetable)es).setTopLine( parser.getLineNumberForOffset(enumKey.getOffset()) );
|
||||
return es;
|
||||
}
|
||||
|
||||
|
|
|
@ -1,3 +1,8 @@
|
|||
2003-04-17 John Camelon
|
||||
Fixed error in Elaborated Enumeration Types.
|
||||
Fixed Bug36559 - Parsing Templates...
|
||||
Fixed Bug36634 - Enum start line error
|
||||
|
||||
2003-04-16 John Camelon
|
||||
Fixed Bug36532 - Hang on partial template definition.
|
||||
Fixed Bug36432 - Trying to open attached source code hangs Eclipse.
|
||||
|
|
|
@ -351,7 +351,7 @@ c, quick);
|
|||
|
||||
protected void templateParameterList( Object templateDeclaration ) throws EndOfFile, Backtrack {
|
||||
// if we have gotten this far then we have a true template-declaration
|
||||
// iterate through the template parameter list
|
||||
// iterate through the template parameter listtt
|
||||
|
||||
Object templateParameterList = null;
|
||||
|
||||
|
@ -376,7 +376,7 @@ c, quick);
|
|||
if( LT(1) == Token.tASSIGN ) // optional = type-id
|
||||
{
|
||||
consume( Token.tASSIGN );
|
||||
identifier(); // type-id
|
||||
typeId(); // type-id
|
||||
try{ callback.templateTypeParameterInitialTypeId( currentTemplateParm ); }catch( Exception e ) {}
|
||||
}
|
||||
}
|
||||
|
@ -404,7 +404,7 @@ c, quick);
|
|||
if( LT(1) == Token.tASSIGN ) // optional = type-id
|
||||
{
|
||||
consume( Token.tASSIGN );
|
||||
name();
|
||||
typeId();
|
||||
try{ callback.templateTypeParameterInitialTypeId( newTemplateParm );} catch( Exception e ) {}
|
||||
}
|
||||
}
|
||||
|
@ -757,8 +757,7 @@ c, quick);
|
|||
callback.elaboratedTypeSpecifierName( elab );
|
||||
callback.elaboratedTypeSpecifierEnd( elab );
|
||||
} catch( Exception e ) {}
|
||||
encounteredTypename = true;
|
||||
break;
|
||||
return;
|
||||
}
|
||||
case Token.t_enum:
|
||||
try
|
||||
|
@ -776,8 +775,8 @@ c, quick);
|
|||
callback.elaboratedTypeSpecifierName( elab );
|
||||
callback.elaboratedTypeSpecifierEnd( elab );
|
||||
} catch( Exception e ) {}
|
||||
return;
|
||||
}
|
||||
break;
|
||||
default:
|
||||
break declSpecifiers;
|
||||
}
|
||||
|
@ -1948,7 +1947,8 @@ c, quick);
|
|||
name();
|
||||
return;
|
||||
} catch (Backtrack b) {
|
||||
boolean encountered = false;
|
||||
Token begin = LA(1);
|
||||
Token end = null;
|
||||
simpleMods:
|
||||
for( ; ; )
|
||||
{
|
||||
|
@ -1957,8 +1957,7 @@ c, quick);
|
|||
case Token.t_short:
|
||||
case Token.t_unsigned:
|
||||
case Token.t_long:
|
||||
encountered = true;
|
||||
consume();
|
||||
end = consume();
|
||||
break;
|
||||
case Token.t_int:
|
||||
case Token.t_char:
|
||||
|
@ -1967,14 +1966,21 @@ c, quick);
|
|||
case Token.t_float:
|
||||
case Token.t_wchar_t:
|
||||
case Token.t_void:
|
||||
encountered = true;
|
||||
consume();
|
||||
end = consume();
|
||||
default:
|
||||
break simpleMods;
|
||||
}
|
||||
}
|
||||
if( encountered )
|
||||
return;
|
||||
if( end != null )
|
||||
{
|
||||
try
|
||||
{
|
||||
callback.nameBegin( begin );
|
||||
callback.nameEnd( end );
|
||||
} catch( Exception e ) {}
|
||||
}
|
||||
else
|
||||
throw backtrack;
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -1,3 +1,8 @@
|
|||
2003-04-17 John Camelon
|
||||
Updated DOMTests::testBug36600().
|
||||
Updated LineNumberTest::testDOMLineNos().
|
||||
Added DOMTests::testBug36559().
|
||||
|
||||
2003-04-17 Andrew Niefer
|
||||
Added AutomatedTest
|
||||
Added resources.cFiles
|
||||
|
|
|
@ -75,11 +75,8 @@ public class AutomatedTest extends TestCase {
|
|||
output = file.getCanonicalPath() + ": Parse failed on line ";
|
||||
output += parser.getLastLineNumber() + "\n";
|
||||
} else {
|
||||
StackTraceElement frames[] = e.getStackTrace();
|
||||
output = file.getCanonicalPath() + ": " + e.getClass().toString();
|
||||
output += " on line " + parser.getLastLineNumber() + "\n";
|
||||
output += "\t" + "at " + frames[0].getClassName() + "." + frames[0].getMethodName() + "\n";
|
||||
output += "\t" + "at " + frames[1].getClassName() + "." + frames[1].getMethodName() + "\n";
|
||||
}
|
||||
if( report != null ){
|
||||
report.write( output.getBytes() );
|
||||
|
|
|
@ -1309,7 +1309,25 @@ public class DOMTests extends TestCase {
|
|||
public void testBug36600() throws Exception
|
||||
{
|
||||
TranslationUnit tu = parse( "enum mad_flow (*input_func)(void *, struct mad_stream *);");
|
||||
assertEquals( tu.getDeclarations().size(), 1 );
|
||||
SimpleDeclaration simple = (SimpleDeclaration)tu.getDeclarations().get(0);
|
||||
ElaboratedTypeSpecifier elab = (ElaboratedTypeSpecifier)simple.getTypeSpecifier();
|
||||
assertEquals( elab.getClassKey(), ClassKey.t_enum );
|
||||
assertEquals( elab.getName().toString(), "mad_flow");
|
||||
assertEquals( simple.getDeclarators().size(), 1 );
|
||||
Declarator declarator = (Declarator)simple.getDeclarators().get(0);
|
||||
assertNull( declarator.getName() );
|
||||
assertNotNull( declarator.getDeclarator() );
|
||||
|
||||
tu = parse( "enum mad_layer layer;");
|
||||
assertEquals( tu.getDeclarations().size(), 1);
|
||||
SimpleDeclaration declaration = (SimpleDeclaration)tu.getDeclarations().get(0);
|
||||
elab = (ElaboratedTypeSpecifier)declaration.getTypeSpecifier();
|
||||
assertEquals( elab.getClassKey(), ClassKey.t_enum);
|
||||
assertEquals( elab.getName().toString(), "mad_layer");
|
||||
assertEquals( declaration.getDeclarators().size(), 1);
|
||||
assertEquals( ((Declarator)declaration.getDeclarators().get(0)).getName().toString(), "layer" );
|
||||
|
||||
}
|
||||
|
||||
public void testBug36247() throws Exception
|
||||
|
@ -1367,5 +1385,43 @@ public class DOMTests extends TestCase {
|
|||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
public void testBug36559() throws Exception
|
||||
{
|
||||
Writer code = new StringWriter();
|
||||
code.write( "namespace myNameSpace {\n" );
|
||||
code.write( "template<typename T=short> class B {};\n" );
|
||||
code.write( "template<> class B<int> {};\n" );
|
||||
code.write( "}\n" );
|
||||
TranslationUnit tu = parse( code.toString() );
|
||||
assertEquals( tu.getDeclarations().size(),1);
|
||||
NamespaceDefinition definition = (NamespaceDefinition)tu.getDeclarations().get(0);
|
||||
assertEquals( definition.getName().toString(), "myNameSpace");
|
||||
assertEquals( definition.getDeclarations().size(), 2 );
|
||||
TemplateDeclaration templateDeclaration = (TemplateDeclaration)definition.getDeclarations().get(0);
|
||||
assertFalse( templateDeclaration.isExported());
|
||||
assertEquals( templateDeclaration.getTemplateParms().getDeclarations().size(), 1 );
|
||||
TemplateParameter parm = (TemplateParameter)templateDeclaration.getTemplateParms().getDeclarations().get(0);
|
||||
assertEquals( parm.getKind(), TemplateParameter.k_typename );
|
||||
assertEquals( parm.getName().toString(), "T");
|
||||
assertEquals( parm.getTypeId().toString(), "short");
|
||||
assertEquals( templateDeclaration.getDeclarations().size(), 1 );
|
||||
SimpleDeclaration classB = (SimpleDeclaration)templateDeclaration.getDeclarations().get(0);
|
||||
assertEquals( classB.getDeclarators().size(), 0 );
|
||||
assertEquals( ((ClassSpecifier)classB.getTypeSpecifier()).getName().toString(), "B" );
|
||||
assertEquals( ((ClassSpecifier)classB.getTypeSpecifier()).getClassKey(), ClassKey.t_class );
|
||||
assertEquals( ((ClassSpecifier)classB.getTypeSpecifier()).getDeclarations().size(), 0 );
|
||||
|
||||
ExplicitTemplateDeclaration etd = (ExplicitTemplateDeclaration)definition.getDeclarations().get(1);
|
||||
assertEquals( etd.getKind(), ExplicitTemplateDeclaration.k_specialization );
|
||||
assertEquals( etd.getDeclarations().size(), 1 );
|
||||
classB = (SimpleDeclaration)etd.getDeclarations().get(0);
|
||||
assertEquals( classB.getDeclarators().size(), 0 );
|
||||
assertEquals( ((ClassSpecifier)classB.getTypeSpecifier()).getName().toString(), "B<int>" );
|
||||
assertEquals( ((ClassSpecifier)classB.getTypeSpecifier()).getClassKey(), ClassKey.t_class );
|
||||
assertEquals( ((ClassSpecifier)classB.getTypeSpecifier()).getDeclarations().size(), 0 );
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -21,6 +21,7 @@ import junit.framework.TestCase;
|
|||
|
||||
import org.eclipse.cdt.internal.core.dom.ClassSpecifier;
|
||||
import org.eclipse.cdt.internal.core.dom.DOMBuilder;
|
||||
import org.eclipse.cdt.internal.core.dom.EnumerationSpecifier;
|
||||
import org.eclipse.cdt.internal.core.dom.IOffsetable;
|
||||
import org.eclipse.cdt.internal.core.dom.NamespaceDefinition;
|
||||
import org.eclipse.cdt.internal.core.dom.SimpleDeclaration;
|
||||
|
@ -134,7 +135,9 @@ public class LineNumberTest extends TestCase {
|
|||
|
||||
validateLineNumbers( (SimpleDeclaration)declarations.get(1), 25, 27);
|
||||
validateLineNumbers( (TemplateDeclaration)declarations.get(2), 34, 35);
|
||||
validateLineNumbers( (SimpleDeclaration)declarations.get(3), 38, 43);
|
||||
SimpleDeclaration d = (SimpleDeclaration)declarations.get(3);
|
||||
validateLineNumbers( d, 38, 43);
|
||||
validateLineNumbers( ((EnumerationSpecifier)d.getTypeSpecifier()), 38, 43);
|
||||
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Reference in a new issue