[clang] Implement lifetime analysis for lifetime_capture_by(X) (#115921)
[llvm-project.git] / clang / test / SemaTemplate / typo-template-name.cpp
blob741aa708e81fc36b79b07a24a59f61cb0c3bfacd
1 // RUN: %clang_cc1 -std=c++1z %s -verify -Wno-unused
3 namespace InExpr {
4 namespace A {
5 void typo_first_a(); // expected-note {{found}}
6 template<typename T> void typo_first_b(); // expected-note 2{{declared here}}
8 void testA() { A::typo_first_a<int>(); } // expected-error {{'typo_first_a' does not name a template but is followed by template arguments; did you mean 'typo_first_b'?}}
10 namespace B {
11 void typo_first_b(); // expected-note {{found}}
13 void testB() { B::typo_first_b<int>(); } // expected-error {{'typo_first_b' does not name a template but is followed by template arguments; did you mean 'A::typo_first_b'?}}
15 struct Base {
16 template<typename T> static void foo(); // expected-note 4{{declared here}}
17 int n;
19 struct Derived : Base {
20 void foo(); // expected-note {{found}}
22 // We probably don't want to suggest correcting to .Base::foo<int>
23 void testMember() { Derived().foo<int>(); } // expected-error-re {{does not name a template but is followed by template arguments{{$}}}}
25 struct Derived2 : Base {
26 void goo(); // expected-note {{found}}
28 void testMember2() { Derived2().goo<int>(); } // expected-error {{member 'goo' of 'InExpr::Derived2' is not a template; did you mean 'foo'?}}
30 void no_correction() {
31 int foo; // expected-note 3{{found}}
33 foo<int>(); // expected-error {{'foo' does not name a template but is followed by template arguments; did you mean 'Base::foo'?}}
34 foo<>(); // expected-error {{'foo' does not name a template but is followed by template arguments; did you mean 'Base::foo'?}}
35 foo<Base *>(); // expected-error {{'foo' does not name a template but is followed by template arguments; did you mean 'Base::foo'?}}
37 // These are valid expressions.
38 foo<foo; // expected-warning {{self-comparison}}
39 foo<int()>(0); // expected-warning {{comparisons like 'X<=Y<=Z' don't have their mathematical meaning}}
40 foo<int(), true>(false);
41 foo<Base{}.n;