summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorNathan Ridge2013-02-21 05:03:49 (EST)
committer Sergey Prigogin2013-02-21 16:51:21 (EST)
commitf0a597bc2bf3d70f51eb6995e6582de099917ea0 (patch)
treeca0ad008bf8f9dce8f5767df03df63cdebb664cf
parent895e0aa394c19d6f10d2743b9a0b267a2b55e1da (diff)
downloadorg.eclipse.cdt-f0a597bc2bf3d70f51eb6995e6582de099917ea0.zip
org.eclipse.cdt-f0a597bc2bf3d70f51eb6995e6582de099917ea0.tar.gz
org.eclipse.cdt-f0a597bc2bf3d70f51eb6995e6582de099917ea0.tar.bz2
Bug 401400 - Another error involving variadic non-type templaterefs/changes/59/10559/3
parameters Change-Id: Ic5c64de6d32a203d13274053da61923d9d8e2ad3 Reviewed-on: https://git.eclipse.org/r/10559 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.java22
-rw-r--r--core/org.eclipse.cdt.core/parser/org/eclipse/cdt/core/dom/ast/cpp/ICPPTemplateParameterMap.java9
-rw-r--r--core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/CPPTemplateParameterMap.java1
-rw-r--r--core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/semantics/EvalBinding.java9
4 files changed, 40 insertions, 1 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 57a89c6..10fb36e 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
@@ -7312,4 +7312,26 @@ public class AST2TemplateTests extends AST2TestBase {
public void testVariadicNonTypeTemplateParameter_401142() throws Exception {
parseAndCheckBindings();
}
+
+ // template <bool... Args>
+ // struct ice_or;
+ // template <>
+ // struct ice_or<> {
+ // static const bool value = false;
+ // };
+ // template <bool First, bool... Rest>
+ // struct ice_or<First, Rest...> {
+ // static const bool value = ice_or<Rest...>::value;
+ // };
+ // template <bool> struct S {};
+ // template <>
+ // struct S<false> {
+ // typedef int type;
+ // };
+ // int main() {
+ // S<ice_or<false, false>::value>::type t;
+ // }
+ public void testVariadicNonTypeTemplateParameter_401400() throws Exception {
+ parseAndCheckBindings();
+ }
}
diff --git a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/core/dom/ast/cpp/ICPPTemplateParameterMap.java b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/core/dom/ast/cpp/ICPPTemplateParameterMap.java
index 2a4b0a1..45db3a3 100644
--- a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/core/dom/ast/cpp/ICPPTemplateParameterMap.java
+++ b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/core/dom/ast/cpp/ICPPTemplateParameterMap.java
@@ -45,6 +45,15 @@ public interface ICPPTemplateParameterMap {
public ICPPTemplateArgument[] getPackExpansion(ICPPTemplateParameter param);
/**
+ * If 'param' is not a parameter pack, returns the value for 'param' in the map.
+ * If 'param' is a parmameter pack, returns the value at position 'packOffset'
+ * in the pack of values for 'param' in the map.
+ * Returns <code>null</code> is 'param' is not mapped.
+ * @since 5.5
+ */
+ public ICPPTemplateArgument getArgument(ICPPTemplateParameter param, int packOffset);
+
+ /**
* Returns the array of template parameter positions, for which a mapping exists.
*/
Integer[] getAllParameterPositions();
diff --git a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/CPPTemplateParameterMap.java b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/CPPTemplateParameterMap.java
index c1c7c5d..2cc251a 100644
--- a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/CPPTemplateParameterMap.java
+++ b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/CPPTemplateParameterMap.java
@@ -114,6 +114,7 @@ public class CPPTemplateParameterMap implements ICPPTemplateParameterMap {
return null;
}
+ @Override
public ICPPTemplateArgument getArgument(ICPPTemplateParameter tpar, int packOffset) {
return getArgument(tpar.getParameterID(), packOffset);
}
diff --git a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/semantics/EvalBinding.java b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/semantics/EvalBinding.java
index 17a09e8..a59760b 100644
--- a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/semantics/EvalBinding.java
+++ b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/semantics/EvalBinding.java
@@ -27,6 +27,7 @@ import org.eclipse.cdt.core.dom.ast.IVariable;
import org.eclipse.cdt.core.dom.ast.cpp.ICPPClassSpecialization;
import org.eclipse.cdt.core.dom.ast.cpp.ICPPFunction;
import org.eclipse.cdt.core.dom.ast.cpp.ICPPParameter;
+import org.eclipse.cdt.core.dom.ast.cpp.ICPPParameterPackType;
import org.eclipse.cdt.core.dom.ast.cpp.ICPPSpecialization;
import org.eclipse.cdt.core.dom.ast.cpp.ICPPTemplateArgument;
import org.eclipse.cdt.core.dom.ast.cpp.ICPPTemplateDefinition;
@@ -246,6 +247,12 @@ public class EvalBinding extends CPPDependentEvaluation {
}
if (binding instanceof ICPPTemplateNonTypeParameter) {
IType type= ((ICPPTemplateNonTypeParameter) binding).getType();
+ // If the binding is a non-type parameter pack, it must have been
+ // referenced from inside the expansion pattern of a pack expansion.
+ // In such a context, the type of the binding is the type of each
+ // parameter in the parameter pack, not the type of the pack itself.
+ if (type instanceof ICPPParameterPackType)
+ type = ((ICPPParameterPackType) type).getType();
return prvalueType(type);
}
if (binding instanceof IVariable) {
@@ -329,7 +336,7 @@ public class EvalBinding extends CPPDependentEvaluation {
ICPPClassSpecialization within, int maxdepth, IASTNode point) {
IBinding origBinding = getBinding();
if (origBinding instanceof ICPPTemplateNonTypeParameter) {
- ICPPTemplateArgument argument = tpMap.getArgument((ICPPTemplateNonTypeParameter) origBinding);
+ ICPPTemplateArgument argument = tpMap.getArgument((ICPPTemplateNonTypeParameter) origBinding, packOffset);
if (argument != null && argument.isNonTypeValue()) {
return argument.getNonTypeEvaluation();
}