1
0
Fork 0
mirror of https://github.com/eclipse-cdt/cdt synced 2025-04-29 19:45:01 +02:00

Cosmetics.

This commit is contained in:
Sergey Prigogin 2012-11-20 15:31:08 -08:00
parent 3c6d895d64
commit 4b30304283
3 changed files with 645 additions and 675 deletions

View file

@ -46,10 +46,9 @@ public class GCCCompleteParseExtensionsTest extends AST2BaseTest {
CNameResolver resolver = new CNameResolver();
tu.accept(resolver);
if (resolver.numProblemBindings > 0)
throw new ParserException(" there are " + resolver.numProblemBindings + " ProblemBindings on the tu"); //$NON-NLS-1$ //$NON-NLS-2$
throw new ParserException(" there are " + resolver.numProblemBindings + " ProblemBindings on the tu"); //$NON-NLS-2$
if (resolver.numNullBindings > 0)
throw new ParserException("Expected no null bindings, encountered " + resolver.numNullBindings); //$NON-NLS-1$
throw new ParserException("Expected no null bindings, encountered " + resolver.numNullBindings);
return tu;
}
@ -59,21 +58,18 @@ public class GCCCompleteParseExtensionsTest extends AST2BaseTest {
CPPNameResolver resolver = new CPPNameResolver();
tu.accept(resolver);
if (resolver.numProblemBindings > 0)
throw new ParserException(" there are " + resolver.numProblemBindings + " ProblemBindings on the tu"); //$NON-NLS-1$ //$NON-NLS-2$
throw new ParserException(" there are " + resolver.numProblemBindings + " ProblemBindings on the tu"); //$NON-NLS-2$
if (resolver.numNullBindings > 0)
throw new ParserException("Expected no null bindings, encountered " + resolver.numNullBindings); //$NON-NLS-1$
throw new ParserException("Expected no null bindings, encountered " + resolver.numNullBindings);
return tu;
}
public void testBug39695() throws Exception
{
parseGCC("int a = __alignof__ (int);").getDeclarations(); //$NON-NLS-1$
public void testBug39695() throws Exception {
parseGCC("int a = __alignof__ (int);").getDeclarations();
}
public void testBug39684() throws Exception
{
IASTDeclaration bar = parseGCC("typeof(foo(1)) bar () { return foo(1); }").getDeclarations()[0]; //$NON-NLS-1$
public void testBug39684() throws Exception {
IASTDeclaration bar = parseGCC("typeof(foo(1)) bar () { return foo(1); }").getDeclarations()[0];
assertTrue(bar instanceof CASTFunctionDefinition);
CFunction barFunc = (CFunction)((CASTFunctionDefinition)bar).getDeclarator().getName().resolveBinding();
IFunctionType type = barFunc.getType();
@ -83,169 +79,162 @@ public class GCCCompleteParseExtensionsTest extends AST2BaseTest {
// assertEquals(simpleTypeSpec.getType(), IASTGCCSimpleTypeSpecifier.Type.TYPEOF);
}
public void testBug39698A() throws Exception
{
IASTDeclaration[] decls = parseGPP("int a=0; \n int b=1; \n int c = a <? b;").getDeclarations(); //$NON-NLS-1$
assertEquals( ASTStringUtil.getExpressionString( (IASTExpression) ((IASTEqualsInitializer)((IASTSimpleDeclaration)decls[2]).getDeclarators()[0].getInitializer()).getInitializerClause() ), "a <? b" ); //$NON-NLS-1$
public void testBug39698A() throws Exception {
IASTDeclaration[] decls = parseGPP("int a=0; \n int b=1; \n int c = a <? b;").getDeclarations();
assertEquals(ASTStringUtil.getExpressionString((IASTExpression) ((IASTEqualsInitializer)((IASTSimpleDeclaration)decls[2]).getDeclarators()[0].getInitializer()).getInitializerClause()), "a <? b");
}
public void testBug39698B() throws Exception
{
IASTDeclaration[] decls = parseGPP("int a=0; \n int b=1; \n int c = a >? b;").getDeclarations(); //$NON-NLS-1$
assertEquals( ASTStringUtil.getExpressionString( (IASTExpression) ((IASTEqualsInitializer)((IASTSimpleDeclaration)decls[2]).getDeclarators()[0].getInitializer()).getInitializerClause() ), "a >? b" ); //$NON-NLS-1$
public void testBug39698B() throws Exception {
IASTDeclaration[] decls = parseGPP("int a=0; \n int b=1; \n int c = a >? b;").getDeclarations();
assertEquals(ASTStringUtil.getExpressionString((IASTExpression) ((IASTEqualsInitializer)((IASTSimpleDeclaration)decls[2]).getDeclarators()[0].getInitializer()).getInitializerClause()), "a >? b");
}
public void testPredefinedSymbol_bug69791() throws Exception {
parseGPP("typedef __builtin_va_list __gnuc_va_list; \n").getDeclarations();//$NON-NLS-1$
parseGCC("typedef __builtin_va_list __gnuc_va_list; \n").getDeclarations();//$NON-NLS-1$
parseGPP("typedef __builtin_va_list __gnuc_va_list; \n").getDeclarations();
parseGCC("typedef __builtin_va_list __gnuc_va_list; \n").getDeclarations();
}
public void testBug39697() throws Exception
{
public void testBug39697() throws Exception {
Writer writer = new StringWriter();
writer.write( "__asm__( \"CODE\" );\n" ); //$NON-NLS-1$
writer.write( "__inline__ int foo() { return 4; }\n"); //$NON-NLS-1$
writer.write( "__const__ int constInt;\n"); //$NON-NLS-1$
writer.write( "__volatile__ int volInt;\n"); //$NON-NLS-1$
writer.write( "__signed__ int signedInt;\n"); //$NON-NLS-1$
writer.write("__asm__( \"CODE\" );\n");
writer.write("__inline__ int foo() { return 4; }\n");
writer.write("__const__ int constInt;\n");
writer.write("__volatile__ int volInt;\n");
writer.write("__signed__ int signedInt;\n");
IASTDeclaration[] decls = parseGCC(writer.toString()).getDeclarations();
assertEquals(((IASTASMDeclaration)decls[0]).getAssembly(), "\"CODE\""); //$NON-NLS-1$
assertEquals(((IASTASMDeclaration)decls[0]).getAssembly(), "\"CODE\"");
assertTrue(((IASTFunctionDefinition)decls[1]).getDeclSpecifier().isInline());
assertTrue(((IASTSimpleDeclaration)decls[2]).getDeclSpecifier().isConst());
assertTrue(((IASTSimpleDeclaration)decls[3]).getDeclSpecifier().isVolatile());
assertTrue(((ICASTSimpleDeclSpecifier)((IASTSimpleDeclaration)decls[4]).getDeclSpecifier()).isSigned());
writer = new StringWriter();
writer.write( "int * __restrict__ resPointer1;\n"); //$NON-NLS-1$
writer.write( "int * __restrict resPointer2;\n"); //$NON-NLS-1$
writer.write("int * __restrict__ resPointer1;\n");
writer.write("int * __restrict resPointer2;\n");
decls = parseGCC(writer.toString()).getDeclarations();
assertTrue(((ICASTPointer)((IASTSimpleDeclaration)decls[0]).getDeclarators()[0].getPointerOperators()[0]).isRestrict());
assertTrue(((ICASTPointer)((IASTSimpleDeclaration)decls[1]).getDeclarators()[0].getPointerOperators()[0]).isRestrict());
writer = new StringWriter();
writer.write( "int * __restrict__ resPointer1;\n"); //$NON-NLS-1$
writer.write( "int * __restrict resPointer2;\n"); //$NON-NLS-1$
writer.write("int * __restrict__ resPointer1;\n");
writer.write("int * __restrict resPointer2;\n");
decls = parseGPP(writer.toString()).getDeclarations();
assertTrue(((IASTPointer)((IASTSimpleDeclaration)decls[0]).getDeclarators()[0].getPointerOperators()[0]).isRestrict());
assertTrue(((IASTPointer)((IASTSimpleDeclaration)decls[1]).getDeclarators()[0].getPointerOperators()[0]).isRestrict());
}
public void testBug73954A() throws Exception {
StringWriter writer = new StringWriter();
writer.write("void f(){ \n");//$NON-NLS-1$
writer.write(" __builtin_expect( 23, 2); \n");//$NON-NLS-1$
writer.write(" __builtin_prefetch( (const void *)0, 1, 2); \n");//$NON-NLS-1$
writer.write(" __builtin_huge_val(); \n");//$NON-NLS-1$
writer.write(" __builtin_huge_valf(); \n");//$NON-NLS-1$
writer.write(" __builtin_huge_vall(); \n");//$NON-NLS-1$
writer.write(" __builtin_inf(); \n");//$NON-NLS-1$
writer.write(" __builtin_inff(); \n");//$NON-NLS-1$
writer.write(" __builtin_infl(); \n");//$NON-NLS-1$
writer.write(" __builtin_nan(\"\"); \n");//$NON-NLS-1$
writer.write(" __builtin_nanf(\"\"); \n");//$NON-NLS-1$
writer.write(" __builtin_nanl(\"\"); \n");//$NON-NLS-1$
writer.write(" __builtin_nans(\"\"); \n");//$NON-NLS-1$
writer.write(" __builtin_nansf(\"\"); \n");//$NON-NLS-1$
writer.write(" __builtin_nansl(\"\"); \n");//$NON-NLS-1$
writer.write(" __builtin_ffs (0); \n");//$NON-NLS-1$
writer.write(" __builtin_clz (0); \n");//$NON-NLS-1$
writer.write(" __builtin_ctz (0); \n");//$NON-NLS-1$
writer.write(" __builtin_popcount (0); \n");//$NON-NLS-1$
writer.write(" __builtin_parity (0); \n");//$NON-NLS-1$
writer.write(" __builtin_ffsl (0); \n");//$NON-NLS-1$
writer.write(" __builtin_clzl (0); \n");//$NON-NLS-1$
writer.write(" __builtin_ctzl (0); \n");//$NON-NLS-1$
writer.write(" __builtin_popcountl (0); \n");//$NON-NLS-1$
writer.write(" __builtin_parityl (0); \n");//$NON-NLS-1$
writer.write(" __builtin_ffsll (0); \n");//$NON-NLS-1$
writer.write(" __builtin_clzll (0); \n");//$NON-NLS-1$
writer.write(" __builtin_ctzll (0); \n");//$NON-NLS-1$
writer.write(" __builtin_popcountll (0); \n");//$NON-NLS-1$
writer.write(" __builtin_parityll (0); \n");//$NON-NLS-1$
writer.write(" __builtin_powi (0, 0); \n");//$NON-NLS-1$
writer.write(" __builtin_powif (0, 0); \n");//$NON-NLS-1$
writer.write(" __builtin_powil (0, 0); \n");//$NON-NLS-1$
writer.write("} \n"); //$NON-NLS-1$
writer.write("void f(){ \n");
writer.write(" __builtin_expect( 23, 2); \n");
writer.write(" __builtin_prefetch( (const void *)0, 1, 2); \n");
writer.write(" __builtin_huge_val(); \n");
writer.write(" __builtin_huge_valf(); \n");
writer.write(" __builtin_huge_vall(); \n");
writer.write(" __builtin_inf(); \n");
writer.write(" __builtin_inff(); \n");
writer.write(" __builtin_infl(); \n");
writer.write(" __builtin_nan(\"\"); \n");
writer.write(" __builtin_nanf(\"\"); \n");
writer.write(" __builtin_nanl(\"\"); \n");
writer.write(" __builtin_nans(\"\"); \n");
writer.write(" __builtin_nansf(\"\"); \n");
writer.write(" __builtin_nansl(\"\"); \n");
writer.write(" __builtin_ffs (0); \n");
writer.write(" __builtin_clz (0); \n");
writer.write(" __builtin_ctz (0); \n");
writer.write(" __builtin_popcount (0); \n");
writer.write(" __builtin_parity (0); \n");
writer.write(" __builtin_ffsl (0); \n");
writer.write(" __builtin_clzl (0); \n");
writer.write(" __builtin_ctzl (0); \n");
writer.write(" __builtin_popcountl (0); \n");
writer.write(" __builtin_parityl (0); \n");
writer.write(" __builtin_ffsll (0); \n");
writer.write(" __builtin_clzll (0); \n");
writer.write(" __builtin_ctzll (0); \n");
writer.write(" __builtin_popcountll (0); \n");
writer.write(" __builtin_parityll (0); \n");
writer.write(" __builtin_powi (0, 0); \n");
writer.write(" __builtin_powif (0, 0); \n");
writer.write(" __builtin_powil (0, 0); \n");
writer.write("} \n");
parseGCC(writer.toString());
}
public void testBug39686() throws Exception
{
public void testBug39686() throws Exception {
Writer code = new StringWriter();
code.write("__complex__ double x; // complex double\n"); //$NON-NLS-1$
code.write("__complex__ short int a; // complex short int\n"); //$NON-NLS-1$
code.write("__complex__ float y = 2.5fi; // 2.5 imaginary float literal\n"); //$NON-NLS-1$
code.write("__complex__ int z = 3i; // imaginary intege r literal\n"); //$NON-NLS-1$
code.write("double v = __real__ x; // real part of expression\n"); //$NON-NLS-1$
code.write("double w = __imag__ x; // imaginary part of expression\n"); //$NON-NLS-1$
code.write("__complex__ double x; // complex double\n");
code.write("__complex__ short int a; // complex short int\n");
code.write("__complex__ float y = 2.5fi; // 2.5 imaginary float literal\n");
code.write("__complex__ int z = 3i; // imaginary intege r literal\n");
code.write("double v = __real__ x; // real part of expression\n");
code.write("double w = __imag__ x; // imaginary part of expression\n");
parseGCC(code.toString());
}
public void testBug39551B() throws Exception
{
public void testBug39551B() throws Exception {
//this used to be 99.99 * __I__, but I don't know where the __I__ came from, its not in C99, nor in GCC
IASTDeclaration decl = parseGCC("_Imaginary double id = 99.99 * 1i;").getDeclarations()[0]; //$NON-NLS-1$
IASTDeclaration decl = parseGCC("_Imaginary double id = 99.99 * 1i;").getDeclarations()[0];
// TODO Devin does ICPPASTSimpleDeclSpecifier need something for isImaginary ?
// assertEquals( variable.getName(), "id"); //$NON-NLS-1$
// assertEquals(variable.getName(), "id");
// assertTrue(((IASTSimpleTypeSpecifier)variable.getAbstractDeclaration().getTypeSpecifier()).isImaginary());
}
public void testBug39681() throws Exception
{
public void testBug39681() throws Exception {
Writer code = new StringWriter();
code.write("double\n"); //$NON-NLS-1$
code.write("foo (double a, double b)\n"); //$NON-NLS-1$
code.write("{\n"); //$NON-NLS-1$
code.write(" double square (double z) { return z * z; }\n"); //$NON-NLS-1$
code.write(" return square (a) + square (b);\n"); //$NON-NLS-1$
code.write("}\n"); //$NON-NLS-1$
code.write("double\n");
code.write("foo (double a, double b)\n");
code.write("{\n");
code.write(" double square (double z) { return z * z; }\n");
code.write(" return square (a) + square (b);\n");
code.write("}\n");
parseGCC(code.toString());
}
public void testBug39677() throws Exception
{
parseGPP("class B { public: B(); int a;}; B::B() : a(({ 1; })) {}"); //$NON-NLS-1$
public void testBug39677() throws Exception {
parseGPP("class B { public: B(); int a;}; B::B() : a(({ 1; })) {}");
Writer writer = new StringWriter();
writer.write("int foo(); class B { public: B(); int a;};");
writer.write( "B::B() : a(( { int y = foo (); int z;\n" ); //$NON-NLS-1$
writer.write( "if (y > 0) z = y;\n" ); //$NON-NLS-1$
writer.write( "else z = - y;\n" );//$NON-NLS-1$
writer.write( "z; })) {}\n" );//$NON-NLS-1$
writer.write("B::B() : a(( { int y = foo (); int z;\n");
writer.write("if (y > 0) z = y;\n");
writer.write("else z = - y;\n");
writer.write("z; })) {}\n");
parseGPP(writer.toString());
writer = new StringWriter();
writer.write( "int x = ({ int foo(); int y = foo (); int z;\n" ); //$NON-NLS-1$
writer.write( "if (y > 0) z = y;\n" ); //$NON-NLS-1$
writer.write( "else z = - y;\n" );//$NON-NLS-1$
writer.write( "z; });\n" );//$NON-NLS-1$
writer.write("int x = ({ int foo(); int y = foo (); int z;\n");
writer.write("if (y > 0) z = y;\n");
writer.write("else z = - y;\n");
writer.write("z; });\n");
parseGPP(writer.toString());
writer = new StringWriter();
writer.write( "int foo(); \n" ); //$NON-NLS-1$
writer.write( "typeof({ int y = foo (); \n" ); //$NON-NLS-1$
writer.write( " int z; \n" ); //$NON-NLS-1$
writer.write( " if (y > 0) z = y; \n" ); //$NON-NLS-1$
writer.write( " else z = - y; \n" ); //$NON-NLS-1$
writer.write( " z; \n" ); //$NON-NLS-1$
writer.write( " }) zoot; \n" ); //$NON-NLS-1$
writer.write("int foo(); \n");
writer.write("typeof({ int y = foo (); \n");
writer.write(" int z; \n");
writer.write(" if (y > 0) z = y; \n");
writer.write(" else z = - y; \n");
writer.write(" z; \n");
writer.write(" }) zoot; \n");
parseGPP(writer.toString()); // TODO Devin raised bug 93980
}
public void testBug75401() throws Exception {
Writer writer = new StringWriter();
writer.write( "#define va_list __builtin_va_list \n"); //$NON-NLS-1$
writer.write( "#define va_arg(v,l) __builtin_va_arg(v,l) \n"); //$NON-NLS-1$
writer.write( "#define va_start(v,l) __builtin_va_start(v,l) \n"); //$NON-NLS-1$
writer.write( "#define va_end(v) __builtin_va_end(v) \n"); //$NON-NLS-1$
writer.write( "void variadic(int first, ...) { \n"); //$NON-NLS-1$
writer.write( " va_list v; \n"); //$NON-NLS-1$
writer.write( " va_start(v, first); \n"); //$NON-NLS-1$
writer.write( " long l = va_arg(v, long); \n"); //$NON-NLS-1$
writer.write( " va_end(v); \n"); //$NON-NLS-1$
writer.write( "} \n"); //$NON-NLS-1$
writer.write("#define va_list __builtin_va_list \n");
writer.write("#define va_arg(v,l) __builtin_va_arg(v,l) \n");
writer.write("#define va_start(v,l) __builtin_va_start(v,l) \n");
writer.write("#define va_end(v) __builtin_va_end(v) \n");
writer.write("void variadic(int first, ...) { \n");
writer.write(" va_list v; \n");
writer.write(" va_start(v, first); \n");
writer.write(" long l = va_arg(v, long); \n");
writer.write(" va_end(v); \n");
writer.write("} \n");
parseGCC(writer.toString());
parseGPP(writer.toString());
@ -253,31 +242,31 @@ public class GCCCompleteParseExtensionsTest extends AST2BaseTest {
public void testBug73954B() throws Exception {
Writer writer = new StringWriter();
writer.write( "#define foo(x) \\\n"); //$NON-NLS-1$
writer.write( " __builtin_choose_expr( 1, foo_d(x), (void)0 ) \n"); //$NON-NLS-1$
writer.write( "int foo_d( int x ); \n"); //$NON-NLS-1$
writer.write( "int main() { \n"); //$NON-NLS-1$
writer.write( " if( __builtin_constant_p(1) && \n"); //$NON-NLS-1$
writer.write( " __builtin_types_compatible_p( 1, 'c') ) \n"); //$NON-NLS-1$
writer.write( " foo(1); \n"); //$NON-NLS-1$
writer.write( "} \n"); //$NON-NLS-1$
writer.write("#define foo(x) \\\n");
writer.write(" __builtin_choose_expr( 1, foo_d(x), (void)0 ) \n");
writer.write("int foo_d( int x ); \n");
writer.write("int main() { \n");
writer.write(" if( __builtin_constant_p(1) && \n");
writer.write(" __builtin_types_compatible_p( 1, 'c') ) \n");
writer.write(" foo(1); \n");
writer.write("} \n");
parseGCC(writer.toString());
}
public void testGNUExternalTemplate_bug71603() throws Exception {
parseGPP("template <typename T> \n class A {}; \n extern template class A<int>; \n").getDeclarations(); //$NON-NLS-1$
parseGPP("template <typename T> \n class A {}; \n extern template class A<int>; \n").getDeclarations();
}
public void testBug74190_g_assert_1() throws Exception {
Writer writer = new StringWriter();
writer.write( "void log( int ); \n"); //$NON-NLS-1$
writer.write( "void f() { \n"); //$NON-NLS-1$
writer.write( " int a = 1; \n"); //$NON-NLS-1$
writer.write( " (void)({ if( a ){ } \n"); //$NON-NLS-1$
writer.write( " else{ log( a ); } \n"); //$NON-NLS-1$
writer.write( " }); \n"); //$NON-NLS-1$
writer.write( "} \n"); //$NON-NLS-1$
writer.write("void log( int ); \n");
writer.write("void f() { \n");
writer.write(" int a = 1; \n");
writer.write(" (void)({ if( a ){ } \n");
writer.write(" else{ log( a ); } \n");
writer.write(" }); \n");
writer.write("} \n");
parseGCC(writer.toString());
parseGPP(writer.toString());
@ -285,11 +274,11 @@ public class GCCCompleteParseExtensionsTest extends AST2BaseTest {
public void testBug74190_g_return_if_fail() throws Exception {
Writer writer = new StringWriter();
writer.write( "void f() { \n"); //$NON-NLS-1$
writer.write( " (void)({ if( ( ({ 0; }) ) ) \n"); //$NON-NLS-1$
writer.write( " { } \n"); //$NON-NLS-1$
writer.write( " }); \n"); //$NON-NLS-1$
writer.write( "} \n"); //$NON-NLS-1$
writer.write("void f() { \n");
writer.write(" (void)({ if( ( ({ 0; }) ) ) \n");
writer.write(" { } \n");
writer.write(" }); \n");
writer.write("} \n");
parseGCC(writer.toString());
parseGPP(writer.toString());
@ -297,82 +286,82 @@ public class GCCCompleteParseExtensionsTest extends AST2BaseTest {
public void testBug95635() throws Exception{
StringWriter writer = new StringWriter();
writer.write("void f(){ \n");//$NON-NLS-1$
writer.write(" char a[10]; \n"); //$NON-NLS-1$
writer.write(" __builtin_va_list b; \n"); //$NON-NLS-1$
writer.write(" __builtin_abort(); \n");//$NON-NLS-1$
writer.write(" __builtin_exit(1); \n");//$NON-NLS-1$
writer.write(" __builtin__Exit(1); \n");//$NON-NLS-1$
writer.write(" __builtin__exit(1); \n");//$NON-NLS-1$
writer.write(" __builtin_conj(1); \n");//$NON-NLS-1$
writer.write(" __builtin_conjf(1); \n");//$NON-NLS-1$
writer.write(" __builtin_conjl(1); \n");//$NON-NLS-1$
writer.write(" __builtin_creal(1); \n");//$NON-NLS-1$
writer.write(" __builtin_crealf(1); \n");//$NON-NLS-1$
writer.write(" __builtin_creall(1); \n");//$NON-NLS-1$
writer.write(" __builtin_cimag(1); \n");//$NON-NLS-1$
writer.write(" __builtin_cimagf(1); \n");//$NON-NLS-1$
writer.write(" __builtin_cimagl(1); \n");//$NON-NLS-1$
writer.write(" __builtin_imaxabs(1); \n");//$NON-NLS-1$
writer.write(" __builtin_llabs(1); \n");//$NON-NLS-1$
writer.write(" __builtin_vscanf(\"\",b);\n");//$NON-NLS-1$
writer.write(" __builtin_vsnprintf(a, 1, \"\", b); \n");//$NON-NLS-1$
writer.write(" __builtin_vsscanf(\"\", \"\", b);\n");//$NON-NLS-1$
writer.write(" __builtin_cosf(1); \n");//$NON-NLS-1$
writer.write(" __builtin_cosl(1); \n");//$NON-NLS-1$
writer.write(" __builtin_expf(1); \n");//$NON-NLS-1$
writer.write(" __builtin_expl(1); \n");//$NON-NLS-1$
writer.write(" __builtin_fabsf(1); \n");//$NON-NLS-1$
writer.write(" __builtin_fabsl(1); \n");//$NON-NLS-1$
writer.write(" __builtin_logf(1); \n");//$NON-NLS-1$
writer.write(" __builtin_logl(1); \n");//$NON-NLS-1$
writer.write(" __builtin_sinf(1); \n");//$NON-NLS-1$
writer.write(" __builtin_sinl(1); \n");//$NON-NLS-1$
writer.write(" __builtin_sqrtf(1); \n");//$NON-NLS-1$
writer.write(" __builtin_sqrtl(1); \n");//$NON-NLS-1$
writer.write(" __builtin_abs(1); \n");//$NON-NLS-1$
writer.write(" __builtin_cos(1); \n");//$NON-NLS-1$
writer.write(" __builtin_exp(1); \n");//$NON-NLS-1$
writer.write(" __builtin_fabs(1); \n");//$NON-NLS-1$
writer.write(" __builtin_fprintf((void*)0, \"\");\n");//$NON-NLS-1$
writer.write(" __builtin_fputs(\"\", (void*)0);\n");//$NON-NLS-1$
writer.write(" __builtin_labs(1); \n");//$NON-NLS-1$
writer.write(" __builtin_log(1); \n");//$NON-NLS-1$
writer.write(" __builtin_memcmp((void*)0, (void*)0, 1);\n");//$NON-NLS-1$
writer.write(" __builtin_memcpy((void*)0,(void*)0, 1);\n");//$NON-NLS-1$
writer.write(" __builtin_memset((void*)0, 1, 1);\n");//$NON-NLS-1$
writer.write(" __builtin_printf(\"\"); \n");//$NON-NLS-1$
writer.write(" __builtin_putchar(1); \n");//$NON-NLS-1$
writer.write(" __builtin_puts(\"\"); \n");//$NON-NLS-1$
writer.write(" __builtin_scanf(\"\"); \n");//$NON-NLS-1$
writer.write(" __builtin_sin(1); \n");//$NON-NLS-1$
writer.write(" __builtin_snprintf(a, 1, \"\");\n");//$NON-NLS-1$
writer.write(" __builtin_sprintf(a, \"\");\n");//$NON-NLS-1$
writer.write(" __builtin_sqrt(1); \n");//$NON-NLS-1$
writer.write(" __builtin_sscanf(\"\", \"\"); \n");//$NON-NLS-1$1
writer.write(" __builtin_strcat(a, \"\"); \n");//$NON-NLS-1$
writer.write(" __builtin_strchr(\"\", 1); \n");//$NON-NLS-1$
writer.write(" __builtin_strcmp(\"\", \"\"); \n");//$NON-NLS-1$
writer.write(" __builtin_strcpy(a, \"\"); \n");//$NON-NLS-1$
writer.write(" __builtin_strcspn(\"\", \"\");\n");//$NON-NLS-1$
writer.write(" __builtin_strlen(\"\"); \n");//$NON-NLS-1$
writer.write(" __builtin_strncat(a, \"\", 1);\n");//$NON-NLS-1$
writer.write(" __builtin_strncmp(\"\", \"\", 1);\n");//$NON-NLS-1$
writer.write(" __builtin_strncpy(a, \"\", 1);\n");//$NON-NLS-1$
writer.write(" __builtin_strpbrk(\"\", \"\");\n");//$NON-NLS-1$
writer.write(" __builtin_strrchr(\"\", 1); \n");//$NON-NLS-1$
writer.write(" __builtin_strspn(\"\", \"\"); \n");//$NON-NLS-1$
writer.write(" __builtin_strstr(\"\", \"\"); \n");//$NON-NLS-1$
writer.write(" __builtin_strstr(\"\", \"\"); \n");//$NON-NLS-1$
writer.write(" __builtin_vprintf(a, b);\n");//$NON-NLS-1$
writer.write(" __builtin_vsprintf(a, \"\", b); \n");//$NON-NLS-1$
writer.write(" __builtin_isgreater(1.0,1.0); \n");//$NON-NLS-1$
writer.write(" __builtin_isgreaterequal(1.0,1.0);\n");//$NON-NLS-1$
writer.write(" __builtin_isless(1.0,1.0); \n");//$NON-NLS-1$
writer.write(" __builtin_islessequal(1.0,1.0); \n");//$NON-NLS-1$
writer.write(" __builtin_islessgreater(1.0,1.0); \n");//$NON-NLS-1$
writer.write(" __builtin_isunordered(1.0,1.0); \n");//$NON-NLS-1$
writer.write("} \n"); //$NON-NLS-1$
writer.write("void f(){ \n");
writer.write(" char a[10]; \n");
writer.write(" __builtin_va_list b; \n");
writer.write(" __builtin_abort(); \n");
writer.write(" __builtin_exit(1); \n");
writer.write(" __builtin__Exit(1); \n");
writer.write(" __builtin__exit(1); \n");
writer.write(" __builtin_conj(1); \n");
writer.write(" __builtin_conjf(1); \n");
writer.write(" __builtin_conjl(1); \n");
writer.write(" __builtin_creal(1); \n");
writer.write(" __builtin_crealf(1); \n");
writer.write(" __builtin_creall(1); \n");
writer.write(" __builtin_cimag(1); \n");
writer.write(" __builtin_cimagf(1); \n");
writer.write(" __builtin_cimagl(1); \n");
writer.write(" __builtin_imaxabs(1); \n");
writer.write(" __builtin_llabs(1); \n");
writer.write(" __builtin_vscanf(\"\",b);\n");
writer.write(" __builtin_vsnprintf(a, 1, \"\", b); \n");
writer.write(" __builtin_vsscanf(\"\", \"\", b);\n");
writer.write(" __builtin_cosf(1); \n");
writer.write(" __builtin_cosl(1); \n");
writer.write(" __builtin_expf(1); \n");
writer.write(" __builtin_expl(1); \n");
writer.write(" __builtin_fabsf(1); \n");
writer.write(" __builtin_fabsl(1); \n");
writer.write(" __builtin_logf(1); \n");
writer.write(" __builtin_logl(1); \n");
writer.write(" __builtin_sinf(1); \n");
writer.write(" __builtin_sinl(1); \n");
writer.write(" __builtin_sqrtf(1); \n");
writer.write(" __builtin_sqrtl(1); \n");
writer.write(" __builtin_abs(1); \n");
writer.write(" __builtin_cos(1); \n");
writer.write(" __builtin_exp(1); \n");
writer.write(" __builtin_fabs(1); \n");
writer.write(" __builtin_fprintf((void*)0, \"\");\n");
writer.write(" __builtin_fputs(\"\", (void*)0);\n");
writer.write(" __builtin_labs(1); \n");
writer.write(" __builtin_log(1); \n");
writer.write(" __builtin_memcmp((void*)0, (void*)0, 1);\n");
writer.write(" __builtin_memcpy((void*)0,(void*)0, 1);\n");
writer.write(" __builtin_memset((void*)0, 1, 1);\n");
writer.write(" __builtin_printf(\"\"); \n");
writer.write(" __builtin_putchar(1); \n");
writer.write(" __builtin_puts(\"\"); \n");
writer.write(" __builtin_scanf(\"\"); \n");
writer.write(" __builtin_sin(1); \n");
writer.write(" __builtin_snprintf(a, 1, \"\");\n");
writer.write(" __builtin_sprintf(a, \"\");\n");
writer.write(" __builtin_sqrt(1); \n");
writer.write(" __builtin_sscanf(\"\", \"\"); \n");
writer.write(" __builtin_strcat(a, \"\"); \n");
writer.write(" __builtin_strchr(\"\", 1); \n");
writer.write(" __builtin_strcmp(\"\", \"\"); \n");
writer.write(" __builtin_strcpy(a, \"\"); \n");
writer.write(" __builtin_strcspn(\"\", \"\");\n");
writer.write(" __builtin_strlen(\"\"); \n");
writer.write(" __builtin_strncat(a, \"\", 1);\n");
writer.write(" __builtin_strncmp(\"\", \"\", 1);\n");
writer.write(" __builtin_strncpy(a, \"\", 1);\n");
writer.write(" __builtin_strpbrk(\"\", \"\");\n");
writer.write(" __builtin_strrchr(\"\", 1); \n");
writer.write(" __builtin_strspn(\"\", \"\"); \n");
writer.write(" __builtin_strstr(\"\", \"\"); \n");
writer.write(" __builtin_strstr(\"\", \"\"); \n");
writer.write(" __builtin_vprintf(a, b);\n");
writer.write(" __builtin_vsprintf(a, \"\", b); \n");
writer.write(" __builtin_isgreater(1.0,1.0); \n");
writer.write(" __builtin_isgreaterequal(1.0,1.0);\n");
writer.write(" __builtin_isless(1.0,1.0); \n");
writer.write(" __builtin_islessequal(1.0,1.0); \n");
writer.write(" __builtin_islessgreater(1.0,1.0); \n");
writer.write(" __builtin_isunordered(1.0,1.0); \n");
writer.write("} \n");
final String code = writer.toString();
parseGCC(code);
@ -403,8 +392,7 @@ public class GCCCompleteParseExtensionsTest extends AST2BaseTest {
// (__offsetof__ (reinterpret_cast <__size_t> \
// (& reinterpret_cast <const volatile char &> \
// (static_cast<type *> (0)->field))))
String code= getAboveComment();
parseGPP(code);
parseGPP(getAboveComment());
}
// void test(){

View file

@ -40,20 +40,20 @@ public class GCCTests extends AST2BaseTest {
public void testGCC20000113() throws Exception {
StringBuilder buffer = new StringBuilder();
buffer.append("struct x { \n"); //$NON-NLS-1$
buffer.append(" unsigned x1:1; \n"); //$NON-NLS-1$
buffer.append(" unsigned x2:2; \n"); //$NON-NLS-1$
buffer.append(" unsigned x3:3; \n"); //$NON-NLS-1$
buffer.append("}; \n"); //$NON-NLS-1$
buffer.append("foobar(int x, int y, int z) { \n"); //$NON-NLS-1$
buffer.append(" struct x a = {x, y, z}; \n"); //$NON-NLS-1$
buffer.append(" struct x b = {x, y, z}; \n"); //$NON-NLS-1$
buffer.append(" struct x *c = &b; \n"); //$NON-NLS-1$
buffer.append(" c->x3 += (a.x2 - a.x1) * c->x2; \n"); //$NON-NLS-1$
buffer.append(" if (a.x1 != 1 || c->x3 != 5) \n"); //$NON-NLS-1$
buffer.append(" return -1; \n"); //$NON-NLS-1$
buffer.append(" return 0; \n"); //$NON-NLS-1$
buffer.append("} \n"); //$NON-NLS-1$
buffer.append("struct x { \n");
buffer.append(" unsigned x1:1; \n");
buffer.append(" unsigned x2:2; \n");
buffer.append(" unsigned x3:3; \n");
buffer.append("}; \n");
buffer.append("foobar(int x, int y, int z) { \n");
buffer.append(" struct x a = {x, y, z}; \n");
buffer.append(" struct x b = {x, y, z}; \n");
buffer.append(" struct x *c = &b; \n");
buffer.append(" c->x3 += (a.x2 - a.x1) * c->x2; \n");
buffer.append(" if (a.x1 != 1 || c->x3 != 5) \n");
buffer.append(" return -1; \n");
buffer.append(" return 0; \n");
buffer.append("} \n");
IASTTranslationUnit tu = parse(buffer.toString(), ParserLanguage.C);
@ -86,15 +86,15 @@ public class GCCTests extends AST2BaseTest {
public void testGCC20000205() throws Exception{
StringBuilder buffer = new StringBuilder();
buffer.append("static int f(int a) { \n"); //$NON-NLS-1$
buffer.append(" if (a == 0) \n"); //$NON-NLS-1$
buffer.append(" return 0; \n"); //$NON-NLS-1$
buffer.append(" do \n"); //$NON-NLS-1$
buffer.append(" if (a & 128) \n"); //$NON-NLS-1$
buffer.append(" return 1; \n"); //$NON-NLS-1$
buffer.append(" while (f(0)); \n"); //$NON-NLS-1$
buffer.append(" return 0; \n"); //$NON-NLS-1$
buffer.append("} \n"); //$NON-NLS-1$
buffer.append("static int f(int a) { \n");
buffer.append(" if (a == 0) \n");
buffer.append(" return 0; \n");
buffer.append(" do \n");
buffer.append(" if (a & 128) \n");
buffer.append(" return 1; \n");
buffer.append(" while (f(0)); \n");
buffer.append(" return 0; \n");
buffer.append("} \n");
IASTTranslationUnit tu = parse(buffer.toString(), ParserLanguage.C);
@ -111,18 +111,18 @@ public class GCCTests extends AST2BaseTest {
public void testGCC20000217() throws Exception{
StringBuilder buffer = new StringBuilder();
buffer.append("unsigned short int showbug(unsigned short int * a, \n"); //$NON-NLS-1$
buffer.append(" unsigned short int * b) { \n"); //$NON-NLS-1$
buffer.append(" *a += *b - 8; \n"); //$NON-NLS-1$
buffer.append(" return (*a >= 8); \n"); //$NON-NLS-1$
buffer.append("} \n"); //$NON-NLS-1$
buffer.append("int main() { \n"); //$NON-NLS-1$
buffer.append(" unsigned short int x = 0; \n"); //$NON-NLS-1$
buffer.append(" unsigned short int y = 10; \n"); //$NON-NLS-1$
buffer.append(" if (showbug(&x, &y) != 0) \n"); //$NON-NLS-1$
buffer.append(" return -1; \n"); //$NON-NLS-1$
buffer.append(" return 0; \n"); //$NON-NLS-1$
buffer.append("} \n"); //$NON-NLS-1$
buffer.append("unsigned short int showbug(unsigned short int * a, \n");
buffer.append(" unsigned short int * b) { \n");
buffer.append(" *a += *b - 8; \n");
buffer.append(" return (*a >= 8); \n");
buffer.append("} \n");
buffer.append("int main() { \n");
buffer.append(" unsigned short int x = 0; \n");
buffer.append(" unsigned short int y = 10; \n");
buffer.append(" if (showbug(&x, &y) != 0) \n");
buffer.append(" return -1; \n");
buffer.append(" return 0; \n");
buffer.append("} \n");
IASTTranslationUnit tu = parse(buffer.toString(), ParserLanguage.C);
CNameCollector collector = new CNameCollector();
@ -145,22 +145,22 @@ public class GCCTests extends AST2BaseTest {
public void testGCC20000224() throws Exception{
StringBuilder buffer = new StringBuilder();
buffer.append("int loop_1 = 100; \n"); //$NON-NLS-1$
buffer.append("int loop_2 = 7; \n"); //$NON-NLS-1$
buffer.append("int flag = 0; \n"); //$NON-NLS-1$
buffer.append("int test(void) { \n"); //$NON-NLS-1$
buffer.append(" int i; \n"); //$NON-NLS-1$
buffer.append(" int counter = 0; \n"); //$NON-NLS-1$
buffer.append(" while (loop_1 > counter) { \n"); //$NON-NLS-1$
buffer.append(" if (flag & 1) { \n"); //$NON-NLS-1$
buffer.append(" for (i = 0; i < loop_2; i++) { \n"); //$NON-NLS-1$
buffer.append(" counter++; \n"); //$NON-NLS-1$
buffer.append(" } \n"); //$NON-NLS-1$
buffer.append(" } \n"); //$NON-NLS-1$
buffer.append(" flag++; \n"); //$NON-NLS-1$
buffer.append(" } \n"); //$NON-NLS-1$
buffer.append(" return 1; \n"); //$NON-NLS-1$
buffer.append("} \n"); //$NON-NLS-1$
buffer.append("int loop_1 = 100; \n");
buffer.append("int loop_2 = 7; \n");
buffer.append("int flag = 0; \n");
buffer.append("int test(void) { \n");
buffer.append(" int i; \n");
buffer.append(" int counter = 0; \n");
buffer.append(" while (loop_1 > counter) { \n");
buffer.append(" if (flag & 1) { \n");
buffer.append(" for (i = 0; i < loop_2; i++) { \n");
buffer.append(" counter++; \n");
buffer.append(" } \n");
buffer.append(" } \n");
buffer.append(" flag++; \n");
buffer.append(" } \n");
buffer.append(" return 1; \n");
buffer.append("} \n");
IASTTranslationUnit tu = parse(buffer.toString(), ParserLanguage.C);
CNameCollector collector = new CNameCollector();
@ -182,19 +182,19 @@ public class GCCTests extends AST2BaseTest {
public void testGCC20000225() throws Exception {
StringBuilder buffer = new StringBuilder();
buffer.append("int main() { \n"); //$NON-NLS-1$
buffer.append(" int nResult, b = 0, i = -1; \n"); //$NON-NLS-1$
buffer.append(" do { \n"); //$NON-NLS-1$
buffer.append(" if (b != 0) { \n"); //$NON-NLS-1$
buffer.append(" nResult = 1; \n"); //$NON-NLS-1$
buffer.append(" } else { \n"); //$NON-NLS-1$
buffer.append(" nResult = 0; \n"); //$NON-NLS-1$
buffer.append(" } \n"); //$NON-NLS-1$
buffer.append(" i++; \n"); //$NON-NLS-1$
buffer.append(" b = (i + 2) * 4; \n"); //$NON-NLS-1$
buffer.append(" } while (i < 0); \n"); //$NON-NLS-1$
buffer.append(" return -1; \n"); //$NON-NLS-1$
buffer.append("} \n"); //$NON-NLS-1$
buffer.append("int main() { \n");
buffer.append(" int nResult, b = 0, i = -1; \n");
buffer.append(" do { \n");
buffer.append(" if (b != 0) { \n");
buffer.append(" nResult = 1; \n");
buffer.append(" } else { \n");
buffer.append(" nResult = 0; \n");
buffer.append(" } \n");
buffer.append(" i++; \n");
buffer.append(" b = (i + 2) * 4; \n");
buffer.append(" } while (i < 0); \n");
buffer.append(" return -1; \n");
buffer.append("} \n");
IASTTranslationUnit tu = parse(buffer.toString(), ParserLanguage.C);
CNameCollector collector = new CNameCollector();
@ -212,17 +212,17 @@ public class GCCTests extends AST2BaseTest {
public void testGCC20000227() throws Exception {
StringBuilder buffer = new StringBuilder();
buffer.append("static const unsigned char f[] = \"\\0\\377\"; \n"); //$NON-NLS-1$
buffer.append("static const unsigned char g[] = \"\\0y\"; \n"); //$NON-NLS-1$
buffer.append("int main() { \n"); //$NON-NLS-1$
buffer.append(" if (sizeof f != 3 || sizeof g != 3) \n"); //$NON-NLS-1$
buffer.append(" return -1; \n"); //$NON-NLS-1$
buffer.append(" if (f[0] != g[0]) \n"); //$NON-NLS-1$
buffer.append(" return -1; \n"); //$NON-NLS-1$
buffer.append(" if (f[1] != g[1] || f[2] != g[2]) \n"); //$NON-NLS-1$
buffer.append(" return -1; \n"); //$NON-NLS-1$
buffer.append(" return 0; \n"); //$NON-NLS-1$
buffer.append("} \n"); //$NON-NLS-1$
buffer.append("static const unsigned char f[] = \"\\0\\377\"; \n");
buffer.append("static const unsigned char g[] = \"\\0y\"; \n");
buffer.append("int main() { \n");
buffer.append(" if (sizeof f != 3 || sizeof g != 3) \n");
buffer.append(" return -1; \n");
buffer.append(" if (f[0] != g[0]) \n");
buffer.append(" return -1; \n");
buffer.append(" if (f[1] != g[1] || f[2] != g[2]) \n");
buffer.append(" return -1; \n");
buffer.append(" return 0; \n");
buffer.append("} \n");
IASTTranslationUnit tu = parse(buffer.toString(), ParserLanguage.C);
CNameCollector collector = new CNameCollector();
@ -238,21 +238,21 @@ public class GCCTests extends AST2BaseTest {
public void testGCC20000313() throws Exception{
StringBuilder buffer = new StringBuilder();
buffer.append("unsigned int buggy(unsigned int *param) { \n"); //$NON-NLS-1$
buffer.append(" unsigned int accu, zero = 0, borrow; \n"); //$NON-NLS-1$
buffer.append(" accu = - *param; \n"); //$NON-NLS-1$
buffer.append(" borrow = - (accu > zero); \n"); //$NON-NLS-1$
buffer.append(" return borrow; \n"); //$NON-NLS-1$
buffer.append("} \n"); //$NON-NLS-1$
buffer.append("int main(void) { \n"); //$NON-NLS-1$
buffer.append(" unsigned int param = 1; \n"); //$NON-NLS-1$
buffer.append(" unsigned int borrow = buggy (&param); \n"); //$NON-NLS-1$
buffer.append(" if (param != 0) \n"); //$NON-NLS-1$
buffer.append(" return -1; \n"); //$NON-NLS-1$
buffer.append(" if (borrow +1 != 0) \n"); //$NON-NLS-1$
buffer.append(" return -1; \n"); //$NON-NLS-1$
buffer.append(" return 0; \n"); //$NON-NLS-1$
buffer.append("} \n"); //$NON-NLS-1$
buffer.append("unsigned int buggy(unsigned int *param) { \n");
buffer.append(" unsigned int accu, zero = 0, borrow; \n");
buffer.append(" accu = - *param; \n");
buffer.append(" borrow = - (accu > zero); \n");
buffer.append(" return borrow; \n");
buffer.append("} \n");
buffer.append("int main(void) { \n");
buffer.append(" unsigned int param = 1; \n");
buffer.append(" unsigned int borrow = buggy (&param); \n");
buffer.append(" if (param != 0) \n");
buffer.append(" return -1; \n");
buffer.append(" if (borrow +1 != 0) \n");
buffer.append(" return -1; \n");
buffer.append(" return 0; \n");
buffer.append("} \n");
IASTTranslationUnit tu = parse(buffer.toString(), ParserLanguage.C);
CNameCollector collector = new CNameCollector();
@ -278,16 +278,16 @@ public class GCCTests extends AST2BaseTest {
public void testGCC20000314_1() throws Exception{
StringBuilder buffer = new StringBuilder();
buffer.append("int main() { \n"); //$NON-NLS-1$
buffer.append(" long winds = 0; \n"); //$NON-NLS-1$
buffer.append(" while (winds != 0) { \n"); //$NON-NLS-1$
buffer.append(" if (*(char*)winds) \n"); //$NON-NLS-1$
buffer.append(" break; \n"); //$NON-NLS-1$
buffer.append(" } \n"); //$NON-NLS-1$
buffer.append(" if (winds == 0 || winds != 0 || *(char*) winds) \n"); //$NON-NLS-1$
buffer.append(" return 0; \n"); //$NON-NLS-1$
buffer.append(" return -1; \n"); //$NON-NLS-1$
buffer.append("} \n"); //$NON-NLS-1$
buffer.append("int main() { \n");
buffer.append(" long winds = 0; \n");
buffer.append(" while (winds != 0) { \n");
buffer.append(" if (*(char*)winds) \n");
buffer.append(" break; \n");
buffer.append(" } \n");
buffer.append(" if (winds == 0 || winds != 0 || *(char*) winds) \n");
buffer.append(" return 0; \n");
buffer.append(" return -1; \n");
buffer.append("} \n");
IASTTranslationUnit tu = parse(buffer.toString(), ParserLanguage.C);
CNameCollector collector = new CNameCollector();
@ -301,19 +301,19 @@ public class GCCTests extends AST2BaseTest {
public void testGCC20000314_2() throws Exception{
StringBuilder buffer = new StringBuilder();
buffer.append("typedef unsigned long long uint64; \n"); //$NON-NLS-1$
buffer.append("const uint64 bigconst = 1ULL << 34; \n"); //$NON-NLS-1$
buffer.append("int a = 1; \n"); //$NON-NLS-1$
buffer.append("static uint64 getmask(void) { \n"); //$NON-NLS-1$
buffer.append(" if (a) return bigconst; \n"); //$NON-NLS-1$
buffer.append(" else return 0; \n"); //$NON-NLS-1$
buffer.append("} \n"); //$NON-NLS-1$
buffer.append("main() { \n"); //$NON-NLS-1$
buffer.append(" uint64 f = getmask(); \n"); //$NON-NLS-1$
buffer.append(" if (sizeof (long long) == 8 && f != bigconst) \n"); //$NON-NLS-1$
buffer.append(" return -1; \n"); //$NON-NLS-1$
buffer.append(" return 0; \n"); //$NON-NLS-1$
buffer.append("} \n"); //$NON-NLS-1$
buffer.append("typedef unsigned long long uint64; \n");
buffer.append("const uint64 bigconst = 1ULL << 34; \n");
buffer.append("int a = 1; \n");
buffer.append("static uint64 getmask(void) { \n");
buffer.append(" if (a) return bigconst; \n");
buffer.append(" else return 0; \n");
buffer.append("} \n");
buffer.append("main() { \n");
buffer.append(" uint64 f = getmask(); \n");
buffer.append(" if (sizeof (long long) == 8 && f != bigconst) \n");
buffer.append(" return -1; \n");
buffer.append(" return 0; \n");
buffer.append("} \n");
IASTTranslationUnit tu = parse(buffer.toString(), ParserLanguage.C);
CNameCollector collector = new CNameCollector();
@ -335,23 +335,23 @@ public class GCCTests extends AST2BaseTest {
public void testGCC20000403() throws Exception {
StringBuilder buffer = new StringBuilder();
buffer.append("extern unsigned long aa[], bb[]; \n"); //$NON-NLS-1$
buffer.append("int seqgt(unsigned long a, unsigned short win, unsigned long b); \n"); //$NON-NLS-1$
buffer.append("int seqgt2 (unsigned long a, unsigned short win, unsigned long b); \n"); //$NON-NLS-1$
buffer.append("main() { \n"); //$NON-NLS-1$
buffer.append(" if (!seqgt(*aa, 0x1000, *bb) || !seqgt2(*aa, 0x1000, *bb)) \n"); //$NON-NLS-1$
buffer.append(" return -1; \n"); //$NON-NLS-1$
buffer.append(" return 0; \n"); //$NON-NLS-1$
buffer.append("} \n"); //$NON-NLS-1$
buffer.append("int seqgt(unsigned long a, unsigned short win, unsigned long b) { \n"); //$NON-NLS-1$
buffer.append(" return (long) ((a + win) - b) > 0; \n"); //$NON-NLS-1$
buffer.append("} \n"); //$NON-NLS-1$
buffer.append("int seqgt2(unsigned long a, unsigned short win, unsigned long b) { \n"); //$NON-NLS-1$
buffer.append(" long l = ((a + win) - b); \n"); //$NON-NLS-1$
buffer.append(" return 1 > 0; \n"); //$NON-NLS-1$
buffer.append("} \n"); //$NON-NLS-1$
buffer.append("unsigned long aa[] = { (1UL << (sizeof(long) *8 - 1)) = 0xfff }; \n"); //$NON-NLS-1$
buffer.append("unsigned long bb[] = { (1UL << (sizeof(long) *8 - 1)) = 0xfff }; \n"); //$NON-NLS-1$
buffer.append("extern unsigned long aa[], bb[]; \n");
buffer.append("int seqgt(unsigned long a, unsigned short win, unsigned long b); \n");
buffer.append("int seqgt2 (unsigned long a, unsigned short win, unsigned long b); \n");
buffer.append("main() { \n");
buffer.append(" if (!seqgt(*aa, 0x1000, *bb) || !seqgt2(*aa, 0x1000, *bb)) \n");
buffer.append(" return -1; \n");
buffer.append(" return 0; \n");
buffer.append("} \n");
buffer.append("int seqgt(unsigned long a, unsigned short win, unsigned long b) { \n");
buffer.append(" return (long) ((a + win) - b) > 0; \n");
buffer.append("} \n");
buffer.append("int seqgt2(unsigned long a, unsigned short win, unsigned long b) { \n");
buffer.append(" long l = ((a + win) - b); \n");
buffer.append(" return 1 > 0; \n");
buffer.append("} \n");
buffer.append("unsigned long aa[] = { (1UL << (sizeof(long) *8 - 1)) = 0xfff }; \n");
buffer.append("unsigned long bb[] = { (1UL << (sizeof(long) *8 - 1)) = 0xfff }; \n");
IASTTranslationUnit tu = parse(buffer.toString(), ParserLanguage.C);
CNameCollector collector = new CNameCollector();
@ -383,17 +383,17 @@ public class GCCTests extends AST2BaseTest {
public void testGCC20000412_1 () throws Exception {
StringBuilder buffer = new StringBuilder();
buffer.append("short int i = -1; \n"); //$NON-NLS-1$
buffer.append("const char * const wordlist[207]; \n"); //$NON-NLS-1$
buffer.append("const char * const * foo(void) { \n"); //$NON-NLS-1$
buffer.append(" register const char * const *wordptr = &wordlist[207u + i]; \n"); //$NON-NLS-1$
buffer.append(" return wordptr; \n"); //$NON-NLS-1$
buffer.append("} \n"); //$NON-NLS-1$
buffer.append("int main() { \n"); //$NON-NLS-1$
buffer.append(" if (foo() != &wordlist[206]) \n"); //$NON-NLS-1$
buffer.append(" return -1; \n"); //$NON-NLS-1$
buffer.append(" return 0; \n"); //$NON-NLS-1$
buffer.append("} \n"); //$NON-NLS-1$
buffer.append("short int i = -1; \n");
buffer.append("const char * const wordlist[207]; \n");
buffer.append("const char * const * foo(void) { \n");
buffer.append(" register const char * const *wordptr = &wordlist[207u + i]; \n");
buffer.append(" return wordptr; \n");
buffer.append("} \n");
buffer.append("int main() { \n");
buffer.append(" if (foo() != &wordlist[206]) \n");
buffer.append(" return -1; \n");
buffer.append(" return 0; \n");
buffer.append("} \n");
IASTTranslationUnit tu = parse(buffer.toString(), ParserLanguage.C);
CNameCollector collector = new CNameCollector();
@ -413,16 +413,16 @@ public class GCCTests extends AST2BaseTest {
public void testGCC20000412_2() throws Exception {
StringBuilder buffer = new StringBuilder();
buffer.append("int f(int a, int *y) { \n"); //$NON-NLS-1$
buffer.append(" int x = a; \n"); //$NON-NLS-1$
buffer.append(" if (a == 0) return *y; \n"); //$NON-NLS-1$
buffer.append(" return f(a-1, &x); \n"); //$NON-NLS-1$
buffer.append("} \n"); //$NON-NLS-1$
buffer.append("int main(int argc, char** argv) { \n"); //$NON-NLS-1$
buffer.append(" if (f(100, (int *) 0) != 1) \n"); //$NON-NLS-1$
buffer.append(" return -1; \n"); //$NON-NLS-1$
buffer.append(" return 0; \n"); //$NON-NLS-1$
buffer.append("} \n"); //$NON-NLS-1$
buffer.append("int f(int a, int *y) { \n");
buffer.append(" int x = a; \n");
buffer.append(" if (a == 0) return *y; \n");
buffer.append(" return f(a-1, &x); \n");
buffer.append("} \n");
buffer.append("int main(int argc, char** argv) { \n");
buffer.append(" if (f(100, (int *) 0) != 1) \n");
buffer.append(" return -1; \n");
buffer.append(" return 0; \n");
buffer.append("} \n");
IASTTranslationUnit tu = parse(buffer.toString(), ParserLanguage.C);
CNameCollector collector = new CNameCollector();
@ -442,27 +442,27 @@ public class GCCTests extends AST2BaseTest {
public void testGCC20000412_3() throws Exception{
StringBuilder buffer = new StringBuilder();
buffer.append("typedef struct { \n"); //$NON-NLS-1$
buffer.append(" char y; \n"); //$NON-NLS-1$
buffer.append(" char x[32]; \n"); //$NON-NLS-1$
buffer.append("} X; \n"); //$NON-NLS-1$
buffer.append("int z(void) { \n"); //$NON-NLS-1$
buffer.append(" X xxx; \n"); //$NON-NLS-1$
buffer.append(" xxx.x[0] = xxx.x[31] = '0'; \n"); //$NON-NLS-1$
buffer.append(" xxx.y = 0xf; \n"); //$NON-NLS-1$
buffer.append(" return f(xxx, xxx); \n"); //$NON-NLS-1$
buffer.append("} \n"); //$NON-NLS-1$
buffer.append("int main (void) { \n"); //$NON-NLS-1$
buffer.append(" int val; \n"); //$NON-NLS-1$
buffer.append(" val = z(); \n"); //$NON-NLS-1$
buffer.append(" if (val != 0x60) return -1; \n"); //$NON-NLS-1$
buffer.append(" return 0; \n"); //$NON-NLS-1$
buffer.append("} \n"); //$NON-NLS-1$
buffer.append("int f(X x, X y) { \n"); //$NON-NLS-1$
buffer.append(" if (x.y != y.y) \n"); //$NON-NLS-1$
buffer.append(" return 'F'; \n"); //$NON-NLS-1$
buffer.append(" return x.x[0] + y.x[0]; \n"); //$NON-NLS-1$
buffer.append("} \n"); //$NON-NLS-1$
buffer.append("typedef struct { \n");
buffer.append(" char y; \n");
buffer.append(" char x[32]; \n");
buffer.append("} X; \n");
buffer.append("int z(void) { \n");
buffer.append(" X xxx; \n");
buffer.append(" xxx.x[0] = xxx.x[31] = '0'; \n");
buffer.append(" xxx.y = 0xf; \n");
buffer.append(" return f(xxx, xxx); \n");
buffer.append("} \n");
buffer.append("int main (void) { \n");
buffer.append(" int val; \n");
buffer.append(" val = z(); \n");
buffer.append(" if (val != 0x60) return -1; \n");
buffer.append(" return 0; \n");
buffer.append("} \n");
buffer.append("int f(X x, X y) { \n");
buffer.append(" if (x.y != y.y) \n");
buffer.append(" return 'F'; \n");
buffer.append(" return x.x[0] + y.x[0]; \n");
buffer.append("} \n");
IASTTranslationUnit tu = parse(buffer.toString(), ParserLanguage.C);
CNameCollector collector = new CNameCollector();
@ -490,24 +490,24 @@ public class GCCTests extends AST2BaseTest {
public void testGCC20000412_4() throws Exception{
StringBuilder buffer = new StringBuilder();
buffer.append("void f(int i, int j, int radius, int width, int N) { \n"); //$NON-NLS-1$
buffer.append(" const int diff = i - radius; \n"); //$NON-NLS-1$
buffer.append(" const int lowk = (diff > 0 ? diff : 0); \n"); //$NON-NLS-1$
buffer.append(" int k; \n"); //$NON-NLS-1$
buffer.append(" for (k = lowk; k <= 2; k++) { \n"); //$NON-NLS-1$
buffer.append(" int idx = ((k-i+radius) * width - j + radius); \n"); //$NON-NLS-1$
buffer.append(" if (idx < 0) return -1; \n"); //$NON-NLS-1$
buffer.append(" } \n"); //$NON-NLS-1$
buffer.append(" for (k = lowk; k <= 2; k++) ; \n"); //$NON-NLS-1$
buffer.append("} \n"); //$NON-NLS-1$
buffer.append("int main (int argc, char** argv) { \n"); //$NON-NLS-1$
buffer.append(" int exc_rad = 2; \n"); //$NON-NLS-1$
buffer.append(" int N = 8; \n"); //$NON-NLS-1$
buffer.append(" int i; \n"); //$NON-NLS-1$
buffer.append(" for (i = 1; i < 4; i++) \n"); //$NON-NLS-1$
buffer.append(" f(i, 1, exc_rad, 2*exc_rad + 1, N); \n"); //$NON-NLS-1$
buffer.append(" return 0; \n"); //$NON-NLS-1$
buffer.append("} \n"); //$NON-NLS-1$
buffer.append("void f(int i, int j, int radius, int width, int N) { \n");
buffer.append(" const int diff = i - radius; \n");
buffer.append(" const int lowk = (diff > 0 ? diff : 0); \n");
buffer.append(" int k; \n");
buffer.append(" for (k = lowk; k <= 2; k++) { \n");
buffer.append(" int idx = ((k-i+radius) * width - j + radius); \n");
buffer.append(" if (idx < 0) return -1; \n");
buffer.append(" } \n");
buffer.append(" for (k = lowk; k <= 2; k++) ; \n");
buffer.append("} \n");
buffer.append("int main (int argc, char** argv) { \n");
buffer.append(" int exc_rad = 2; \n");
buffer.append(" int N = 8; \n");
buffer.append(" int i; \n");
buffer.append(" for (i = 1; i < 4; i++) \n");
buffer.append(" f(i, 1, exc_rad, 2*exc_rad + 1, N); \n");
buffer.append(" return 0; \n");
buffer.append("} \n");
IASTTranslationUnit tu = parse(buffer.toString(), ParserLanguage.C);
CNameCollector collector = new CNameCollector();
@ -545,15 +545,15 @@ public class GCCTests extends AST2BaseTest {
public void testGCC20000412_5() throws Exception {
StringBuilder buffer = new StringBuilder();
buffer.append("int main(void) { \n"); //$NON-NLS-1$
buffer.append(" struct { \n"); //$NON-NLS-1$
buffer.append(" int node; \n"); //$NON-NLS-1$
buffer.append(" int type; \n"); //$NON-NLS-1$
buffer.append(" } lastglob[1] = { { 0, 1 } }; \n"); //$NON-NLS-1$
buffer.append(" if (lastglob[0].node != 0 || lastglob[0].type != 1) \n"); //$NON-NLS-1$
buffer.append(" return -1; \n"); //$NON-NLS-1$
buffer.append(" return 0; \n"); //$NON-NLS-1$
buffer.append("} \n"); //$NON-NLS-1$
buffer.append("int main(void) { \n");
buffer.append(" struct { \n");
buffer.append(" int node; \n");
buffer.append(" int type; \n");
buffer.append(" } lastglob[1] = { { 0, 1 } }; \n");
buffer.append(" if (lastglob[0].node != 0 || lastglob[0].type != 1) \n");
buffer.append(" return -1; \n");
buffer.append(" return 0; \n");
buffer.append("} \n");
IASTTranslationUnit tu = parse(buffer.toString(), ParserLanguage.C);
CNameCollector collector = new CNameCollector();
@ -571,18 +571,18 @@ public class GCCTests extends AST2BaseTest {
public void testGCC20000419() throws Exception {
StringBuilder buffer = new StringBuilder();
buffer.append("struct foo { int a, b, c; }; \n"); //$NON-NLS-1$
buffer.append("void brother(int a, int b, int c) { \n"); //$NON-NLS-1$
buffer.append(" if (a) return; \n"); //$NON-NLS-1$
buffer.append("} \n"); //$NON-NLS-1$
buffer.append("void sister(struct foo f, int b, int c) { \n"); //$NON-NLS-1$
buffer.append(" brother((f.b == b), b, c); \n"); //$NON-NLS-1$
buffer.append("} \n"); //$NON-NLS-1$
buffer.append("int main() { \n"); //$NON-NLS-1$
buffer.append(" struct foo f = { 7, 8, 9 }; \n"); //$NON-NLS-1$
buffer.append(" sister(f, 1, 2); \n"); //$NON-NLS-1$
buffer.append(" return 0; \n"); //$NON-NLS-1$
buffer.append("} \n"); //$NON-NLS-1$
buffer.append("struct foo { int a, b, c; }; \n");
buffer.append("void brother(int a, int b, int c) { \n");
buffer.append(" if (a) return; \n");
buffer.append("} \n");
buffer.append("void sister(struct foo f, int b, int c) { \n");
buffer.append(" brother((f.b == b), b, c); \n");
buffer.append("} \n");
buffer.append("int main() { \n");
buffer.append(" struct foo f = { 7, 8, 9 }; \n");
buffer.append(" sister(f, 1, 2); \n");
buffer.append(" return 0; \n");
buffer.append("} \n");
IASTTranslationUnit tu = parse(buffer.toString(), ParserLanguage.C);
CNameCollector collector = new CNameCollector();
@ -617,14 +617,15 @@ public class GCCTests extends AST2BaseTest {
assertInstances(collector, sc, 2);
assertInstances(collector, f, 2);
}
public void testGCC20000503() throws Exception {
StringBuilder buffer = new StringBuilder();
buffer.append("unsigned long sub(int a) { \n"); //$NON-NLS-1$
buffer.append(" return ((0 > a - 2) ? 0 : a - 2) * sizeof(long); \n"); //$NON-NLS-1$
buffer.append("} \n"); //$NON-NLS-1$
buffer.append("main() { \n"); //$NON-NLS-1$
buffer.append(" return (sub(0) != 0); \n"); //$NON-NLS-1$
buffer.append("} \n"); //$NON-NLS-1$
buffer.append("unsigned long sub(int a) { \n");
buffer.append(" return ((0 > a - 2) ? 0 : a - 2) * sizeof(long); \n");
buffer.append("} \n");
buffer.append("main() { \n");
buffer.append(" return (sub(0) != 0); \n");
buffer.append("} \n");
IASTTranslationUnit tu = parse(buffer.toString(), ParserLanguage.C);
CNameCollector collector = new CNameCollector();
@ -640,33 +641,33 @@ public class GCCTests extends AST2BaseTest {
public void testGCC20000511() throws Exception {
StringBuilder buffer = new StringBuilder();
buffer.append("int f(int value, int expect) { \n"); //$NON-NLS-1$
buffer.append(" return (value == expect); \n"); //$NON-NLS-1$
buffer.append("} \n"); //$NON-NLS-1$
buffer.append("main() { \n"); //$NON-NLS-1$
buffer.append(" int a = 7, b = 6, c = 4, d = 7, e = 2; \n"); //$NON-NLS-1$
buffer.append(" f(a || b % c, 1); \n"); //$NON-NLS-1$
buffer.append(" f(a ? b % c : 0, 2); \n"); //$NON-NLS-1$
buffer.append(" f(a = b % c, 2); \n"); //$NON-NLS-1$
buffer.append(" f(a *= b % c, 4); \n"); //$NON-NLS-1$
buffer.append(" f(a /= b % c, 2); \n"); //$NON-NLS-1$
buffer.append(" f(a %= b % c, 0); \n"); //$NON-NLS-1$
buffer.append(" f(a += b % c, 2); \n"); //$NON-NLS-1$
buffer.append(" f(d || c && e, 1); \n"); //$NON-NLS-1$
buffer.append(" f(d ? c && e : 0, 1); \n"); //$NON-NLS-1$
buffer.append(" f(d = c && e, 1); \n"); //$NON-NLS-1$
buffer.append(" f(d *= c && e, 1); \n"); //$NON-NLS-1$
buffer.append(" f(d %= c && e, 0); \n"); //$NON-NLS-1$
buffer.append(" f(d += c && e, 1); \n"); //$NON-NLS-1$
buffer.append(" f(d -= c && e, 0); \n"); //$NON-NLS-1$
buffer.append(" f(d || c || e, 1); \n"); //$NON-NLS-1$
buffer.append(" f(d ? c || e : 0, 0); \n"); //$NON-NLS-1$
buffer.append(" f(d = c || e, 1); \n"); //$NON-NLS-1$
buffer.append(" f(d *= c || e, 1); \n"); //$NON-NLS-1$
buffer.append(" f(d %= c || e, 0); \n"); //$NON-NLS-1$
buffer.append(" f(d += c || e, 1); \n"); //$NON-NLS-1$
buffer.append(" f(d -= c || e, 0); \n"); //$NON-NLS-1$
buffer.append("} \n"); //$NON-NLS-1$
buffer.append("int f(int value, int expect) { \n");
buffer.append(" return (value == expect); \n");
buffer.append("} \n");
buffer.append("main() { \n");
buffer.append(" int a = 7, b = 6, c = 4, d = 7, e = 2; \n");
buffer.append(" f(a || b % c, 1); \n");
buffer.append(" f(a ? b % c : 0, 2); \n");
buffer.append(" f(a = b % c, 2); \n");
buffer.append(" f(a *= b % c, 4); \n");
buffer.append(" f(a /= b % c, 2); \n");
buffer.append(" f(a %= b % c, 0); \n");
buffer.append(" f(a += b % c, 2); \n");
buffer.append(" f(d || c && e, 1); \n");
buffer.append(" f(d ? c && e : 0, 1); \n");
buffer.append(" f(d = c && e, 1); \n");
buffer.append(" f(d *= c && e, 1); \n");
buffer.append(" f(d %= c && e, 0); \n");
buffer.append(" f(d += c && e, 1); \n");
buffer.append(" f(d -= c && e, 0); \n");
buffer.append(" f(d || c || e, 1); \n");
buffer.append(" f(d ? c || e : 0, 0); \n");
buffer.append(" f(d = c || e, 1); \n");
buffer.append(" f(d *= c || e, 1); \n");
buffer.append(" f(d %= c || e, 0); \n");
buffer.append(" f(d += c || e, 1); \n");
buffer.append(" f(d -= c || e, 0); \n");
buffer.append("} \n");
IASTTranslationUnit tu = parse(buffer.toString(), ParserLanguage.C);
CNameCollector collector = new CNameCollector();
@ -692,21 +693,22 @@ public class GCCTests extends AST2BaseTest {
assertInstances(collector, d, 15);
assertInstances(collector, e, 15);
}
public void testGCC20000603() throws Exception {
StringBuilder buffer = new StringBuilder();
buffer.append("struct s1 { double d; }; \n"); //$NON-NLS-1$
buffer.append("struct s2 { double d; }; \n"); //$NON-NLS-1$
buffer.append("double f(struct s1 * a, struct s2 *b) { \n"); //$NON-NLS-1$
buffer.append(" a->d = 1.0; \n"); //$NON-NLS-1$
buffer.append(" return b->d + 1.0; \n"); //$NON-NLS-1$
buffer.append("} \n"); //$NON-NLS-1$
buffer.append("int main() { \n"); //$NON-NLS-1$
buffer.append(" struct s1 a; \n"); //$NON-NLS-1$
buffer.append(" a.d = 0.0; \n"); //$NON-NLS-1$
buffer.append(" if (f(&a, (struct s2 *)&a) != 2.0) \n"); //$NON-NLS-1$
buffer.append(" return -1; \n"); //$NON-NLS-1$
buffer.append(" return 0; \n"); //$NON-NLS-1$
buffer.append("} \n"); //$NON-NLS-1$
buffer.append("struct s1 { double d; }; \n");
buffer.append("struct s2 { double d; }; \n");
buffer.append("double f(struct s1 * a, struct s2 *b) { \n");
buffer.append(" a->d = 1.0; \n");
buffer.append(" return b->d + 1.0; \n");
buffer.append("} \n");
buffer.append("int main() { \n");
buffer.append(" struct s1 a; \n");
buffer.append(" a.d = 0.0; \n");
buffer.append(" if (f(&a, (struct s2 *)&a) != 2.0) \n");
buffer.append(" return -1; \n");
buffer.append(" return 0; \n");
buffer.append("} \n");
IASTTranslationUnit tu = parse(buffer.toString(), ParserLanguage.C);
CNameCollector collector = new CNameCollector();
@ -731,20 +733,21 @@ public class GCCTests extends AST2BaseTest {
assertInstances(collector, pb, 2);
assertInstances(collector, a, 4);
}
public void testGCC20000605_2() throws Exception{
StringBuilder buffer = new StringBuilder();
buffer.append("struct F { int i; }; \n"); //$NON-NLS-1$
buffer.append("void f1(struct F *x, struct F * y) { \n"); //$NON-NLS-1$
buffer.append(" int timeout = 0; \n"); //$NON-NLS-1$
buffer.append(" for (; ((const struct F*)x)->i < y->i; x->i++) \n"); //$NON-NLS-1$
buffer.append(" if (++timeout > 5) \n"); //$NON-NLS-1$
buffer.append(" return; \n"); //$NON-NLS-1$
buffer.append("} \n"); //$NON-NLS-1$
buffer.append("main() { \n"); //$NON-NLS-1$
buffer.append(" struct F x, y; \n"); //$NON-NLS-1$
buffer.append(" x.i = 0; y.i = 1; \n"); //$NON-NLS-1$
buffer.append(" f1(&x, &y); \n"); //$NON-NLS-1$
buffer.append("} \n"); //$NON-NLS-1$
buffer.append("struct F { int i; }; \n");
buffer.append("void f1(struct F *x, struct F * y) { \n");
buffer.append(" int timeout = 0; \n");
buffer.append(" for (; ((const struct F*)x)->i < y->i; x->i++) \n");
buffer.append(" if (++timeout > 5) \n");
buffer.append(" return; \n");
buffer.append("} \n");
buffer.append("main() { \n");
buffer.append(" struct F x, y; \n");
buffer.append(" x.i = 0; y.i = 1; \n");
buffer.append(" f1(&x, &y); \n");
buffer.append("} \n");
IASTTranslationUnit tu = parse(buffer.toString(), ParserLanguage.C);
CNameCollector collector = new CNameCollector();
@ -769,20 +772,21 @@ public class GCCTests extends AST2BaseTest {
assertInstances(collector, x, 3);
assertInstances(collector, y, 3);
}
public void testGCC20000605_3() throws Exception{
StringBuilder buffer = new StringBuilder();
buffer.append("struct F { int x; int y; }; \n"); //$NON-NLS-1$
buffer.append("int main() { \n"); //$NON-NLS-1$
buffer.append(" int timeout = 0, x = 0; \n"); //$NON-NLS-1$
buffer.append(" while (1) { \n"); //$NON-NLS-1$
buffer.append(" const struct F i = { x++, }; \n"); //$NON-NLS-1$
buffer.append(" if (i.x > 0) \n"); //$NON-NLS-1$
buffer.append(" break; \n"); //$NON-NLS-1$
buffer.append(" if (++timeout > 5) \n"); //$NON-NLS-1$
buffer.append(" goto die; \n"); //$NON-NLS-1$
buffer.append(" } \n"); //$NON-NLS-1$
buffer.append(" die: return 0; \n"); //$NON-NLS-1$
buffer.append("} \n"); //$NON-NLS-1$
buffer.append("struct F { int x; int y; }; \n");
buffer.append("int main() { \n");
buffer.append(" int timeout = 0, x = 0; \n");
buffer.append(" while (1) { \n");
buffer.append(" const struct F i = { x++, }; \n");
buffer.append(" if (i.x > 0) \n");
buffer.append(" break; \n");
buffer.append(" if (++timeout > 5) \n");
buffer.append(" goto die; \n");
buffer.append(" } \n");
buffer.append(" die: return 0; \n");
buffer.append("} \n");
IASTTranslationUnit tu = parse(buffer.toString(), ParserLanguage.C);
CNameCollector collector = new CNameCollector();
@ -805,15 +809,16 @@ public class GCCTests extends AST2BaseTest {
assertInstances(collector, i, 2);
assertInstances(collector, die, 2);
}
public void testGCCenum_2() throws Exception {
StringBuilder buffer = new StringBuilder();
buffer.append("enum foo { FOO, BAR }; \n"); //$NON-NLS-1$
buffer.append("int main() { \n"); //$NON-NLS-1$
buffer.append(" int i; \n"); //$NON-NLS-1$
buffer.append(" for (i = BAR; i >= FOO; --i) \n"); //$NON-NLS-1$
buffer.append(" if (i == -1) return -1; \n"); //$NON-NLS-1$
buffer.append(" return 0; \n"); //$NON-NLS-1$
buffer.append("} \n"); //$NON-NLS-1$
buffer.append("enum foo { FOO, BAR }; \n");
buffer.append("int main() { \n");
buffer.append(" int i; \n");
buffer.append(" for (i = BAR; i >= FOO; --i) \n");
buffer.append(" if (i == -1) return -1; \n");
buffer.append(" return 0; \n");
buffer.append("} \n");
IASTTranslationUnit tu = parse(buffer.toString(), ParserLanguage.C);
CNameCollector collector = new CNameCollector();

View file

@ -21,6 +21,7 @@ import org.eclipse.cdt.internal.core.dom.parser.GCCBuiltinSymbolProvider;
*/
public class GCCParserExtensionConfiguration extends AbstractCParserExtensionConfiguration {
private static GCCParserExtensionConfiguration sInstance= new GCCParserExtensionConfiguration();
/**
* @since 5.1
*/
@ -28,65 +29,41 @@ public class GCCParserExtensionConfiguration extends AbstractCParserExtensionCon
return sInstance;
}
/*
* @see org.eclipse.cdt.core.dom.parser.c.AbstractCParserExtensionConfiguration#supportStatementsInExpressions()
*/
@Override
public boolean supportStatementsInExpressions() {
return true;
}
/*
* @see org.eclipse.cdt.core.dom.parser.c.AbstractCParserExtensionConfiguration#supportGCCStyleDesignators()
*/
@Override
public boolean supportGCCStyleDesignators() {
return true;
}
/*
* @see org.eclipse.cdt.core.dom.parser.c.AbstractCParserExtensionConfiguration#supportTypeofUnaryExpressions()
*/
@Override
public boolean supportTypeofUnaryExpressions() {
return true;
}
/*
* @see org.eclipse.cdt.core.dom.parser.c.AbstractCParserExtensionConfiguration#supportAlignOfUnaryExpression()
*/
@Override
public boolean supportAlignOfUnaryExpression() {
return true;
}
/*
* @see org.eclipse.cdt.core.dom.parser.c.AbstractCParserExtensionConfiguration#supportKnRC()
*/
@Override
public boolean supportKnRC() {
return true;
}
/*
* @see org.eclipse.cdt.core.dom.parser.c.AbstractCParserExtensionConfiguration#supportAttributeSpecifiers()
*/
@Override
public boolean supportAttributeSpecifiers() {
return true;
}
/*
* @see org.eclipse.cdt.core.dom.parser.c.AbstractCParserExtensionConfiguration#supportDeclspecSpecifiers()
*/
@Override
public boolean supportDeclspecSpecifiers() {
return true;
}
/*
* @see org.eclipse.cdt.core.dom.parser.c.AbstractCParserExtensionConfiguration#getBuiltinSymbolProvider()
*/
@Override
public IBuiltinBindingsProvider getBuiltinBindingsProvider() {
return new GCCBuiltinSymbolProvider(ParserLanguage.C, true);