1
0
Fork 0
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:
John Camelon 2004-07-29 19:39:52 +00:00
parent b368cb948d
commit 782c269d97
2 changed files with 34 additions and 2 deletions

View file

@ -42,6 +42,7 @@ public class FailedCompleteParseASTTest extends CompleteParseBaseTest
//parse no longer passes
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$
fail();
} catch ( ParserException e ){
assertTrue( e.getMessage().equals( "FAILURE" ) ); //$NON-NLS-1$
}
@ -64,6 +65,7 @@ public class FailedCompleteParseASTTest extends CompleteParseBaseTest
//parse no longer passes
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$
fail();
} catch ( ParserException e ){
assertTrue( e.getMessage().equals( "FAILURE" ) ); //$NON-NLS-1$
}
@ -102,6 +104,7 @@ public class FailedCompleteParseASTTest extends CompleteParseBaseTest
//parse no longer passes
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$
fail();
} catch ( ParserException e ){
assertTrue( e.getMessage().equals( "FAILURE" ) ); //$NON-NLS-1$
}
@ -122,6 +125,7 @@ public class FailedCompleteParseASTTest extends CompleteParseBaseTest
//parse no longer passes
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$
fail();
} catch ( ParserException e ){
assertTrue( e.getMessage().equals( "FAILURE" ) ); //$NON-NLS-1$
}
@ -135,4 +139,31 @@ public class FailedCompleteParseASTTest extends CompleteParseBaseTest
// assertFalse( i.hasNext() );
// 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());
}
}

View file

@ -794,7 +794,8 @@ public class CompleteParseBaseTest extends TestCase
ParserMode.COMPLETE_PARSE, language, callback, new NullLogService(), null ), callback, ParserMode.COMPLETE_PARSE, language, null
);
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 )
assertTrue( ((CompleteParser)parser).validateCaches());
return callback.getCompilationUnit();