summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorNathan Ridge2013-03-03 19:59:26 (EST)
committerSergey Prigogin2013-03-03 21:35:16 (EST)
commitf9f94676a2a87cdf5759d3a3d89eccbb7e84119b (patch)
tree293cc5bec900882d9651c34e98fa1969ef61c95c
parent5eb0fb045160f1b8e5d700c089ffb93860356f7b (diff)
downloadorg.eclipse.cdt-f9f94676a2a87cdf5759d3a3d89eccbb7e84119b.zip
org.eclipse.cdt-f9f94676a2a87cdf5759d3a3d89eccbb7e84119b.tar.gz
org.eclipse.cdt-f9f94676a2a87cdf5759d3a3d89eccbb7e84119b.tar.bz2
Bug 402257 - Incorrect overload resolution with SFINAE and nested typesrefs/changes/11/10811/4
Change-Id: Id97160bcccaa0daaa7eaeab965cc74fe816adef5 Reviewed-on: https://git.eclipse.org/r/10811 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.java27
-rw-r--r--core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/semantics/CPPTemplates.java6
2 files changed, 30 insertions, 3 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 0028d96..c6e89ee 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
@@ -6945,7 +6945,32 @@ public class AST2TemplateTests extends AST2TestBase {
public void testSFINAEInDefaultArgument() throws Exception {
parseAndCheckBindings();
}
-
+
+ // typedef char (&no_tag)[1];
+ // typedef char (&yes_tag)[2];
+ //
+ // template <typename T>
+ // struct type_wrapper {};
+ //
+ // template <typename T>
+ // struct has_type {
+ // template <typename U>
+ // static yes_tag test(type_wrapper<U> const volatile*, type_wrapper<typename U::type>* = 0);
+ //
+ // static no_tag test(...);
+ //
+ // static const bool value = sizeof(test(static_cast<type_wrapper<T>*>(0))) == sizeof(yes_tag);
+ // };
+ //
+ // const bool B = has_type<int>::value;
+ public void testSFINAEInNestedTypeInTemplateArgument_402257() throws Exception {
+ BindingAssertionHelper helper = new BindingAssertionHelper(getAboveComment(), true);
+ ICPPVariable B = helper.assertNonProblem("B", ICPPVariable.class);
+ Long val = B.getInitialValue().numericalValue();
+ assertNotNull(val);
+ assertEquals(0 /* false */, val.longValue());
+ }
+
// template <typename>
// struct M {
// template <typename... Args>
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 4650cc7..29ab1ac 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
@@ -2618,16 +2618,18 @@ public class CPPTemplates {
private static IBinding resolveDeferredClassInstance(ICPPDeferredClassInstance dci,
ICPPTemplateParameterMap tpMap, int packOffset, ICPPClassSpecialization within, IASTNode point) {
+ ICPPClassTemplate classTemplate = dci.getClassTemplate();
ICPPTemplateArgument[] arguments = dci.getTemplateArguments();
ICPPTemplateArgument[] newArgs;
try {
- newArgs = instantiateArguments(arguments, tpMap, packOffset, within, point, false);
+ newArgs = instantiateArguments(arguments, tpMap, packOffset, within, point, true);
} catch (DOMException e) {
return e.getProblem();
}
+ if (newArgs == null)
+ return createProblem(classTemplate, IProblemBinding.SEMANTIC_INVALID_TEMPLATE_ARGUMENTS, point);
boolean changed= arguments != newArgs;
- ICPPClassTemplate classTemplate = dci.getClassTemplate();
IType classTemplateSpecialization= instantiateType(classTemplate, tpMap, packOffset, within, point);
if (classTemplateSpecialization != classTemplate && classTemplateSpecialization instanceof ICPPClassTemplate) {
classTemplate= (ICPPClassTemplate) classTemplateSpecialization;