Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorNathan Ridge2017-05-10 07:52:30 +0000
committerNathan Ridge2017-06-20 06:34:07 +0000
commit1dceabb0ebbf4ba8a6948c796fcd58fc0aa888f6 (patch)
treeebd8f464ff7760bfe42486e402c0efc258eb6635
parente374b4b08e7323b8d33ef1f2826b761f74c9b54f (diff)
downloadorg.eclipse.cdt-1dceabb0ebbf4ba8a6948c796fcd58fc0aa888f6.tar.gz
org.eclipse.cdt-1dceabb0ebbf4ba8a6948c796fcd58fc0aa888f6.tar.xz
org.eclipse.cdt-1dceabb0ebbf4ba8a6948c796fcd58fc0aa888f6.zip
Bug 516338 - Detect substitution failure during instantiation of dependent alias template arguments
-rw-r--r--core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/core/parser/tests/ast2/AST2TemplateTests.java16
-rw-r--r--core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/semantics/CPPTemplates.java23
2 files changed, 38 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 47f4a66ef6..8ea14a808a 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
@@ -10131,6 +10131,22 @@ public class AST2TemplateTests extends AST2CPPTestBase {
parseAndCheckBindings();
}
+ // template <typename>
+ // using void_t = void;
+ //
+ // template <typename T, typename = void>
+ // struct Waldo {
+ // using type = T;
+ // };
+ //
+ // template <typename T>
+ // struct Waldo<T, void_t<typename T::type>> {};
+ //
+ // Waldo<int>::type foo();
+ public void testSFINAEInAliasTemplateArgs_516338() throws Exception {
+ parseAndCheckBindings();
+ }
+
// template <typename, typename>
// struct is_same {
// static constexpr bool value = false;
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 c21ff48da6..ee3cce19e7 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
@@ -1536,7 +1536,7 @@ public class CPPTemplates {
return type;
}
}
-
+
if (type instanceof TypeOfUnknownMember) {
IBinding binding = resolveUnknown(((TypeOfUnknownMember) type).getUnknownMember(), context);
if (binding instanceof IType) {
@@ -1592,6 +1592,27 @@ public class CPPTemplates {
}
}
+ // An alias template instance may have dependent arguments that don't contribute
+ // to the target type but can SFINAE out during instantiation, so it's not
+ // sufficient to handle it in the ITypeContainer case.
+ if (type instanceof ICPPAliasTemplateInstance) {
+ ICPPAliasTemplateInstance instance = (ICPPAliasTemplateInstance) type;
+ ICPPAliasTemplate template = instance.getTemplateDefinition();
+ ICPPTemplateArgument[] args = instance.getTemplateArguments();
+ ICPPTemplateArgument[] newArgs = instantiateArguments(args, context, true);
+ if (newArgs == null) {
+ return (IType) createProblem(template,
+ IProblemBinding.SEMANTIC_INVALID_TEMPLATE_ARGUMENTS, context.getPoint());
+ }
+ if (args != newArgs) {
+ IType target = instantiateType(instance.getType(), context);
+ CPPTemplateParameterMap map =
+ instantiateArgumentMap(instance.getTemplateParameterMap(), context);
+ return new CPPAliasTemplateInstance(template, target, instance.getOwner(), map, newArgs);
+ }
+ return type;
+ }
+
if (type instanceof ITypeContainer) {
final ITypeContainer typeContainer = (ITypeContainer) type;
IType nestedType = typeContainer.getType();

Back to the top