1
0
Fork 0
mirror of https://github.com/eclipse-cdt/cdt synced 2025-04-23 22:52:11 +02:00

Bug 516338 - Detect substitution failure during instantiation of dependent alias template arguments

Change-Id: Ia97e0632e17b4047a0fe35c05be72dab75e43d5c
This commit is contained in:
Nathan Ridge 2017-05-10 03:52:30 -04:00
parent e374b4b08e
commit 1dceabb0eb
2 changed files with 38 additions and 1 deletions

View file

@ -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;

View file

@ -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();