diff --git a/core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/core/parser/tests/ast2/DOMParserTestSuite.java b/core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/core/parser/tests/ast2/DOMParserTestSuite.java index ff7ebd55b85..75cebea83b1 100644 --- a/core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/core/parser/tests/ast2/DOMParserTestSuite.java +++ b/core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/core/parser/tests/ast2/DOMParserTestSuite.java @@ -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; } } diff --git a/core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/core/parser/tests/ast2/cxx17/TemplateAutoTests.java b/core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/core/parser/tests/ast2/cxx17/TemplateAutoTests.java new file mode 100644 index 00000000000..f50b4cd32a7 --- /dev/null +++ b/core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/core/parser/tests/ast2/cxx17/TemplateAutoTests.java @@ -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 + // struct C { + // using T = decltype(F); + // }; + // + // void foo() { + // + // } + // + // using A = C<&foo>::T; + public void testTemplateNontypeParameterTypeDeductionParsing_519361() throws Exception { + parseAndCheckBindings(); + } +} 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 98574a76890..2ce50e1d203 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 @@ -2865,6 +2865,14 @@ public class CPPTemplates { } return null; } + + if (paramType instanceof ProblemType) { + // Partial support for C++17 template + 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()) {