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++17 %s -verify -fexceptions -fcxx-exceptions -pedantic-errors
5
- // RUN: %clang_cc1 -std=c++20 %s -verify -fexceptions -fcxx-exceptions -pedantic-errors
6
- // RUN: %clang_cc1 -std=c++23 %s -verify -fexceptions -fcxx-exceptions -pedantic-errors
1
+ // RUN: %clang_cc1 -std=c++98 %s -verify=expected,cxx98-14,cxx98 -fexceptions -fcxx-exceptions -pedantic-errors
2
+ // RUN: %clang_cc1 -std=c++11 %s -verify=expected,cxx98-14,since-cxx11 -fexceptions -fcxx-exceptions -pedantic-errors
3
+ // RUN: %clang_cc1 -std=c++14 %s -verify=expected,cxx98-14,since-cxx14,since-cxx11 -fexceptions -fcxx-exceptions -pedantic-errors
4
+ // RUN: %clang_cc1 -std=c++17 %s -verify=expected,since-cxx17,since-cxx14,since-cxx11 -fexceptions -fcxx-exceptions -pedantic-errors
5
+ // RUN: %clang_cc1 -std=c++20 %s -verify=expected,since-cxx17,since-cxx14,since-cxx11 -fexceptions -fcxx-exceptions -pedantic-errors
6
+ // RUN: %clang_cc1 -std=c++23 %s -verify=expected,since-cxx17,since-cxx14,since-cxx11,since-cxx23 -fexceptions -fcxx-exceptions -pedantic-errors
7
7
8
8
// dr1200: na
9
9
@@ -40,28 +40,33 @@ struct S {
40
40
S* operator ()();
41
41
int N;
42
42
int M;
43
- #if __cplusplus > 202002L
43
+ #if __cplusplus >= 202302L
44
44
template <typename T>
45
45
static constexpr auto V = 0 ;
46
46
void f (char );
47
47
void f (int );
48
48
void mem (S s) {
49
- auto (s)()->M ; // expected-warning {{expression result unused}}
50
- auto (s)()->V <int >; // expected-warning {{expression result unused}}
49
+ auto (s)()->M ;
50
+ // since-cxx23-warning@-1 {{expression result unused}}
51
+ auto (s)()->V <int >;
52
+ // since-cxx23-warning@-1 {{expression result unused}}
51
53
auto (s)()->f (0 );
52
54
}
53
55
#endif
54
56
};
55
57
void f (S s) {
56
58
{
57
- #if __cplusplus > 202002L
58
- auto (s)()->N ; // expected-warning {{expression result unused}}
59
+ #if __cplusplus >= 202302L
60
+ auto (s)()->N ;
61
+ // since-cxx23-warning@-1 {{expression result unused}}
59
62
#endif
60
63
auto (s)()->M ;
61
64
}
62
65
{
63
- S (s)()->N ; // expected-warning {{expression result unused}}
64
- S (s)()->M ; // expected-warning {{expression result unused}}
66
+ S (s)()->N ;
67
+ // since-cxx11-warning@-1 {{expression result unused}}
68
+ S (s)()->M ;
69
+ // since-cxx11-warning@-1 {{expression result unused}}
65
70
}
66
71
}
67
72
@@ -74,23 +79,27 @@ void g() {
74
79
A a (B ()->C );
75
80
A b (auto ()->C );
76
81
static_assert (sizeof (B ()->C [1 ] == sizeof (int )), " " );
77
- sizeof (auto () -> C[1 ]); // expected-error{{function cannot return array type 'C[1]'}}
82
+ sizeof (auto () -> C[1 ]);
83
+ // since-cxx11-error@-1 {{function cannot return array type 'C[1]' (aka 'dr1223::BB[1]')}}
78
84
}
79
85
80
86
}
81
87
#endif
82
88
83
89
#if __cplusplus >= 201103L
84
90
namespace dr1227 { // dr1227: 3.0
85
- template <class T > struct A { using X = typename T::X; }; // expected-error {{type 'int' cannot be used prior to '::' because it has no members}}
91
+ template <class T > struct A { using X = typename T::X; };
92
+ // since-cxx11-error@-1 {{type 'int' cannot be used prior to '::' because it has no members}}
93
+ // since-cxx11-note@#dr1227-g {{in instantiation of template class 'dr1227::A<int>' requested here}}
94
+ // since-cxx11-note@#dr1227-g-int {{while substituting explicitly-specified template arguments into function template 'g'}}
86
95
template <class T > typename T::X f (typename A<T>::X);
87
96
template <class T > void f (...) { }
88
- template <class T > auto g (typename A<T>::X) -> typename T::X; // expected-note {{in instantiation of template class ' dr1227::A<int>' requested here}}
97
+ template <class T > auto g (typename A<T>::X) -> typename T::X; // # dr1227-g
89
98
template <class T > void g (...) { }
90
99
91
100
void h () {
92
101
f<int >(0 ); // OK, substituting return type causes deduction to fail
93
- g<int >(0 ); // expected-note {{while substituting explicitly-specified template arguments into function template 'g'}}
102
+ g<int >(0 ); // #dr1227-g-int
94
103
}
95
104
}
96
105
#endif
@@ -109,15 +118,21 @@ struct Derived : Base {
109
118
110
119
namespace dr1265 { // dr1265: 5
111
120
#if __cplusplus >= 201103L
112
- auto a = 0 , b() -> int ; // expected-error {{declaration with trailing return type must be the only declaration in its group}}
113
- auto b () -> int, d = 0; // expected-error {{declaration with trailing return type must be the only declaration in its group}}
114
- auto e () -> int, f() -> int; // expected-error {{declaration with trailing return type must be the only declaration in its group}}
121
+ auto a = 0 , b() -> int ;
122
+ // since-cxx11-error@-1 {{declaration with trailing return type must be the only declaration in its group}}
123
+ auto b () -> int, d = 0;
124
+ // since-cxx11-error@-1 {{declaration with trailing return type must be the only declaration in its group}}
125
+ auto e () -> int, f() -> int;
126
+ // since-cxx11-error@-1 {{declaration with trailing return type must be the only declaration in its group}}
115
127
#endif
116
128
117
129
#if __cplusplus >= 201402L
118
- auto g (), h = 0; // expected-error {{function with deduced return type must be the only declaration in its group}}
119
- auto i = 0 , j(); // expected-error {{function with deduced return type must be the only declaration in its group}}
120
- auto k (), l(); // expected-error {{function with deduced return type must be the only declaration in its group}}
130
+ auto g (), h = 0;
131
+ // since-cxx14-error@-1 {{function with deduced return type must be the only declaration in its group}}
132
+ auto i = 0 , j();
133
+ // since-cxx14-error@-1 {{function with deduced return type must be the only declaration in its group}}
134
+ auto k (), l();
135
+ // since-cxx14-error@-1 {{function with deduced return type must be the only declaration in its group}}
121
136
#endif
122
137
}
123
138
@@ -130,16 +145,16 @@ namespace dr1295 { // dr1295: 4
130
145
131
146
X x = {1 };
132
147
133
- unsigned const &r1 = static_cast <X &&>(x).bitfield; // expected-error 0-1{{C++11}}
134
- unsigned const &r2 = static_cast <unsigned &&>(x.bitfield); // expected-error 0-1{{C++11}}
148
+ unsigned const &r1 = static_cast <X &&>(x).bitfield;
149
+ // cxx98-error@-1 {{rvalue references are a C++11 extension}}
150
+ unsigned const &r2 = static_cast <unsigned &&>(x.bitfield);
151
+ // cxx98-error@-1 {{rvalue references are a C++11 extension}}
135
152
136
- template <unsigned &r> struct Y {};
137
- Y<x.bitfield> y;
138
- #if __cplusplus <= 201402L
139
- // expected-error@-2 {{does not refer to any declaration}} expected-note@-3 {{here}}
140
- #else
141
- // expected-error@-4 {{refers to subobject}}
142
- #endif
153
+ template <unsigned &r> struct Y {}; // #dr1295-Y
154
+ Y<x.bitfield> y; // #dr1295-y
155
+ // cxx98-14-error@-1 {{non-type template argument does not refer to any declaration}}
156
+ // cxx98-14-note@#dr1295-Y {{template parameter is declared here}}
157
+ // since-cxx17-error@#dr1295-y {{non-type template argument refers to subobject 'x.bitfield'}}
143
158
144
159
#if __cplusplus >= 201103L
145
160
const unsigned other = 0 ;
0 commit comments