File: p3.cpp

package info (click to toggle)
llvm-toolchain-11 1%3A11.0.1-2
  • links: PTS, VCS
  • area: main
  • in suites: bullseye
  • size: 995,808 kB
  • sloc: cpp: 4,767,656; ansic: 760,916; asm: 477,436; python: 170,940; objc: 69,804; lisp: 29,914; sh: 23,855; f90: 18,173; pascal: 7,551; perl: 7,471; ml: 5,603; awk: 3,489; makefile: 2,573; xml: 915; cs: 573; fortran: 503; javascript: 452
file content (67 lines) | stat: -rw-r--r-- 1,578 bytes parent folder | download | duplicates (21)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
// RUN: %clang_cc1 -fsyntax-only -verify %s
// RUN: %clang_cc1 -std=c++17 -fsyntax-only -verify %s
// RUN: %clang_cc1 -std=c++20 -fsyntax-only -verify %s

typedef int fn;

namespace N0 {
  struct A {
    friend void fn();
    void g() {
      int i = fn(1);
    }
  };
}

namespace N1 {
  struct A {
    friend void fn(A &);
    operator int();
    void g(A a) {
      // ADL should not apply to the lookup of 'fn', it refers to the typedef
      // above.
      int i = fn(a);
    }
  };
}

namespace std_example {
  int h; // expected-note {{non-template declaration}}
  void g();
#if __cplusplus <= 201703L
  // expected-note@-2 {{non-template declaration}}
#endif
  namespace N {
    struct A {};
    template<class T> int f(T);
    template<class T> int g(T);
#if __cplusplus <= 201703L
    // expected-note@-2 {{here}}
#endif
    template<class T> int h(T); // expected-note {{here}}
  }

  int x = f<N::A>(N::A());
#if __cplusplus <= 201703L
  // expected-warning@-2 {{C++20 extension}}
#endif
  int y = g<N::A>(N::A());
#if __cplusplus <= 201703L
  // expected-error@-2 {{'g' does not name a template but is followed by template arguments; did you mean 'N::g'?}}
#endif
  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'?}}
}

namespace AnnexD_example {
  struct A {};
  void operator<(void (*fp)(), A);
  void f() {}
  int main() {
    A a;
    f < a;
#if __cplusplus > 201703L
    // expected-error@-2 {{expected '>'}} expected-note@-2 {{to match this '<'}}
#endif
    (f) < a;
  }
}