]> CyberLeo.Net >> Repos - FreeBSD/FreeBSD.git/blob - test/CXX/drs/dr7xx.cpp
Vendor import of clang trunk r338150:
[FreeBSD/FreeBSD.git] / test / CXX / drs / dr7xx.cpp
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++14 %s -verify -fexceptions -fcxx-exceptions -pedantic-errors
4 // RUN: %clang_cc1 -std=c++1z %s -verify -fexceptions -fcxx-exceptions -pedantic-errors
5
6 namespace dr727 { // dr727: partial
7   struct A {
8     template<typename T> struct C; // expected-note 6{{here}}
9     template<typename T> void f(); // expected-note {{here}}
10     template<typename T> static int N; // expected-error 0-1{{C++14}} expected-note 6{{here}}
11
12     template<> struct C<int>;
13     template<> void f<int>();
14     template<> static int N<int>;
15
16     template<typename T> struct C<T*>;
17     template<typename T> static int N<T*>;
18
19     struct B {
20       template<> struct C<float>; // expected-error {{not in class 'A' or an enclosing namespace}}
21       template<> void f<float>(); // expected-error {{no function template matches}}
22       template<> static int N<float>; // expected-error {{not in class 'A' or an enclosing namespace}}
23
24       template<typename T> struct C<T**>; // expected-error {{not in class 'A' or an enclosing namespace}}
25       template<typename T> static int N<T**>; // expected-error {{not in class 'A' or an enclosing namespace}}
26
27       template<> struct A::C<double>; // expected-error {{not in class 'A' or an enclosing namespace}}
28       template<> void A::f<double>(); // expected-error {{no function template matches}} expected-error {{cannot have a qualified name}}
29       template<> static int A::N<double>; // expected-error {{not in class 'A' or an enclosing namespace}} expected-error {{cannot have a qualified name}}
30
31       template<typename T> struct A::C<T***>; // expected-error {{not in class 'A' or an enclosing namespace}}
32       template<typename T> static int A::N<T***>; // expected-error {{not in class 'A' or an enclosing namespace}} expected-error {{cannot have a qualified name}}
33     };
34   };
35
36   template<> struct A::C<char>;
37   template<> void A::f<char>();
38   template<> int A::N<char>;
39
40   template<typename T> struct A::C<T****>;
41   template<typename T> int A::N<T****>;
42
43   namespace C {
44     template<> struct A::C<long>; // expected-error {{not in class 'A' or an enclosing namespace}}
45     template<> void A::f<long>(); // expected-error {{not in class 'A' or an enclosing namespace}}
46     template<> int A::N<long>; // expected-error {{not in class 'A' or an enclosing namespace}}
47
48     template<typename T> struct A::C<T*****>; // expected-error {{not in class 'A' or an enclosing namespace}}
49     template<typename T> int A::N<T*****>; // expected-error {{not in class 'A' or an enclosing namespace}}
50   }
51
52   template<typename>
53   struct D {
54     template<typename T> struct C { typename T::error e; }; // expected-error {{no members}}
55     template<typename T> void f() { T::error; } // expected-error {{no members}}
56     template<typename T> static const int N = T::error; // expected-error 2{{no members}} expected-error 0-1{{C++14}}
57
58     template<> struct C<int> {};
59     template<> void f<int>() {}
60     template<> static const int N<int>;
61
62     template<typename T> struct C<T*> {};
63     template<typename T> static const int N<T*>;
64   };
65
66   void d(D<int> di) {
67     D<int>::C<int>();
68     di.f<int>();
69     int a = D<int>::N<int>; // FIXME: expected-note {{instantiation of}}
70
71     D<int>::C<int*>();
72     int b = D<int>::N<int*>;
73
74     D<int>::C<float>(); // expected-note {{instantiation of}}
75     di.f<float>(); // expected-note {{instantiation of}}
76     int c = D<int>::N<float>; // expected-note {{instantiation of}}
77   }
78 }
79
80 namespace dr777 { // dr777: 3.7
81 #if __cplusplus >= 201103L
82 template <typename... T>
83 void f(int i = 0, T ...args) {}
84 void ff() { f(); }
85
86 template <typename... T>
87 void g(int i = 0, T ...args, T ...args2) {}
88
89 template <typename... T>
90 void h(int i = 0, T ...args, int j = 1) {}
91 #endif
92 }