summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorNathan Ridge2013-05-26 14:44:07 (EDT)
committer Sergey Prigogin2013-05-26 14:45:14 (EDT)
commit255cd71f24199f74c3c0c060c5720070ff010bcb (patch)
treee66f332376759afde78d8df263d9f9f0ade70125
parentdc086d6a532cbc008c2a2be240afe4a34af15b83 (diff)
downloadorg.eclipse.cdt-255cd71f24199f74c3c0c060c5720070ff010bcb.zip
org.eclipse.cdt-255cd71f24199f74c3c0c060c5720070ff010bcb.tar.gz
org.eclipse.cdt-255cd71f24199f74c3c0c060c5720070ff010bcb.tar.bz2
Bug 409056 - Invalid ambiguity with templated conversion operatorrefs/changes/51/13151/3
Change-Id: I9f56c875899ee2543aab2090387dbbdfd0e489b4 Reviewed-on: https://git.eclipse.org/r/13151 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.java33
-rw-r--r--core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/semantics/TemplateArgumentDeduction.java4
2 files changed, 35 insertions, 2 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 04a8760..163aeeb 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
@@ -125,6 +125,14 @@ public class AST2TemplateTests extends AST2TestBase {
private IASTTranslationUnit parseAndCheckBindings(final String code) throws Exception {
return parseAndCheckBindings(code, CPP);
}
+
+ protected IASTTranslationUnit parseAndCheckImplicitNameBindings() throws Exception {
+ IASTTranslationUnit tu = parse(getAboveComment(), CPP, false, true, false);
+ NameCollector col = new NameCollector(true /* visit implicit names */);
+ tu.accept(col);
+ assertNoProblemBindings(col);
+ return tu;
+ }
protected BindingAssertionHelper getAssertionHelper() throws ParserException, IOException {
String code= getAboveComment();
@@ -7130,6 +7138,31 @@ public class AST2TemplateTests extends AST2TestBase {
assertNotNull(val);
assertEquals(0 /* false */, val.longValue());
}
+
+ // struct S {
+ // S(int);
+ // };
+ //
+ // template <typename>
+ // struct meta {};
+ //
+ // template <>
+ // struct meta<S> {
+ // typedef void type;
+ // };
+ //
+ // struct B {
+ // template <typename T, typename = typename meta<T>::type>
+ // operator T() const;
+ // };
+ //
+ // struct A {
+ // S waldo;
+ // A() : waldo(B{}) {}
+ // };
+ public void testSFINAEInTemplatedConversionOperator_409056() throws Exception {
+ parseAndCheckImplicitNameBindings();
+ }
// template <typename>
// struct M {
diff --git a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/semantics/TemplateArgumentDeduction.java b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/semantics/TemplateArgumentDeduction.java
index 2044afb..a698a90 100644
--- a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/semantics/TemplateArgumentDeduction.java
+++ b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/semantics/TemplateArgumentDeduction.java
@@ -370,8 +370,8 @@ public class TemplateArgumentDeduction {
final ICPPTemplateParameter tpar = tmplParams[i];
ICPPTemplateArgument deducedArg= map.getArgument(tpar);
if (deducedArg == null) {
- deducedArg= tpar.getDefaultValue();
- if (deducedArg == null)
+ deducedArg= CPPTemplates.instantiateArgument(tpar.getDefaultValue(), map, -1, null, point);
+ if (!CPPTemplates.isValidArgument(deducedArg))
return null;
}
result[i]= deducedArg;