1
0
Fork 0
mirror of https://github.com/eclipse-cdt/cdt synced 2025-07-24 09:25:31 +02:00

Bug 519361: use placeholder type for template<auto>

Change-Id: I40f96479148a92618050ba50d7761f478f92024d
Signed-off-by: Vlad Ivanov <vlad@ivanov.email>
This commit is contained in:
Vlad Ivanov 2018-05-07 16:45:18 +03:00 committed by Nathan Ridge
parent 9cf1f0625e
commit 0bf58281c2
3 changed files with 24 additions and 7 deletions

View file

@ -33,4 +33,18 @@ public class TemplateAutoTests extends AST2CPPTestBase {
public void testTemplateNontypeParameterTypeDeductionParsing_519361() throws Exception {
parseAndCheckBindings();
}
// template<typename T>
// struct Helper {};
//
// void test() {}
//
// template<auto F>
// struct C {
// using T = decltype(F);
// using H = Helper<T>;
// };
public void testTemplateNontypeParameterTypeDeductionParsing_519361_2() throws Exception {
parseAndCheckBindings();
}
}

View file

@ -164,6 +164,7 @@ import org.eclipse.cdt.internal.core.dom.parser.cpp.CPPMethodSpecialization;
import org.eclipse.cdt.internal.core.dom.parser.cpp.CPPMethodTemplateSpecialization;
import org.eclipse.cdt.internal.core.dom.parser.cpp.CPPParameterPackType;
import org.eclipse.cdt.internal.core.dom.parser.cpp.CPPParameterSpecialization;
import org.eclipse.cdt.internal.core.dom.parser.cpp.CPPPlaceholderType;
import org.eclipse.cdt.internal.core.dom.parser.cpp.CPPPointerToMemberType;
import org.eclipse.cdt.internal.core.dom.parser.cpp.CPPPointerType;
import org.eclipse.cdt.internal.core.dom.parser.cpp.CPPTemplateDefinition;
@ -2866,11 +2867,9 @@ public class CPPTemplates {
return null;
}
if (paramType instanceof ProblemType) {
if (paramType instanceof CPPPlaceholderType) {
// Partial support for C++17 template <auto>
if (((ProblemType) paramType).getID() == ProblemType.TYPE_CANNOT_DEDUCE_AUTO_TYPE) {
return arg;
}
return arg;
}
Cost cost = Conversions.checkImplicitConversionSequence(p, a, LVALUE, UDCMode.FORBIDDEN,

View file

@ -2214,9 +2214,13 @@ public class CPPVisitor extends ASTQueries {
return createAutoParameterType(declSpec, declarator,
(ICPPASTParameterDeclaration) declarator.getParent(), placeholderKind);
} else {
// 'auto' used as the type of a template parameter.
// This is a C++17 feature we don't yet support.
return ProblemType.CANNOT_DEDUCE_AUTO_TYPE;
if (placeholderKind == PlaceholderKind.Auto) {
// 'auto' used as the type of a template parameter.
// This is a partially supported C++17 feature.
return new CPPPlaceholderType(placeholderKind);
} else {
return ProblemType.CANNOT_DEDUCE_DECLTYPE_AUTO_TYPE;
}
}
}
ICPPASTInitializerClause autoInitClause= null;