// _MYMACRO_ myType foo(); // _MYMACRO_ myType foo() {} // extern void foo2() _MYMACRO_; public void testUndefinedMacrosInFunctionDeclarations_Bug234085() throws Exception { final String comment = getAboveComment(); for (ParserLanguage lang : ParserLanguage.values()) { IASTTranslationUnit tu = parse(comment, lang, false, false); IASTProblemDeclaration pd = getDeclaration(tu, 0); assertEquals("_MYMACRO_", pd.getRawSignature()); IASTSimpleDeclaration sdecl = getDeclaration(tu, 1); assertEquals("myType foo();", sdecl.getRawSignature()); pd = getDeclaration(tu, 2); assertEquals("_MYMACRO_", pd.getRawSignature()); IASTFunctionDefinition fdef = getDeclaration(tu, 3); assertEquals("myType foo() {}", fdef.getRawSignature()); sdecl = getDeclaration(tu, 4); assertEquals("extern void foo2()", sdecl.getRawSignature()); pd = getDeclaration(tu, 5); // the missing semicolon if (lang == ParserLanguage.CPP) { pd = getDeclaration(tu, 6); assertEquals("_MYMACRO_;", pd.getRawSignature()); } else { sdecl = getDeclaration(tu, 6); assertEquals("_MYMACRO_;", sdecl.getRawSignature()); } } }
// typedef int tint; // struct X { // int a; // } // tint b; public void testCompositeTypeWithoutSemi() throws Exception { final String comment = getAboveComment(); for (ParserLanguage lang : ParserLanguage.values()) { IASTTranslationUnit tu = parse(comment, lang, false, false); IASTCompositeTypeSpecifier def = getCompositeType(tu, 1); IASTProblemDeclaration pdecl = getDeclaration(tu, 2); IASTSimpleDeclaration sdecl = getDeclaration(tu, 3); } }
// void test() { // int a= offsetof(struct mystruct, singlechar); // } public void testRangeOfProblemNode_Bug238151() throws Exception { final String comment = getAboveComment(); for (ParserLanguage lang : ParserLanguage.values()) { IASTTranslationUnit tu = parse(comment, lang, false, false); IASTFunctionDefinition fdef = getDeclaration(tu, 0); IASTProblemStatement pdecl = getStatement(fdef, 0); assertEquals("int a= offsetof(struct mystruct, singlechar);", pdecl.getRawSignature()); } }
// typedef int tint; // int a() // tint b; public void testPrototypeWithoutSemi() throws Exception { final String comment = getAboveComment(); for (ParserLanguage lang : ParserLanguage.values()) { IASTTranslationUnit tu = parse(comment, lang, false, false); IASTSimpleDeclaration sdecl = getDeclaration(tu, 1); assertEquals("int a()", sdecl.getRawSignature()); IASTProblemDeclaration pdecl = getDeclaration(tu, 2); sdecl = getDeclaration(tu, 3); } }
// void func() { // int a; public void testIncompleteFunctionDefinition() throws Exception { final String comment = getAboveComment(); for (ParserLanguage lang : ParserLanguage.values()) { IASTTranslationUnit tu = parse(comment, lang, false, false); IASTFunctionDefinition fdef = getDeclaration(tu, 0); IASTProblemDeclaration pdecl = getDeclaration(tu, 1); IASTDeclarationStatement sdecl = getStatement(fdef, 0); } }
// typedef int tint; // struct X { // int a; // } c // tint b; public void testCompositeTypeWithDtorWithoutSemi() throws Exception { final String comment = getAboveComment(); for (ParserLanguage lang : ParserLanguage.values()) { IASTTranslationUnit tu = parse(comment, lang, false, false); IASTSimpleDeclaration sdecl = getDeclaration(tu, 1); assertInstance(sdecl.getDeclSpecifier(), IASTCompositeTypeSpecifier.class); assertEquals(1, sdecl.getDeclarators().length); IASTProblemDeclaration pdecl = getDeclaration(tu, 2); sdecl = getDeclaration(tu, 3); } }
// enum _T { I J, K }; // missing comma // int i; public void testEnumProblem() throws Exception { final String comment = getAboveComment(); for (ParserLanguage lang : ParserLanguage.values()) { IASTTranslationUnit tu = parse(comment, lang, false, false); IASTSimpleDeclaration e = getDeclaration(tu, 0); IASTProblemDeclaration p = getDeclaration(tu, 1); assertEquals("J, K };", p.getRawSignature()); IASTSimpleDeclaration s = getDeclaration(tu, 2); assertEquals("int i;", s.getRawSignature()); } }
// int f(){ // if( 12 A ) // return -1; // int v; // } public void testProblemInIfExpression_Bug100321() throws Exception { final String comment = getAboveComment(); for (ParserLanguage lang : ParserLanguage.values()) { IASTTranslationUnit tu = parse(comment, lang, false, false); IASTFunctionDefinition fdef = getDeclaration(tu, 0); IASTIfStatement ifstmt = getStatement(fdef, 0); assertInstance(ifstmt.getConditionExpression(), IASTProblemExpression.class); assertEquals("12 A", ifstmt.getConditionExpression().getRawSignature()); assertInstance(ifstmt.getThenClause(), IASTReturnStatement.class); } }
// void f() { // int a= 1 // f() // } public void testExpressionWithoutSemi_314593() throws Exception { final String comment = getAboveComment(); for (ParserLanguage lang : ParserLanguage.values()) { IASTTranslationUnit tu = parse(comment, lang, false, false); IASTFunctionDefinition fdef = getDeclaration(tu, 0); IASTStatement stmt = getStatement(fdef, 0); assertEquals("int a= 1", stmt.getRawSignature()); IASTProblemStatement pstmt = getStatement(fdef, 1); stmt = getStatement(fdef, 2); assertEquals("f()", stmt.getRawSignature()); pstmt = getStatement(fdef, 3); } }