mirror of
https://github.com/eclipse-cdt/cdt
synced 2025-06-07 09:46:02 +02:00
Bug 516338 - Detect substitution failure during instantiation of dependent alias template arguments
Change-Id: Ia97e0632e17b4047a0fe35c05be72dab75e43d5c
This commit is contained in:
parent
e374b4b08e
commit
1dceabb0eb
2 changed files with 38 additions and 1 deletions
|
@ -10131,6 +10131,22 @@ public class AST2TemplateTests extends AST2CPPTestBase {
|
||||||
parseAndCheckBindings();
|
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>
|
// template <typename, typename>
|
||||||
// struct is_same {
|
// struct is_same {
|
||||||
// static constexpr bool value = false;
|
// static constexpr bool value = false;
|
||||||
|
|
|
@ -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) {
|
if (type instanceof ITypeContainer) {
|
||||||
final ITypeContainer typeContainer = (ITypeContainer) type;
|
final ITypeContainer typeContainer = (ITypeContainer) type;
|
||||||
IType nestedType = typeContainer.getType();
|
IType nestedType = typeContainer.getType();
|
||||||
|
|
Loading…
Add table
Reference in a new issue