mirror of
https://github.com/eclipse-cdt/cdt
synced 2025-07-05 16:15:25 +02:00
Bug 469788 - Ambiguous node in initializer in trailing return type
Change-Id: Iff81cad75a57c9482ada515a9e9a34d5d1a956d3
This commit is contained in:
parent
2e36830918
commit
cf0b76c58e
2 changed files with 60 additions and 2 deletions
|
@ -8866,6 +8866,56 @@ public class AST2TemplateTests extends AST2TestBase {
|
|||
parseAndCheckBindings();
|
||||
}
|
||||
|
||||
// template<typename T>
|
||||
// struct remove_reference {
|
||||
// typedef T type;
|
||||
// };
|
||||
//
|
||||
// template<typename T>
|
||||
// struct remove_reference<T&> {
|
||||
// typedef T type;
|
||||
// };
|
||||
//
|
||||
// template<typename T>
|
||||
// struct remove_reference<T&&> {
|
||||
// typedef T type;
|
||||
// };
|
||||
//
|
||||
// template<typename T>
|
||||
// T&& waldo(typename remove_reference<T>::type& t);
|
||||
//
|
||||
// template <class T>
|
||||
// struct D {
|
||||
// T t;
|
||||
// };
|
||||
//
|
||||
// template <class T, class U>
|
||||
// T f(U p);
|
||||
//
|
||||
// template <class T, class U>
|
||||
// auto g(U&& t) -> decltype(f<T, D<U>>(D<U>{waldo<U>(t)})) {
|
||||
// return f<T, D<U>>(D<U>{waldo<U>(t)});
|
||||
// }
|
||||
//
|
||||
// struct A {};
|
||||
//
|
||||
// template <typename T>
|
||||
// struct B {
|
||||
// A a;
|
||||
//
|
||||
// void method() {
|
||||
// g<A>(a);
|
||||
// }
|
||||
// };
|
||||
//
|
||||
// void test() {
|
||||
// B<int> b;
|
||||
// b.method();
|
||||
// }
|
||||
public void testAmbiguityResolution_469788() throws Exception {
|
||||
parseAndCheckBindings();
|
||||
}
|
||||
|
||||
// template <typename>
|
||||
// struct Base {
|
||||
// template <typename>
|
||||
|
|
|
@ -30,9 +30,11 @@ import org.eclipse.cdt.core.dom.ast.IASTNode;
|
|||
import org.eclipse.cdt.core.dom.ast.IASTParameterDeclaration;
|
||||
import org.eclipse.cdt.core.dom.ast.IASTSimpleDeclaration;
|
||||
import org.eclipse.cdt.core.dom.ast.IASTTranslationUnit;
|
||||
import org.eclipse.cdt.core.dom.ast.IASTTypeId;
|
||||
import org.eclipse.cdt.core.dom.ast.IScope;
|
||||
import org.eclipse.cdt.core.dom.ast.cpp.ICPPASTCompositeTypeSpecifier;
|
||||
import org.eclipse.cdt.core.dom.ast.cpp.ICPPASTElaboratedTypeSpecifier;
|
||||
import org.eclipse.cdt.core.dom.ast.cpp.ICPPASTFunctionDeclarator;
|
||||
import org.eclipse.cdt.core.dom.ast.cpp.ICPPASTTemplateDeclaration;
|
||||
import org.eclipse.cdt.core.dom.ast.cpp.ICPPASTTemplateId;
|
||||
import org.eclipse.cdt.core.dom.ast.cpp.ICPPASTTemplateSpecialization;
|
||||
|
@ -127,10 +129,16 @@ final class CPPASTAmbiguityResolver extends ASTVisitor {
|
|||
|
||||
// Visit the declarator first, it may contain ambiguous template arguments needed
|
||||
// for associating the template declarations.
|
||||
fSkipInitializers++;
|
||||
ASTQueries.findOutermostDeclarator(fdef.getDeclarator()).accept(this);
|
||||
ICPPASTFunctionDeclarator fdecl = (ICPPASTFunctionDeclarator) fdef.getDeclarator();
|
||||
fSkipInitializers++; // Initializers may refer to class members declared later.
|
||||
fdecl.accept(this);
|
||||
fSkipInitializers--;
|
||||
fdef.getDeclSpecifier().accept(this);
|
||||
IASTTypeId trailingReturnType = fdecl.getTrailingReturnType();
|
||||
if (trailingReturnType != null) {
|
||||
// Visit initializers inside the trailing return type that were skipped earlier.
|
||||
trailingReturnType.accept(this);
|
||||
}
|
||||
// Defer visiting the body of the function until the class body has been visited.
|
||||
fDeferredNodes.getLast().add(decl);
|
||||
return PROCESS_SKIP;
|
||||
|
|
Loading…
Add table
Reference in a new issue