mirror of
https://github.com/eclipse-cdt/cdt
synced 2025-04-23 22:52:11 +02:00
Bug 519361: try to deduce the type of non-type template parameters
This commit resolves some of type resolution errors for C++17 <auto> templates. Change-Id: Ibdd3dcc0b7740bce1d6f390d034e1ce67c27be58 Signed-off-by: Vlad Ivanov <vlad@ivanov.email>
This commit is contained in:
parent
3929a1fc80
commit
ac0e24da56
3 changed files with 47 additions and 0 deletions
|
@ -16,6 +16,7 @@ package org.eclipse.cdt.core.parser.tests.ast2;
|
|||
import org.eclipse.cdt.core.parser.tests.ast2.cxx14.GenericLambdaTests;
|
||||
import org.eclipse.cdt.core.parser.tests.ast2.cxx14.ReturnTypeDeductionTests;
|
||||
import org.eclipse.cdt.core.parser.tests.ast2.cxx14.VariableTemplateTests;
|
||||
import org.eclipse.cdt.core.parser.tests.ast2.cxx17.TemplateAutoTests;
|
||||
import org.eclipse.cdt.core.parser.tests.prefix.CompletionTestSuite;
|
||||
|
||||
import junit.framework.Test;
|
||||
|
@ -64,6 +65,8 @@ public class DOMParserTestSuite extends TestCase {
|
|||
suite.addTest(VariableTemplateTests.suite());
|
||||
suite.addTestSuite(ReturnTypeDeductionTests.class);
|
||||
suite.addTestSuite(GenericLambdaTests.class);
|
||||
// C++17 tests
|
||||
suite.addTest(TemplateAutoTests.suite());
|
||||
return suite;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -0,0 +1,36 @@
|
|||
/*******************************************************************************
|
||||
* Copyright (c) 2018 Vlad Ivanov
|
||||
* All rights reserved. This program and the accompanying materials
|
||||
* are made available under the terms of the Eclipse Public License v1.0
|
||||
* which accompanies this distribution, and is available at
|
||||
* http://www.eclipse.org/legal/epl-v10.html
|
||||
*
|
||||
* Contributors:
|
||||
* Vlad Ivanov (LabSystems) - Initial implementation
|
||||
*******************************************************************************/
|
||||
package org.eclipse.cdt.core.parser.tests.ast2.cxx17;
|
||||
|
||||
import org.eclipse.cdt.core.parser.tests.ast2.AST2CPPTestBase;
|
||||
|
||||
import junit.framework.TestSuite;
|
||||
|
||||
public class TemplateAutoTests extends AST2CPPTestBase {
|
||||
|
||||
public static TestSuite suite() {
|
||||
return suite(TemplateAutoTests.class);
|
||||
}
|
||||
|
||||
// template<auto F>
|
||||
// struct C {
|
||||
// using T = decltype(F);
|
||||
// };
|
||||
//
|
||||
// void foo() {
|
||||
//
|
||||
// }
|
||||
//
|
||||
// using A = C<&foo>::T;
|
||||
public void testTemplateNontypeParameterTypeDeductionParsing_519361() throws Exception {
|
||||
parseAndCheckBindings();
|
||||
}
|
||||
}
|
|
@ -2865,6 +2865,14 @@ public class CPPTemplates {
|
|||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
if (paramType instanceof ProblemType) {
|
||||
// Partial support for C++17 template <auto>
|
||||
if (((ProblemType) paramType).getID() == ProblemType.TYPE_CANNOT_DEDUCE_AUTO_TYPE) {
|
||||
return arg;
|
||||
}
|
||||
}
|
||||
|
||||
Cost cost = Conversions.checkImplicitConversionSequence(p, a, LVALUE, UDCMode.FORBIDDEN,
|
||||
Context.ORDINARY);
|
||||
if (cost == null || !cost.converts()) {
|
||||
|
|
Loading…
Add table
Reference in a new issue