brintos

brintos / llvm-project-archived public Read only

0
0
Text · 1.5 KiB · 8ac4e97 Raw
68 lines · cpp
1// RUN: %clang_cc1 -fsyntax-only -verify %s2// RUN: %clang_cc1 -std=c++17 -fsyntax-only -verify %s3// RUN: %clang_cc1 -std=c++20 -fsyntax-only -verify %s4 5typedef int fn;6 7namespace N0 {8  struct A {9    friend void fn();10    void g() {11      int i = fn(1);12    }13  };14}15 16namespace N1 {17  struct A {18    friend void fn(A &);19    operator int();20    void g(A a) {21      // ADL should not apply to the lookup of 'fn', it refers to the typedef22      // above.23      int i = fn(a);24    }25  };26}27 28namespace std_example {29  int h; // expected-note {{non-template declaration}}30  void g();31#if __cplusplus <= 201703L32  // expected-note@-2 {{non-template declaration}}33#endif34  namespace N {35    struct A {};36    template<class T> int f(T);37    template<class T> int g(T);38#if __cplusplus <= 201703L39    // expected-note@-2 {{here}}40#endif41    template<class T> int h(T); // expected-note {{here}}42  }43 44  int x = f<N::A>(N::A());45#if __cplusplus <= 201703L46  // expected-warning@-2 {{C++20 extension}}47#endif48  int y = g<N::A>(N::A());49#if __cplusplus <= 201703L50  // expected-error@-2 {{'g' does not name a template but is followed by template arguments; did you mean 'N::g'?}}51#endif52  int z = h<N::A>(N::A()); // expected-error {{'h' does not name a template but is followed by template arguments; did you mean 'N::h'?}}53}54 55namespace AnnexD_example {56  struct A {};57  void operator<(void (*fp)(), A);58  void f() {}59  int main() {60    A a;61    f < a;62#if __cplusplus > 201703L63    // expected-error@-2 {{expected '>'}} expected-note@-2 {{to match this '<'}}64#endif65    (f) < a;66  }67}68