File: p3.cpp

package info (click to toggle)
llvm-toolchain-9 1%3A9.0.1-16.1
  • links: PTS, VCS
  • area: main
  • in suites: bullseye
  • size: 882,388 kB
  • sloc: cpp: 4,167,636; ansic: 714,256; asm: 457,610; python: 155,927; objc: 65,094; sh: 42,856; lisp: 26,908; perl: 7,786; pascal: 7,722; makefile: 6,881; ml: 5,581; awk: 3,648; cs: 2,027; xml: 888; javascript: 381; ruby: 156
file content (67 lines) | stat: -rw-r--r-- 1,539 bytes parent folder | download | duplicates (2)
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++2a -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++2a 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 '>'}}
#endif
    (f) < a;
  }
}