dr2xx.cpp revision 2c1721f12297bb881f7f9deb383fe6616d835272
1// RUN: %clang_cc1 -std=c++98 %s -verify -fexceptions -fcxx-exceptions -pedantic-errors
2// RUN: %clang_cc1 -std=c++11 %s -verify -fexceptions -fcxx-exceptions -pedantic-errors
3// RUN: %clang_cc1 -std=c++1y %s -verify -fexceptions -fcxx-exceptions -pedantic-errors
4
5#if __cplusplus < 201103L
6#define fold(x) (__builtin_constant_p(x) ? (x) : (x))
7#else
8#define fold
9#endif
10
11namespace dr200 { // dr200: dup 214
12  template <class T> T f(int);
13  template <class T, class U> T f(U) = delete; // expected-error 0-1{{extension}}
14
15  void g() {
16    f<int>(1);
17  }
18}
19
20// dr201 FIXME: write codegen test
21
22namespace dr202 { // dr202: yes
23  template<typename T> T f();
24  template<int (*g)()> struct X {
25    int arr[fold(g == &f<int>) ? 1 : -1];
26  };
27  template struct X<f>;
28}
29
30// FIXME (export) dr204: no
31
32namespace dr206 { // dr206: yes
33  struct S; // expected-note 2{{declaration}}
34  template<typename T> struct Q { S s; }; // expected-error {{incomplete}}
35  template<typename T> void f() { S s; } // expected-error {{incomplete}}
36}
37
38namespace dr207 { // dr207: yes
39  class A {
40  protected:
41    static void f() {}
42  };
43  class B : A {
44  public:
45    using A::f;
46    void g() {
47      A::f();
48      f();
49    }
50  };
51}
52
53// dr208 FIXME: write codegen test
54
55namespace dr209 { // dr209: yes
56  class A {
57    void f(); // expected-note {{here}}
58  };
59  class B {
60    friend void A::f(); // expected-error {{private}}
61  };
62}
63
64// dr210 FIXME: write codegen test
65
66namespace dr211 { // dr211: yes
67  struct A {
68    A() try {
69      throw 0;
70    } catch (...) {
71      return; // expected-error {{return in the catch of a function try block of a constructor}}
72    }
73  };
74}
75
76namespace dr213 { // dr213: yes
77  template <class T> struct A : T {
78    void h(T t) {
79      char &r1 = f(t);
80      int &r2 = g(t); // expected-error {{undeclared}}
81    }
82  };
83  struct B {
84    int &f(B);
85    int &g(B); // expected-note {{in dependent base class}}
86  };
87  char &f(B);
88
89  template void A<B>::h(B); // expected-note {{instantiation}}
90}
91
92namespace dr214 { // dr214: yes
93  template<typename T, typename U> T checked_cast(U from) { U::error; }
94  template<typename T, typename U> T checked_cast(U *from);
95  class C {};
96  void foo(int *arg) { checked_cast<const C *>(arg); }
97
98  template<typename T> T f(int);
99  template<typename T, typename U> T f(U) { T::error; }
100  void g() {
101    f<int>(1);
102  }
103}
104
105namespace dr215 { // dr215: yes
106  template<typename T> class X {
107    friend void T::foo();
108    int n;
109  };
110  struct Y {
111    void foo() { (void)+X<Y>().n; }
112  };
113}
114