llvm-capstone/clang/test/SemaTemplate/dependent-typos-recovery.cpp
Richard Smith c4fb7720ce PR48339: Improve diagnostics for invalid dependent unqualified function calls.
Fix bogus diagnostics that would get confused and think a "no viable
fuctions" case was an "undeclared identifiers" case, resulting in an
incorrect diagnostic preceding the correct one. Use overload resolution
to determine which function we should select when we can find call
candidates from a dependent base class. Make the diagnostics for a call
that could call a function from a dependent base class more specific,
and use a different diagnostic message for the case where the call
target is instead declared later in the same class. Plus some minor
diagnostic wording improvements.
2020-12-02 17:54:55 -08:00

24 lines
813 B
C++

// RUN: %clang_cc1 -fsyntax-only -verify %s
// There should be no extra errors about missing 'template' keywords.
struct B {
template <typename T>
int f(){};
} builder; // expected-note 2{{'builder' declared here}}
auto a = bilder.f<int>(); // expected-error{{undeclared identifier 'bilder'; did you mean}}
auto b = (*(&bilder+0)).f<int>(); // expected-error{{undeclared identifier 'bilder'; did you mean}}
struct X {
struct type {};
};
namespace PR48339 {
struct S {
template <typename T> static void g(typename T::type) {} // expected-note {{couldn't infer template argument 'T'}}
template <typename T> void f() { g(typename T::type{}); } // expected-error {{no matching function for call to 'g'}}
};
void f() { S{}.f<X>(); } // expected-note {{in instantiation of}}
}