|
1 | | -// RUN: %clang_cc1 -std=c++98 -pedantic-errors %s -verify=expected |
2 | | -// RUN: %clang_cc1 -std=c++11 -pedantic-errors %s -verify=expected |
3 | | -// RUN: %clang_cc1 -std=c++14 -pedantic-errors %s -verify=expected |
| 1 | +// RUN: %clang_cc1 -std=c++98 -pedantic-errors %s -verify=expected,cxx98-14 |
| 2 | +// RUN: %clang_cc1 -std=c++11 -pedantic-errors %s -verify=expected,cxx98-14 |
| 3 | +// RUN: %clang_cc1 -std=c++14 -pedantic-errors %s -verify=expected,cxx98-14 |
4 | 4 | // RUN: %clang_cc1 -std=c++17 -pedantic-errors %s -verify=expected,since-cxx17 |
5 | 5 | // RUN: %clang_cc1 -std=c++20 -pedantic-errors %s -verify=expected,since-cxx17 |
6 | 6 | // RUN: %clang_cc1 -std=c++23 -pedantic-errors %s -verify=expected,since-cxx17 |
7 | 7 | // RUN: %clang_cc1 -std=c++2c -pedantic-errors %s -verify=expected,since-cxx17 |
8 | 8 |
|
9 | | -#if __cplusplus <= 201402L |
10 | | -// expected-no-diagnostics |
11 | | -#endif |
12 | | - |
13 | 9 | namespace cwg2406 { // cwg2406: 5 |
14 | 10 | #if __cplusplus >= 201703L |
15 | 11 | void fallthrough(int n) { |
@@ -186,3 +182,36 @@ namespace cwg2445 { // cwg2445: 19 |
186 | 182 | } |
187 | 183 | #endif |
188 | 184 | } |
| 185 | + |
| 186 | +namespace cwg2486 { // cwg2486: 4 c++17 |
| 187 | +struct C { |
| 188 | + void fn() throw(); |
| 189 | +}; |
| 190 | + |
| 191 | +static void call(C& c, void (C::*f)()) { |
| 192 | + (c.*f)(); |
| 193 | +} |
| 194 | + |
| 195 | +static void callNE(C& c, void (C::*f)() throw()) { |
| 196 | +// cxx98-14-warning@-1 {{mangled name of 'callNE' will change in C++17 due to non-throwing exception specification in function signature}} |
| 197 | + (c.*f)(); |
| 198 | +} |
| 199 | + |
| 200 | +void ref() { |
| 201 | + C c; |
| 202 | + call(c, &C::fn); // <= implicit cast removes noexcept |
| 203 | + callNE(c, &C::fn); |
| 204 | +} |
| 205 | + |
| 206 | +void (*p)(); |
| 207 | +void (*pp)() throw() = p; |
| 208 | +// since-cxx17-error@-1 {{cannot initialize a variable of type 'void (*)() throw()' with an lvalue of type 'void (*)()': different exception specifications}} |
| 209 | + |
| 210 | +struct S { |
| 211 | + typedef void (*p)(); |
| 212 | + operator p(); // #cwg2486-conv |
| 213 | +}; |
| 214 | +void (*q)() throw() = S(); |
| 215 | +// since-cxx17-error@-1 {{no viable conversion from 'S' to 'void (*)() throw()'}} |
| 216 | +// since-cxx17-note@#cwg2486-conv {{candidate function}} |
| 217 | +} // namespace cwg2486 |
0 commit comments