Skip to main content
summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorAlain Magloire2005-08-30 15:49:11 -0400
committerAlain Magloire2005-08-30 15:49:11 -0400
commit930b697e19373d2ff057e64ad69ad9db01ea786f (patch)
tree500017ed59c7868b1e5558055afc76a850467f87
parentca26718e840caa9b90f264a2c2a41a9c851e7c37 (diff)
downloadorg.eclipse.cdt-930b697e19373d2ff057e64ad69ad9db01ea786f.tar.gz
org.eclipse.cdt-930b697e19373d2ff057e64ad69ad9db01ea786f.tar.xz
org.eclipse.cdt-930b697e19373d2ff057e64ad69ad9db01ea786f.zip
2005-08-30 Alain Magloire
New test in PR 107150 (written by Devin Steffler) * parser/org/eclipse/cdt/core/parser/tests/ast2/AST2CPPTests.java * parser/org/eclipse/cdt/core/parser/tests/ast2/AST2Tests.java * parser/org/eclipse/cdt/core/parser/tests/scanner2/Scanner2Test.java
-rw-r--r--core/org.eclipse.cdt.core.tests/ChangeLog6
-rw-r--r--core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/core/parser/tests/ast2/AST2CPPTests.java27
-rw-r--r--core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/core/parser/tests/ast2/AST2Tests.java57
-rw-r--r--core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/core/parser/tests/scanner2/Scanner2Test.java42
4 files changed, 132 insertions, 0 deletions
diff --git a/core/org.eclipse.cdt.core.tests/ChangeLog b/core/org.eclipse.cdt.core.tests/ChangeLog
index ca3a435ecf..0ce25cd516 100644
--- a/core/org.eclipse.cdt.core.tests/ChangeLog
+++ b/core/org.eclipse.cdt.core.tests/ChangeLog
@@ -1,3 +1,9 @@
+2005-08-30 Alain Magloire
+ New test in PR 107150 (written by Devin Steffler)
+ * parser/org/eclipse/cdt/core/parser/tests/ast2/AST2CPPTests.java
+ * parser/org/eclipse/cdt/core/parser/tests/ast2/AST2Tests.java
+ * parser/org/eclipse/cdt/core/parser/tests/scanner2/Scanner2Test.java
+
2005-06-26 Alain Magloire
* model/org/eclipse/cdt/core/model/tests/StructuralTemplateTests.java
diff --git a/core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/core/parser/tests/ast2/AST2CPPTests.java b/core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/core/parser/tests/ast2/AST2CPPTests.java
index 588efc8aaa..ba91a62cce 100644
--- a/core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/core/parser/tests/ast2/AST2CPPTests.java
+++ b/core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/core/parser/tests/ast2/AST2CPPTests.java
@@ -36,6 +36,7 @@ import org.eclipse.cdt.core.dom.ast.IASTLabelStatement;
import org.eclipse.cdt.core.dom.ast.IASTLiteralExpression;
import org.eclipse.cdt.core.dom.ast.IASTName;
import org.eclipse.cdt.core.dom.ast.IASTNamedTypeSpecifier;
+import org.eclipse.cdt.core.dom.ast.IASTProblemDeclaration;
import org.eclipse.cdt.core.dom.ast.IASTReturnStatement;
import org.eclipse.cdt.core.dom.ast.IASTSimpleDeclSpecifier;
import org.eclipse.cdt.core.dom.ast.IASTSimpleDeclaration;
@@ -5099,4 +5100,30 @@ public class AST2CPPTests extends AST2BaseTest {
IASTCompoundStatement body = (IASTCompoundStatement) f.getBody();
assertEquals( body.getStatements().length, 3 );
}
+
+ public void testBug107150() throws Exception {
+ StringBuffer buffer = new StringBuffer();
+ buffer.append("#define FUNC_PROTOTYPE_PARAMS(list) list\r\n"); //$NON-NLS-1$
+ buffer.append("int func1 FUNC_PROTOTYPE_PARAMS((int arg1)){\r\n"); //$NON-NLS-1$
+ buffer.append("return 0;\r\n"); //$NON-NLS-1$
+ buffer.append("}\r\n"); //$NON-NLS-1$
+ buffer.append("int func2 FUNC_PROTOTYPE_PARAMS\r\n"); //$NON-NLS-1$
+ buffer.append("((int arg1)){\r\n"); //$NON-NLS-1$
+ buffer.append("return 0;\r\n"); //$NON-NLS-1$
+ buffer.append("}\r\n"); //$NON-NLS-1$
+ IASTTranslationUnit tu = parse(buffer.toString(), ParserLanguage.CPP);
+ assertFalse( tu.getDeclarations()[1] instanceof IASTProblemDeclaration );
+
+ buffer = new StringBuffer();
+ buffer.append("#define FUNC_PROTOTYPE_PARAMS(list) list\n"); //$NON-NLS-1$
+ buffer.append("int func1 FUNC_PROTOTYPE_PARAMS((int arg1)){\n"); //$NON-NLS-1$
+ buffer.append("return 0;\n"); //$NON-NLS-1$
+ buffer.append("}\n"); //$NON-NLS-1$
+ buffer.append("int func2 FUNC_PROTOTYPE_PARAMS\n"); //$NON-NLS-1$
+ buffer.append("((int arg1)){\n"); //$NON-NLS-1$
+ buffer.append("return 0;\n"); //$NON-NLS-1$
+ buffer.append("}\n"); //$NON-NLS-1$
+ tu = parse(buffer.toString(), ParserLanguage.CPP);
+ assertFalse( tu.getDeclarations()[1] instanceof IASTProblemDeclaration );
+ }
}
diff --git a/core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/core/parser/tests/ast2/AST2Tests.java b/core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/core/parser/tests/ast2/AST2Tests.java
index eab89b845e..270ac2c493 100644
--- a/core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/core/parser/tests/ast2/AST2Tests.java
+++ b/core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/core/parser/tests/ast2/AST2Tests.java
@@ -41,6 +41,7 @@ import org.eclipse.cdt.core.dom.ast.IASTNamedTypeSpecifier;
import org.eclipse.cdt.core.dom.ast.IASTNullStatement;
import org.eclipse.cdt.core.dom.ast.IASTParameterDeclaration;
import org.eclipse.cdt.core.dom.ast.IASTProblem;
+import org.eclipse.cdt.core.dom.ast.IASTProblemDeclaration;
import org.eclipse.cdt.core.dom.ast.IASTReturnStatement;
import org.eclipse.cdt.core.dom.ast.IASTSimpleDeclSpecifier;
import org.eclipse.cdt.core.dom.ast.IASTSimpleDeclaration;
@@ -3367,4 +3368,60 @@ public class AST2Tests extends AST2BaseTest {
IASTCompoundStatement body = (IASTCompoundStatement) f.getBody();
assertEquals( body.getStatements().length, 3 );
}
+
+ public void testBug107150() throws Exception {
+ StringBuffer buffer = new StringBuffer();
+ buffer.append("#define FUNC_PROTOTYPE_PARAMS(list) list\r\n"); //$NON-NLS-1$
+ buffer.append("int func1 FUNC_PROTOTYPE_PARAMS((int arg1)){\r\n"); //$NON-NLS-1$
+ buffer.append("return 0;\r\n"); //$NON-NLS-1$
+ buffer.append("}\r\n"); //$NON-NLS-1$
+ buffer.append("int func2 FUNC_PROTOTYPE_PARAMS\r\n"); //$NON-NLS-1$
+ buffer.append("((int arg1)){\r\n"); //$NON-NLS-1$
+ buffer.append("return 0;\r\n"); //$NON-NLS-1$
+ buffer.append("}\r\n"); //$NON-NLS-1$
+ parse(buffer.toString(), ParserLanguage.C);
+ IASTTranslationUnit tu = parse(buffer.toString(), ParserLanguage.CPP);
+ assertFalse( tu.getDeclarations()[1] instanceof IASTProblemDeclaration );
+
+ buffer = new StringBuffer();
+ buffer.append("#define FUNC_PROTOTYPE_PARAMS(list) list\n"); //$NON-NLS-1$
+ buffer.append("int func1 FUNC_PROTOTYPE_PARAMS((int arg1)){\n"); //$NON-NLS-1$
+ buffer.append("return 0;\n"); //$NON-NLS-1$
+ buffer.append("}\n"); //$NON-NLS-1$
+ buffer.append("int func2 FUNC_PROTOTYPE_PARAMS\n"); //$NON-NLS-1$
+ buffer.append("((int arg1)){\n"); //$NON-NLS-1$
+ buffer.append("return 0;\n"); //$NON-NLS-1$
+ buffer.append("}\n"); //$NON-NLS-1$
+ parse(buffer.toString(), ParserLanguage.C);
+ tu = parse(buffer.toString(), ParserLanguage.CPP);
+ assertFalse( tu.getDeclarations()[1] instanceof IASTProblemDeclaration );
+ }
+
+ public void testBug107150b() throws Exception {
+ StringBuffer buffer = new StringBuffer();
+ buffer.append("#define FUNC_PROTOTYPE_PARAMS(list) list\r\n"); //$NON-NLS-1$
+ buffer.append("int func1 FUNC_PROTOTYPE_PARAMS((int arg1)){\r\n"); //$NON-NLS-1$
+ buffer.append("return 0;\r\n"); //$NON-NLS-1$
+ buffer.append("}\r\n"); //$NON-NLS-1$
+ buffer.append("int func2 FUNC_PROTOTYPE_PARAMS\r\n \r\n \t \r\n \r\n "); //$NON-NLS-1$
+ buffer.append("((int arg1)){\r\n"); //$NON-NLS-1$
+ buffer.append("return 0;\r\n"); //$NON-NLS-1$
+ buffer.append("}\r\n"); //$NON-NLS-1$
+ parse(buffer.toString(), ParserLanguage.C);
+ IASTTranslationUnit tu = parse(buffer.toString(), ParserLanguage.CPP);
+ assertFalse( tu.getDeclarations()[1] instanceof IASTProblemDeclaration );
+
+ buffer = new StringBuffer();
+ buffer.append("#define FUNC_PROTOTYPE_PARAMS(list) list\n"); //$NON-NLS-1$
+ buffer.append("int func1 FUNC_PROTOTYPE_PARAMS((int arg1)){\n"); //$NON-NLS-1$
+ buffer.append("return 0;\n"); //$NON-NLS-1$
+ buffer.append("}\n"); //$NON-NLS-1$
+ buffer.append("int func2 FUNC_PROTOTYPE_PARAMS\n"); //$NON-NLS-1$
+ buffer.append("((int arg1)){\n"); //$NON-NLS-1$
+ buffer.append("return 0;\n"); //$NON-NLS-1$
+ buffer.append("}\n"); //$NON-NLS-1$
+ parse(buffer.toString(), ParserLanguage.C);
+ tu = parse(buffer.toString(), ParserLanguage.CPP);
+ assertFalse( tu.getDeclarations()[1] instanceof IASTProblemDeclaration );
+ }
} \ No newline at end of file
diff --git a/core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/core/parser/tests/scanner2/Scanner2Test.java b/core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/core/parser/tests/scanner2/Scanner2Test.java
index 7f01a23b49..09e7e7825c 100644
--- a/core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/core/parser/tests/scanner2/Scanner2Test.java
+++ b/core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/core/parser/tests/scanner2/Scanner2Test.java
@@ -2364,4 +2364,46 @@ public class Scanner2Test extends BaseScanner2Test
fullyTokenize();
}
+ public void testBug107150() throws Exception {
+ Writer writer = new StringWriter();
+ writer.write("#define FUNC_PROTOTYPE_PARAMS(list) list\r\n"); //$NON-NLS-1$
+ writer.write("int func2 FUNC_PROTOTYPE_PARAMS\r\n"); //$NON-NLS-1$
+ writer.write("((int arg1)){\r\n"); //$NON-NLS-1$
+ writer.write(" return 0;\r\n"); //$NON-NLS-1$
+ writer.write("}\r\n"); //$NON-NLS-1$
+ initializeScanner( writer.toString() );
+ validateToken( IToken.t_int );
+ validateIdentifier( "func2" ); //$NON-NLS-1$
+ validateToken( IToken.tLPAREN );
+ validateToken( IToken.t_int );
+ validateIdentifier( "arg1" ); //$NON-NLS-1$
+ validateToken( IToken.tRPAREN );
+ validateToken( IToken.tLBRACE );
+ validateToken( IToken.t_return );
+ validateInteger( "0" );
+ validateToken( IToken.tSEMI );
+ validateToken( IToken.tRBRACE );
+ validateEOF();
+
+ writer = new StringWriter();
+ writer.write("#define FUNC_PROTOTYPE_PARAMS(list) list\n"); //$NON-NLS-1$
+ writer.write("int func2 FUNC_PROTOTYPE_PARAMS\n"); //$NON-NLS-1$
+ writer.write("((int arg1)){\n"); //$NON-NLS-1$
+ writer.write(" return 0;\n"); //$NON-NLS-1$
+ writer.write("}\n"); //$NON-NLS-1$
+ initializeScanner( writer.toString() );
+ validateToken( IToken.t_int );
+ validateIdentifier( "func2" ); //$NON-NLS-1$
+ validateToken( IToken.tLPAREN );
+ validateToken( IToken.t_int );
+ validateIdentifier( "arg1" ); //$NON-NLS-1$
+ validateToken( IToken.tRPAREN );
+ validateToken( IToken.tLBRACE );
+ validateToken( IToken.t_return );
+ validateInteger( "0" );
+ validateToken( IToken.tSEMI );
+ validateToken( IToken.tRBRACE );
+ validateEOF();
+ }
+
}

Back to the top