summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorNathan Ridge2013-01-29 17:54:20 (EST)
committerSergey Prigogin2013-01-29 19:48:59 (EST)
commitf2037f2ebb1c1843d99567e922671d855c3dc1f6 (patch)
tree0249df3a3fdcce7d17af2250a3015a760aa0bde5
parent86dcb5b8d178717d46499d662ab383845df0b0b0 (diff)
downloadorg.eclipse.cdt-f2037f2ebb1c1843d99567e922671d855c3dc1f6.zip
org.eclipse.cdt-f2037f2ebb1c1843d99567e922671d855c3dc1f6.tar.gz
org.eclipse.cdt-f2037f2ebb1c1843d99567e922671d855c3dc1f6.tar.bz2
Bug 382074 - [C++11] Error involving variadic non-type template
parameters Change-Id: I6f4e3672b4aca8e8ca878bccdec9c19a1838c74d Reviewed-on: https://git.eclipse.org/r/9581 Reviewed-by: Sergey Prigogin <eclipse.sprigogin@gmail.com> IP-Clean: Sergey Prigogin <eclipse.sprigogin@gmail.com> Tested-by: Sergey Prigogin <eclipse.sprigogin@gmail.com>
-rw-r--r--core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/core/parser/tests/ast2/AST2TemplateTests.java9
-rw-r--r--core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/CPPASTAmbiguousTemplateArgument.java21
-rw-r--r--core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/CPPASTPackExpansionExpression.java8
-rw-r--r--core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/semantics/CPPTemplates.java3
4 files changed, 31 insertions, 10 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 c06be85..da6898a 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
@@ -7029,4 +7029,13 @@ public class AST2TemplateTests extends AST2TestBase {
assertNotNull(num);
assertEquals(1, num.longValue());
}
+
+ // template <int...> struct A {};
+ // template <int... I> void foo(A<I...>);
+ // int main() {
+ // foo(A<0>());
+ // }
+ public void testVariadicNonTypeTemplateParameter_382074() throws Exception {
+ parseAndCheckBindings();
+ }
}
diff --git a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/CPPASTAmbiguousTemplateArgument.java b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/CPPASTAmbiguousTemplateArgument.java
index 626020f..25c25f5 100644
--- a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/CPPASTAmbiguousTemplateArgument.java
+++ b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/CPPASTAmbiguousTemplateArgument.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2008, 2011 Symbian Software Systems and others.
+ * Copyright (c) 2008, 2013 Symbian Software Systems 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
@@ -9,6 +9,7 @@
* Andrew Ferguson (Symbian) - Initial Implementation
* Markus Schorn (Wind River Systems)
* IBM Corporation
+ * Nathan Ridge
*******************************************************************************/
package org.eclipse.cdt.internal.core.dom.parser.cpp;
@@ -68,12 +69,18 @@ public class CPPASTAmbiguousTemplateArgument extends ASTAmbiguousNode implements
name.setBinding(null);
namedTypeSpec.setName(name);
}
- } else if (node instanceof IASTIdExpression) {
- IASTIdExpression id= (IASTIdExpression) node;
- final IASTName name = id.getName();
- name.setBinding(null);
- id.setName(name);
- }
+ } else {
+ // Unwrap variadic pack expansion if necessary.
+ if (node instanceof ICPPASTPackExpansionExpression)
+ node= ((ICPPASTPackExpansionExpression) node).getPattern();
+
+ if (node instanceof IASTIdExpression) {
+ IASTIdExpression id= (IASTIdExpression) node;
+ final IASTName name = id.getName();
+ name.setBinding(null);
+ id.setName(name);
+ }
+ }
}
@Override
diff --git a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/CPPASTPackExpansionExpression.java b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/CPPASTPackExpansionExpression.java
index 9b115f0..5669529 100644
--- a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/CPPASTPackExpansionExpression.java
+++ b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/CPPASTPackExpansionExpression.java
@@ -1,12 +1,13 @@
/*******************************************************************************
- * Copyright (c) 2009, 2011 Wind River Systems, Inc. and others.
+ * Copyright (c) 2009, 2013 Wind River Systems, Inc. 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
* http://www.eclipse.org/legal/epl-v10.html
*
* Contributors:
- * Markus Schorn - initial API and implementation
+ * Markus Schorn - initial API and implementation
+ * Natan Ridge
*******************************************************************************/
package org.eclipse.cdt.internal.core.dom.parser.cpp;
@@ -16,6 +17,7 @@ import org.eclipse.cdt.core.dom.ast.ASTVisitor;
import org.eclipse.cdt.core.dom.ast.IASTExpression;
import org.eclipse.cdt.core.dom.ast.IASTNode;
import org.eclipse.cdt.core.dom.ast.IType;
+import org.eclipse.cdt.core.dom.ast.cpp.ICPPASTExpression;
import org.eclipse.cdt.core.dom.ast.cpp.ICPPASTPackExpansionExpression;
import org.eclipse.cdt.internal.core.dom.parser.ASTNode;
import org.eclipse.cdt.internal.core.dom.parser.IASTAmbiguityParent;
@@ -74,7 +76,7 @@ public class CPPASTPackExpansionExpression extends ASTNode implements ICPPASTPac
} else {
type= new CPPParameterPackType(type);
}
- fEvaluation= new EvalFixed(type, PRVALUE, Value.UNKNOWN);
+ fEvaluation= new EvalFixed(type, PRVALUE, Value.create(((ICPPASTExpression) fPattern).getEvaluation()));
}
return fEvaluation;
}
diff --git a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/semantics/CPPTemplates.java b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/semantics/CPPTemplates.java
index edf0e79..d192be3 100644
--- a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/semantics/CPPTemplates.java
+++ b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/semantics/CPPTemplates.java
@@ -2224,6 +2224,9 @@ public class CPPTemplates {
pType= instantiateType(pType, map, -1, null, point);
}
+ if (argType instanceof ICPPParameterPackType) {
+ argType = ((ICPPParameterPackType) argType).getType();
+ }
if (argType instanceof ICPPUnknownType) {
return new CPPTemplateNonTypeArgument(arg.getNonTypeValue(), pType);
}