Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMarkus Schorn2011-04-11 12:40:25 +0000
committerMarkus Schorn2011-04-11 12:40:25 +0000
commit9a2e97825bdd952585a32b795f5fdca21614123a (patch)
tree3ca582f3e8e323871d6b3ce8d2d36d8d5496ad11 /core/org.eclipse.cdt.core.tests
parentee055684b2e04288c0c41233ea3fd01c63e87ada (diff)
downloadorg.eclipse.cdt-9a2e97825bdd952585a32b795f5fdca21614123a.tar.gz
org.eclipse.cdt-9a2e97825bdd952585a32b795f5fdca21614123a.tar.xz
org.eclipse.cdt-9a2e97825bdd952585a32b795f5fdca21614123a.zip
Bug 341747: Ambiguity between template-id and binary expression.
Diffstat (limited to 'core/org.eclipse.cdt.core.tests')
-rw-r--r--core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/core/parser/tests/ast2/AST2TemplateTests.java71
-rw-r--r--core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/core/parser/tests/ast2/AST2Tests.java8
2 files changed, 75 insertions, 4 deletions
diff --git a/core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/core/parser/tests/ast2/AST2TemplateTests.java b/core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/core/parser/tests/ast2/AST2TemplateTests.java
index 549fb0d78cf..6c28e18b783 100644
--- a/core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/core/parser/tests/ast2/AST2TemplateTests.java
+++ b/core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/core/parser/tests/ast2/AST2TemplateTests.java
@@ -24,6 +24,7 @@ import org.eclipse.cdt.core.dom.ast.ASTTypeUtil;
import org.eclipse.cdt.core.dom.ast.IASTBinaryExpression;
import org.eclipse.cdt.core.dom.ast.IASTCompoundStatement;
import org.eclipse.cdt.core.dom.ast.IASTExpressionStatement;
+import org.eclipse.cdt.core.dom.ast.IASTFunctionCallExpression;
import org.eclipse.cdt.core.dom.ast.IASTFunctionDefinition;
import org.eclipse.cdt.core.dom.ast.IASTIdExpression;
import org.eclipse.cdt.core.dom.ast.IASTImplicitName;
@@ -5314,4 +5315,74 @@ public class AST2TemplateTests extends AST2BaseTest {
public void testPartialSpecAfterExplicitInst_339475() throws Exception {
parseAndCheckBindings();
}
+
+
+ // template<bool> struct S {
+ // static int m();
+ // };
+ // template<int> void g(int);
+ // int f();
+ // int s;
+ //
+ // void test() {
+ // f < 0 > (1); // Function pointer
+ // g<0>(1); // Function call
+ // S<1 && 2>::m(); // m is member of S
+ // s<1 && 2>::f(); // f is global
+ // }
+ public void testTemplateIDAmbiguity_341747a() throws Exception {
+ IASTTranslationUnit tu= parseAndCheckBindings();
+ IASTFunctionDefinition fdef= getDeclaration(tu, 4);
+
+ IASTExpressionStatement stmt;
+ stmt= getStatement(fdef, 0);
+ assertTrue(stmt.getExpression() instanceof IASTBinaryExpression);
+
+ stmt= getStatement(fdef, 1);
+ assertTrue(stmt.getExpression() instanceof IASTFunctionCallExpression);
+
+ stmt= getStatement(fdef, 2);
+ assertTrue(stmt.getExpression() instanceof IASTFunctionCallExpression);
+
+ stmt= getStatement(fdef, 0);
+ assertTrue(stmt.getExpression() instanceof IASTBinaryExpression);
+ }
+
+ // const int a=0, b=1;
+ // template<int> struct A{};
+ //
+ // template<bool B= a<b> struct S {};
+ // struct X : S<a<b> {};
+ //
+ // template<typename B= A<b>> struct T {};
+ // struct Y : T<A<b>> {};
+ public void testTemplateIDAmbiguity_341747b() throws Exception {
+ parseAndCheckBindings();
+ }
+
+ // int a=0, b=1;
+ // bool bl= false;
+ // template<bool B> struct S {
+ // int a;
+ // };
+ // void test() {
+ // S< a<b >::a;
+ // a < S<bl>::a;
+ // }
+ public void testTemplateIDAmbiguity_341747c() throws Exception {
+ parseAndCheckBindings();
+ }
+
+ // struct S {
+ // int B;
+ // };
+ // template<typename T> struct B {};
+ // int c;
+ // void test() {
+ // S* a=0;
+ // a->B<c && c>::c;
+ // }
+ public void testTemplateIDAmbiguity_341747d() throws Exception {
+ parseAndCheckBindings();
+ }
}
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 71586ca951d..f82112495b3 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
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2004, 2010 IBM Corporation and others.
+ * Copyright (c) 2004, 2011 IBM Corporation and others.
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at
@@ -7102,12 +7102,12 @@ public class AST2Tests extends AST2BaseTest {
// void f() {
// int a=
public void testLargeExpression_294029() throws Exception {
- // when running the test in a suite, it cannot handle more than 200 parenthesis.
- // run as a single test it does > 600.
+ // when running the test in a suite, it cannot handle more than 160 parenthesis.
+ // run as a single test it does > 500.
sValidateCopy= false;
StringBuilder buf= new StringBuilder();
buf.append(getAboveComment());
- final int depth= 200;
+ final int depth= 160;
for (int i = 0; i < depth; i++) {
buf.append('(');
}

Back to the top