brintos

brintos / llvm-project-archived public Read only

0
0
Text · 2.0 KiB · 66e7935 Raw
44 lines · cpp
1// RUN: %clang_cc1 -std=c++1z %s -verify -Wno-unused2 3namespace 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}}7  }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'?}}9 10  namespace B {11    void typo_first_b(); // expected-note {{found}}12  }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'?}}14 15  struct Base {16    template<typename T> static void foo(); // expected-note 4{{declared here}}17    int n;18  };19  struct Derived : Base {20    void foo(); // expected-note {{found}}21  };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{{$}}}}24 25  struct Derived2 : Base {26    void goo(); // expected-note {{found}}27  };28  void testMember2() { Derived2().goo<int>(); } // expected-error {{member 'goo' of 'InExpr::Derived2' is not a template; did you mean 'foo'?}}29 30  void no_correction() {31    int foo; // expected-note 3{{found}}32 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'?}}36 37    // These are valid expressions.38    foo<foo; // expected-warning {{self-comparison}}39    foo<int()>(0); // expected-error {{chained comparison 'X < Y > Z' does not behave the same as a mathematical expression}}40    foo<int(), true>(false);41    foo<Base{}.n;42  }43}44