mirror of
https://github.com/eclipse-cdt/cdt
synced 2025-04-29 19:45:01 +02:00
Patch for Vlad Hirsl.
This patch adds two JUnit tests for problems generated while parsing<stdio.h>.
This commit is contained in:
parent
b368cb948d
commit
782c269d97
2 changed files with 34 additions and 2 deletions
|
@ -42,6 +42,7 @@ public class FailedCompleteParseASTTest extends CompleteParseBaseTest
|
||||||
//parse no longer passes
|
//parse no longer passes
|
||||||
try{
|
try{
|
||||||
parse ("class A { int m(int); }; \n A a; int A::*pm = &A::m; \n int f(){} \n int f(int); \n int x = f((a.*pm)(5));"); //$NON-NLS-1$
|
parse ("class A { int m(int); }; \n A a; int A::*pm = &A::m; \n int f(){} \n int f(int); \n int x = f((a.*pm)(5));"); //$NON-NLS-1$
|
||||||
|
fail();
|
||||||
} catch ( ParserException e ){
|
} catch ( ParserException e ){
|
||||||
assertTrue( e.getMessage().equals( "FAILURE" ) ); //$NON-NLS-1$
|
assertTrue( e.getMessage().equals( "FAILURE" ) ); //$NON-NLS-1$
|
||||||
}
|
}
|
||||||
|
@ -64,6 +65,7 @@ public class FailedCompleteParseASTTest extends CompleteParseBaseTest
|
||||||
//parse no longer passes
|
//parse no longer passes
|
||||||
try{
|
try{
|
||||||
parse ("class A { int m(int); }; \n A * a; int A::*pm = &A::m; \n int f(){} \n int f(int); \n int x = f((a->*pm)(5));"); //$NON-NLS-1$
|
parse ("class A { int m(int); }; \n A * a; int A::*pm = &A::m; \n int f(){} \n int f(int); \n int x = f((a->*pm)(5));"); //$NON-NLS-1$
|
||||||
|
fail();
|
||||||
} catch ( ParserException e ){
|
} catch ( ParserException e ){
|
||||||
assertTrue( e.getMessage().equals( "FAILURE" ) ); //$NON-NLS-1$
|
assertTrue( e.getMessage().equals( "FAILURE" ) ); //$NON-NLS-1$
|
||||||
}
|
}
|
||||||
|
@ -102,6 +104,7 @@ public class FailedCompleteParseASTTest extends CompleteParseBaseTest
|
||||||
//parse no longer passes
|
//parse no longer passes
|
||||||
try{
|
try{
|
||||||
parse ( "class A { int m; }; \n A a; int A::*pm; \n int f(){} \n int f(int); \n int x = f(a.*pm);" ); //$NON-NLS-1$
|
parse ( "class A { int m; }; \n A a; int A::*pm; \n int f(){} \n int f(int); \n int x = f(a.*pm);" ); //$NON-NLS-1$
|
||||||
|
fail();
|
||||||
} catch ( ParserException e ){
|
} catch ( ParserException e ){
|
||||||
assertTrue( e.getMessage().equals( "FAILURE" ) ); //$NON-NLS-1$
|
assertTrue( e.getMessage().equals( "FAILURE" ) ); //$NON-NLS-1$
|
||||||
}
|
}
|
||||||
|
@ -122,6 +125,7 @@ public class FailedCompleteParseASTTest extends CompleteParseBaseTest
|
||||||
//parse no longer passes
|
//parse no longer passes
|
||||||
try{
|
try{
|
||||||
parse ("class A { int m; }; \n A * a; int A::*pm; \n int f(){} \n int f(int); \n int x = f(a->*pm);"); //$NON-NLS-1$
|
parse ("class A { int m; }; \n A * a; int A::*pm; \n int f(){} \n int f(int); \n int x = f(a->*pm);"); //$NON-NLS-1$
|
||||||
|
fail();
|
||||||
} catch ( ParserException e ){
|
} catch ( ParserException e ){
|
||||||
assertTrue( e.getMessage().equals( "FAILURE" ) ); //$NON-NLS-1$
|
assertTrue( e.getMessage().equals( "FAILURE" ) ); //$NON-NLS-1$
|
||||||
}
|
}
|
||||||
|
@ -134,5 +138,32 @@ public class FailedCompleteParseASTTest extends CompleteParseBaseTest
|
||||||
// IASTVariable x = (IASTVariable) i.next();
|
// IASTVariable x = (IASTVariable) i.next();
|
||||||
// assertFalse( i.hasNext() );
|
// assertFalse( i.hasNext() );
|
||||||
// assertAllReferences( 4 /*should be 5 */, createTaskList( new Task( cl /* , 2 */ ), new Task( a), new Task( pm), new Task( f2)));
|
// assertAllReferences( 4 /*should be 5 */, createTaskList( new Task( cl /* , 2 */ ), new Task( a), new Task( pm), new Task( f2)));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public void testPredefinedSymbol_bug69791() throws Exception {
|
||||||
|
// GNU builtin type __builtin_va_list
|
||||||
|
try {
|
||||||
|
parse("typedef __builtin_va_list __gnuc_va_list; \n");//$NON-NLS-1$
|
||||||
|
fail();
|
||||||
|
} catch ( ParserException e ){
|
||||||
|
assertTrue( e.getMessage().equals( "FAILURE" ) ); //$NON-NLS-1$
|
||||||
|
}
|
||||||
|
// Iterator i = parse("typedef unsigned char byte; \n").getDeclarations();;//$NON-NLS-1$
|
||||||
|
// IASTTypedefDeclaration td = (IASTTypedefDeclaration) i.next();
|
||||||
|
// assertFalse(i.hasNext());
|
||||||
|
}
|
||||||
|
|
||||||
|
public void testPredefinedSymbol_bug70928() throws Exception {
|
||||||
|
// GNU builtin storage class type __cdecl preceded by a custom return type
|
||||||
|
try {
|
||||||
|
parse("typedef int size_t; \n size_t __cdecl foo(); \n");//$NON-NLS-1$
|
||||||
|
fail();
|
||||||
|
} catch ( ParserException e ){
|
||||||
|
assertTrue( e.getMessage().equals( "FAILURE" ) ); //$NON-NLS-1$
|
||||||
|
}
|
||||||
|
// Iterator i = parse("typedef int size_t; \n int __cdecl foo(); \n").getDeclarations();//$NON-NLS-1$
|
||||||
|
// IASTTypedefDeclaration td = (IASTTypedefDeclaration) i.next();
|
||||||
|
// IASTFunction fd = (IASTFunction) i.next();
|
||||||
|
// assertFalse(i.hasNext());
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -794,7 +794,8 @@ public class CompleteParseBaseTest extends TestCase
|
||||||
ParserMode.COMPLETE_PARSE, language, callback, new NullLogService(), null ), callback, ParserMode.COMPLETE_PARSE, language, null
|
ParserMode.COMPLETE_PARSE, language, callback, new NullLogService(), null ), callback, ParserMode.COMPLETE_PARSE, language, null
|
||||||
);
|
);
|
||||||
boolean parseResult = parser.parse();
|
boolean parseResult = parser.parse();
|
||||||
if( ! parseResult && throwOnError ) throw new ParserException( "FAILURE"); //$NON-NLS-1$
|
// throw exception if there are generated IProblems
|
||||||
|
if( (! parseResult || callback.getProblems().hasNext() ) && throwOnError ) throw new ParserException( "FAILURE"); //$NON-NLS-1$
|
||||||
if( parseResult )
|
if( parseResult )
|
||||||
assertTrue( ((CompleteParser)parser).validateCaches());
|
assertTrue( ((CompleteParser)parser).validateCaches());
|
||||||
return callback.getCompilationUnit();
|
return callback.getCompilationUnit();
|
||||||
|
|
Loading…
Add table
Reference in a new issue