1 // RUN: %clang_cc1 -std=c++98 %s -verify=expected -fexceptions -fcxx-exceptions -pedantic-errors 2 // RUN: %clang_cc1 -std=c++11 %s -verify=expected,cxx11-17,since-cxx11, -fexceptions -fcxx-exceptions -pedantic-errors 3 // RUN: %clang_cc1 -std=c++14 %s -verify=expected,cxx14-17,cxx11-17,since-cxx11,since-cxx14 -fexceptions -fcxx-exceptions -pedantic-errors 4 // RUN: %clang_cc1 -std=c++17 %s -verify=expected,cxx14-17,cxx11-17,since-cxx11,since-cxx14 -fexceptions -fcxx-exceptions -pedantic-errors 5 // RUN: %clang_cc1 -std=c++20 %s -verify=expected,since-cxx11,since-cxx14,since-cxx20 -fexceptions -fcxx-exceptions -pedantic-errors 6 // RUN: %clang_cc1 -std=c++23 %s -verify=expected,since-cxx11,since-cxx14,since-cxx20 -fexceptions -fcxx-exceptions -pedantic-errors 7 // RUN: %clang_cc1 -std=c++2c %s -verify=expected,since-cxx11,since-cxx14,since-cxx20 -fexceptions -fcxx-exceptions -pedantic-errors 8 9 namespace cwg1413 { // cwg1413: 12 10 template<int> struct Check { 11 typedef int type; 12 }; 13 template<typename T> struct A : T { 14 static const int a = 1; 15 static const int b; 16 static void c(); 17 void d(); 18 19 void f() { 20 Check<true ? 0 : A::unknown_spec>::type *var1; 21 // expected-error@-1 {{use of undeclared identifier 'var1'}} 22 23 // ok, variable declaration 24 Check<true ? 0 : a>::type *var2; // #cwg1413-var2 25 Check<true ? 0 : b>::type *var3; 26 // expected-error@-1 {{use of undeclared identifier 'var3'}} 27 // expected-note@#cwg1413-var2 {{'var2' declared here}} 28 Check<true ? 0 : ((void)c, 0)>::type *var4; 29 // expected-error@-1 {{use of undeclared identifier 'var4'}} 30 // expected-note@#cwg1413-var2 {{'var2' declared here}} 31 32 // value-dependent because of the implied type-dependent 'this->', not because of 'd' 33 Check<true ? 0 : (d(), 0)>::type *var5; 34 // expected-error@-1 {{use of undeclared identifier 'var5'}} 35 // expected-note@#cwg1413-var2 {{'var2' declared here}} 36 37 // value-dependent because of the value-dependent '&' operator, not because of 'A::d' 38 Check<true ? 0 : (&A::d(), 0)>::type *var5; 39 // expected-error@-1 {{use of undeclared identifier 'var5'}} 40 // expected-note@#cwg1413-var2 {{'var2' declared here}} 41 } 42 }; 43 } // namespace cwg1413 44 45 namespace cwg1423 { // cwg1423: 11 46 #if __cplusplus >= 201103L 47 bool b1 = nullptr; 48 // since-cxx11-error@-1 {{cannot initialize a variable of type 'bool' with an rvalue of type 'std::nullptr_t'}} 49 bool b2(nullptr); 50 // since-cxx11-warning@-1 {{implicit conversion of nullptr constant to 'bool'}} 51 bool b3 = {nullptr}; 52 // since-cxx11-error@-1 {{cannot initialize a variable of type 'bool' with an rvalue of type 'std::nullptr_t'}} 53 bool b4{nullptr}; 54 // since-cxx11-warning@-1 {{implicit conversion of nullptr constant to 'bool'}} 55 #endif 56 } // namespace 1423 57 58 // cwg1425: na abi 59 60 namespace cwg1432 { // cwg1432: 16 61 #if __cplusplus >= 201103L 62 template<typename T> T declval(); 63 64 template <class... T> 65 struct common_type; 66 67 template <class T, class U> 68 struct common_type<T, U> { 69 typedef decltype(true ? declval<T>() : declval<U>()) type; 70 }; 71 72 template <class T, class U, class... V> 73 struct common_type<T, U, V...> { 74 typedef typename common_type<typename common_type<T, U>::type, V...>::type type; 75 }; 76 77 template struct common_type<int, double>; 78 #endif 79 } // namespace cwg1432 80 81 namespace cwg1443 { // cwg1443: 2.7 82 struct A { 83 int i; 84 A() { void foo(int=i); } 85 // expected-error@-1 {{default argument references 'this'}} 86 }; 87 } // namespace cwg1443 88 89 namespace cwg1458 { // cwg1458: 3.1 90 #if __cplusplus >= 201103L 91 struct A; 92 93 void f() { 94 constexpr A* a = nullptr; 95 constexpr int p = &*a; 96 // since-cxx11-error@-1 {{cannot initialize a variable of type 'const int' with an rvalue of type 'A *'}} 97 constexpr A *p2 = &*a; 98 } 99 100 struct A { 101 int operator&(); 102 }; 103 #endif 104 } // namespace cwg1458 105 106 namespace cwg1460 { // cwg1460: 3.5 107 #if __cplusplus >= 201103L 108 namespace DRExample { 109 union A { 110 union {}; 111 // since-cxx11-error@-1 {{declaration does not declare anything}} 112 union {}; 113 // since-cxx11-error@-1 {{declaration does not declare anything}} 114 constexpr A() {} 115 }; 116 constexpr A a = A(); 117 118 union B { 119 union {}; 120 // since-cxx11-error@-1 {{declaration does not declare anything}} 121 union {}; 122 // since-cxx11-error@-1 {{declaration does not declare anything}} 123 constexpr B() = default; 124 }; 125 constexpr B b = B(); 126 127 union C { 128 union {}; 129 // since-cxx11-error@-1 {{declaration does not declare anything}} 130 union {}; 131 // since-cxx11-error@-1 {{declaration does not declare anything}} 132 }; 133 constexpr C c = C(); 134 #if __cplusplus >= 201403L 135 constexpr void f() { C c; } 136 static_assert((f(), true), ""); 137 #endif 138 } 139 140 union A {}; 141 union B { int n; }; // #cwg1460-B 142 union C { int n = 0; }; 143 struct D { union {}; }; 144 // since-cxx11-error@-1 {{declaration does not declare anything}} 145 struct E { union { int n; }; }; // #cwg1460-E 146 struct F { union { int n = 0; }; }; 147 148 struct X { 149 friend constexpr A::A() noexcept; 150 friend constexpr B::B() noexcept; 151 // cxx11-17-error@-1 {{constexpr declaration of 'B' follows non-constexpr declaration}} 152 // cxx11-17-note@#cwg1460-B {{previous declaration is here}} 153 friend constexpr C::C() noexcept; 154 friend constexpr D::D() noexcept; 155 friend constexpr E::E() noexcept; 156 // cxx11-17-error@-1 {{constexpr declaration of 'E' follows non-constexpr declaration}} 157 // cxx11-17-note@#cwg1460-E {{previous declaration is here}} 158 friend constexpr F::F() noexcept; 159 }; 160 161 // These are OK, because value-initialization doesn't actually invoke the 162 // constructor. 163 constexpr A a = A(); 164 constexpr B b = B(); 165 constexpr C c = C(); 166 constexpr D d = D(); 167 constexpr E e = E(); 168 constexpr F f = F(); 169 170 namespace Defaulted { 171 union A { constexpr A() = default; }; 172 union B { int n; constexpr B() = default; }; 173 // cxx11-17-error@-1 {{defaulted definition of default constructor cannot be marked constexpr}} 174 union C { int n = 0; constexpr C() = default; }; 175 struct D { union {}; constexpr D() = default; }; 176 // since-cxx11-error@-1 {{declaration does not declare anything}} 177 struct E { union { int n; }; constexpr E() = default; }; 178 // cxx11-17-error@-1 {{defaulted definition of default constructor cannot be marked constexpr}} 179 struct F { union { int n = 0; }; constexpr F() = default; }; 180 181 struct G { union { int n = 0; }; union { int m; }; constexpr G() = default; }; 182 // cxx11-17-error@-1 {{defaulted definition of default constructor cannot be marked constexpr}} 183 struct H { 184 union { 185 int n = 0; 186 }; 187 union { // #cwg1460-H-union 188 int m; 189 }; 190 constexpr H() {} 191 // cxx11-17-error@-1 {{constexpr constructor that does not initialize all members is a C++20 extension}} 192 // cxx11-17-note@#cwg1460-H-union {{member not initialized by constructor}} 193 constexpr H(bool) : m(1) {} 194 constexpr H(char) : n(1) {} 195 // cxx11-17-error@-1 {{constexpr constructor that does not initialize all members is a C++20 extension}} 196 // cxx11-17-note@#cwg1460-H-union {{member not initialized by constructor}} 197 constexpr H(double) : m(1), n(1) {} 198 }; 199 } 200 201 #if __cplusplus >= 201403L 202 template<typename T> constexpr bool check() { 203 T t; // #cwg1460-t 204 return true; 205 } 206 static_assert(check<A>(), ""); 207 static_assert(check<B>(), ""); // #cwg1460-check-B 208 // cxx14-17-error@-1 {{static assertion expression is not an integral constant expression}} 209 // cxx14-17-note@#cwg1460-t {{non-constexpr constructor 'B' cannot be used in a constant expression}} 210 // cxx14-17-note@#cwg1460-check-B {{in call to 'check<cwg1460::B>()'}} 211 // cxx14-17-note@#cwg1460-B {{declared here}} 212 static_assert(check<C>(), ""); 213 static_assert(check<D>(), ""); 214 static_assert(check<E>(), ""); // #cwg1460-check-E 215 // cxx14-17-error@-1 {{static assertion expression is not an integral constant expression}} 216 // cxx14-17-note@#cwg1460-t {{non-constexpr constructor 'E' cannot be used in a constant expression}} 217 // cxx14-17-note@#cwg1460-check-E {{in call to 'check<cwg1460::E>()'}} 218 // cxx14-17-note@#cwg1460-E {{declared here}} 219 static_assert(check<F>(), ""); 220 #endif 221 222 union G { 223 int a = 0; // #cwg1460-G-a 224 int b = 0; 225 // since-cxx11-error@-1 {{initializing multiple members of union}} 226 // since-cxx11-note@#cwg1460-G-a {{previous initialization is here}} 227 }; 228 union H { 229 union { 230 int a = 0; // #cwg1460-H-a 231 }; 232 union { 233 int b = 0; 234 // since-cxx11-error@-1 {{initializing multiple members of union}} 235 // since-cxx11-note@#cwg1460-H-a {{previous initialization is here}} 236 }; 237 }; 238 struct I { 239 union { 240 int a = 0; // #cwg1460-I-a 241 int b = 0; 242 // since-cxx11-error@-1 {{initializing multiple members of union}} 243 // since-cxx11-note@#cwg1460-I-a {{previous initialization is here}} 244 }; 245 }; 246 struct J { 247 union { int a = 0; }; 248 union { int b = 0; }; 249 }; 250 251 namespace Overriding { 252 struct A { 253 int a = 1, b, c = 3; 254 constexpr A() : b(2) {} 255 }; 256 static_assert(A().a == 1 && A().b == 2 && A().c == 3, ""); 257 258 union B { 259 int a, b = 2, c; 260 constexpr B() : a(1) {} 261 constexpr B(char) : b(4) {} 262 constexpr B(int) : c(3) {} 263 constexpr B(const char*) {} 264 }; 265 static_assert(B().a == 1, ""); 266 static_assert(B().b == 2, ""); 267 // since-cxx11-error@-1 {{static assertion expression is not an integral constant expression}} 268 // since-cxx11-note@-2 {{read of member 'b' of union with active member 'a' is not allowed in a constant expression}} 269 static_assert(B('x').a == 0, ""); 270 // since-cxx11-error@-1 {{static assertion expression is not an integral constant expression}} 271 // since-cxx11-note@-2 {{read of member 'a' of union with active member 'b' is not allowed in a constant expression}} 272 static_assert(B('x').b == 4, ""); 273 static_assert(B(123).b == 2, ""); 274 // since-cxx11-error@-1 {{static assertion expression is not an integral constant expression}} 275 // since-cxx11-note@-2 {{read of member 'b' of union with active member 'c' is not allowed in a constant expression}} 276 static_assert(B(123).c == 3, ""); 277 static_assert(B("").a == 1, ""); 278 // since-cxx11-error@-1 {{static assertion expression is not an integral constant expression}} 279 // since-cxx11-note@-2 {{read of member 'a' of union with active member 'b' is not allowed in a constant expression}} 280 static_assert(B("").b == 2, ""); 281 static_assert(B("").c == 3, ""); 282 // since-cxx11-error@-1 {{static assertion expression is not an integral constant expression}} 283 // since-cxx11-note@-2 {{read of member 'c' of union with active member 'b' is not allowed in a constant expression}} 284 285 struct C { 286 union { int a, b = 2, c; }; 287 union { int d, e = 5, f; }; 288 constexpr C() : a(1) {} 289 constexpr C(char) : c(3) {} 290 constexpr C(int) : d(4) {} 291 constexpr C(float) : f(6) {} 292 constexpr C(const char*) {} 293 }; 294 295 static_assert(C().a == 1, ""); 296 static_assert(C().b == 2, ""); 297 // since-cxx11-error@-1 {{static assertion expression is not an integral constant expression}} 298 // since-cxx11-note@-2 {{read of member 'b' of union with active member 'a' is not allowed in a constant expression}} 299 static_assert(C().d == 4, ""); 300 // since-cxx11-error@-1 {{static assertion expression is not an integral constant expression}} 301 // since-cxx11-note@-2 {{read of member 'd' of union with active member 'e' is not allowed in a constant expression}} 302 static_assert(C().e == 5, ""); 303 304 static_assert(C('x').b == 2, ""); 305 // since-cxx11-error@-1 {{static assertion expression is not an integral constant expression}} 306 // since-cxx11-note@-2 {{read of member 'b' of union with active member 'c' is not allowed in a constant expression}} 307 static_assert(C('x').c == 3, ""); 308 static_assert(C('x').d == 4, ""); 309 // since-cxx11-error@-1 {{static assertion expression is not an integral constant expression}} 310 // since-cxx11-note@-2 {{read of member 'd' of union with active member 'e' is not allowed in a constant expression}} 311 static_assert(C('x').e == 5, ""); 312 313 static_assert(C(1).b == 2, ""); 314 static_assert(C(1).c == 3, ""); 315 // since-cxx11-error@-1 {{static assertion expression is not an integral constant expression}} 316 // since-cxx11-note@-2 {{read of member 'c' of union with active member 'b' is not allowed in a constant expression}} 317 static_assert(C(1).d == 4, ""); 318 static_assert(C(1).e == 5, ""); 319 // since-cxx11-error@-1 {{static assertion expression is not an integral constant expression}} 320 // since-cxx11-note@-2 {{read of member 'e' of union with active member 'd' is not allowed in a constant expression}} 321 322 static_assert(C(1.f).b == 2, ""); 323 static_assert(C(1.f).c == 3, ""); 324 // since-cxx11-error@-1 {{static assertion expression is not an integral constant expression}} 325 // since-cxx11-note@-2 {{read of member 'c' of union with active member 'b' is not allowed in a constant expression}} 326 static_assert(C(1.f).e == 5, ""); 327 // since-cxx11-error@-1 {{static assertion expression is not an integral constant expression}} 328 // since-cxx11-note@-2 {{read of member 'e' of union with active member 'f' is not allowed in a constant expression}} 329 static_assert(C(1.f).f == 6, ""); 330 331 static_assert(C("").a == 1, ""); 332 // since-cxx11-error@-1 {{static assertion expression is not an integral constant expression}} 333 // since-cxx11-note@-2 {{read of member 'a' of union with active member 'b' is not allowed in a constant expression}} 334 static_assert(C("").b == 2, ""); 335 static_assert(C("").c == 3, ""); 336 // since-cxx11-error@-1 {{static assertion expression is not an integral constant expression}} 337 // since-cxx11-note@-2 {{read of member 'c' of union with active member 'b' is not allowed in a constant expression}} 338 static_assert(C("").d == 4, ""); 339 // since-cxx11-error@-1 {{static assertion expression is not an integral constant expression}} 340 // since-cxx11-note@-2 {{read of member 'd' of union with active member 'e' is not allowed in a constant expression}} 341 static_assert(C("").e == 5, ""); 342 static_assert(C("").f == 6, ""); 343 // since-cxx11-error@-1 {{static assertion expression is not an integral constant expression}} 344 // since-cxx11-note@-2 {{read of member 'f' of union with active member 'e' is not allowed in a constant expression}} 345 346 struct D; 347 extern const D d; 348 struct D { 349 int a; 350 union { 351 int b = const_cast<D&>(d).a = 1; // not evaluated 352 int c; 353 }; 354 constexpr D() : a(0), c(0) {} 355 }; 356 constexpr D d {}; 357 static_assert(d.a == 0, ""); 358 } 359 #endif 360 } // namespace cwg1460 361 362 #if __cplusplus >= 201103L 363 namespace std { 364 typedef decltype(sizeof(int)) size_t; 365 366 // libc++'s implementation 367 template <class _E> 368 class initializer_list 369 { 370 const _E* __begin_; 371 size_t __size_; 372 373 initializer_list(const _E* __b, size_t __s) 374 : __begin_(__b), __size_(__s) {} 375 376 public: 377 typedef _E value_type; 378 typedef const _E& reference; 379 typedef const _E& const_reference; 380 typedef size_t size_type; 381 382 typedef const _E* iterator; 383 typedef const _E* const_iterator; 384 385 initializer_list() : __begin_(nullptr), __size_(0) {} 386 387 size_t size() const {return __size_;} 388 const _E* begin() const {return __begin_;} 389 const _E* end() const {return __begin_ + __size_;} 390 }; 391 } // namespace std 392 #endif 393 394 namespace cwg1467 { // cwg1467: 3.7 c++11 395 #if __cplusplus >= 201103L 396 // Note that the change to [over.best.ics] was partially undone by CWG2076; 397 // the resulting rule is tested with the tests for that change. 398 399 // List-initialization of aggregate from same-type object 400 401 namespace basic0 { 402 struct S { 403 int i = 42; 404 }; 405 406 S a; 407 S b(a); 408 S c{a}; 409 410 struct SS : public S { } x; 411 S y(x); 412 S z{x}; 413 } // basic0 414 415 namespace basic1 { 416 struct S { 417 int i{42}; 418 }; 419 420 S a; 421 S b(a); 422 S c{a}; 423 424 struct SS : public S { } x; 425 S y(x); 426 S z{x}; 427 } // basic1 428 429 namespace basic2 { 430 struct S { 431 int i = {42}; 432 }; 433 434 S a; 435 S b(a); 436 S c{a}; 437 438 struct SS : public S { } x; 439 S y(x); 440 S z{x}; 441 } // basic2 442 443 namespace dr_example { 444 struct OK { 445 OK() = default; 446 OK(const OK&) = default; 447 OK(int) { } 448 }; 449 450 OK ok; 451 OK ok2{ok}; 452 453 struct X { 454 X() = default; 455 X(const X&) = default; 456 }; 457 458 X x; 459 X x2{x}; 460 461 void f1(int); // #cwg1467-f1 462 void f1(std::initializer_list<long>) = delete; // #cwg1467-f1-deleted 463 void g1() { f1({42}); } 464 // since-cxx11-error@-1 {{call to deleted function 'f1'}} 465 // since-cxx11-note@#cwg1467-f1 {{candidate function}} 466 // since-cxx11-note@#cwg1467-f1-deleted {{candidate function has been explicitly deleted}} 467 468 template <class T, class U> 469 struct Pair { 470 Pair(T, U); 471 }; 472 struct String { 473 String(const char *); 474 }; 475 476 void f2(Pair<const char *, const char *>); // #cwg1467-f2 477 void f2(std::initializer_list<String>) = delete; // #cwg1467-f2-deleted 478 void g2() { f2({"foo", "bar"}); } 479 // since-cxx11-error@-1 {{call to deleted function 'f2'}} 480 // since-cxx11-note@#cwg1467-f2 {{candidate function}} 481 // since-cxx11-note@#cwg1467-f2-deleted {{candidate function has been explicitly deleted}} 482 } // dr_example 483 484 namespace nonaggregate { 485 struct NonAggregate { 486 NonAggregate() {} 487 }; 488 489 struct WantsIt { 490 WantsIt(NonAggregate); 491 }; 492 493 void f(NonAggregate); 494 void f(WantsIt); 495 496 void test1() { 497 NonAggregate n; 498 f({n}); 499 } 500 501 void test2() { 502 NonAggregate x; 503 NonAggregate y{x}; 504 NonAggregate z{{x}}; 505 } 506 } // nonaggregate 507 508 struct NestedInit { int a, b, c; }; 509 NestedInit ni[1] = {{NestedInit{1, 2, 3}}}; 510 511 namespace NestedInit2 { 512 struct Pair { int a, b; }; 513 struct TwoPairs { TwoPairs(Pair, Pair); }; 514 struct Value { Value(Pair); Value(TwoPairs); }; 515 void f() { Value{{{1,2},{3,4}}}; } 516 } 517 namespace NonAmbiguous { 518 // The original implementation made this case ambiguous due to the special 519 // handling of one element initialization lists. 520 void f(int(&&)[1]); 521 void f(unsigned(&&)[1]); 522 523 void g(unsigned i) { 524 f({i}); 525 } 526 } // namespace NonAmbiguous 527 528 namespace StringLiterals { 529 // When the array size is 4 the call will attempt to bind an lvalue to an 530 // rvalue and fail. Therefore #2 will be called. (rsmith will bring this 531 // issue to CWG) 532 void f(const char(&&)[4]); // #cwg1467-f-char-4 533 void f(const char(&&)[5]) = delete; // #cwg1467-f-char-5 534 void f(const wchar_t(&&)[4]); // #cwg1467-f-wchar-4 535 void f(const wchar_t(&&)[5]) = delete; // #cwg1467-f-wchar-5 536 #if __cplusplus >= 202002L 537 void f2(const char8_t(&&)[4]); // #cwg1467-f2-char8-4 538 void f2(const char8_t(&&)[5]) = delete; // #cwg1467-f2-char8-5 539 #endif 540 void f(const char16_t(&&)[4]); // #cwg1467-f-char16-4 541 void f(const char16_t(&&)[5]) = delete; // #cwg1467-f-char16-5 542 void f(const char32_t(&&)[4]); // #cwg1467-f-char32-4 543 void f(const char32_t(&&)[5]) = delete; // #cwg1467-f-char32-5 544 void g() { 545 f({"abc"}); 546 // since-cxx11-error@-1 {{call to deleted function 'f'}} 547 // since-cxx11-note@#cwg1467-f-char-5 {{candidate function has been explicitly deleted}} 548 // since-cxx11-note@#cwg1467-f-char-4 {{candidate function not viable: expects an rvalue for 1st argument}} 549 // since-cxx11-note@#cwg1467-f-wchar-4 {{candidate function not viable: no known conversion from 'const char[4]' to 'const wchar_t' for 1st argument}} 550 // since-cxx11-note@#cwg1467-f-wchar-5 {{candidate function not viable: no known conversion from 'const char[4]' to 'const wchar_t' for 1st argument}} 551 // since-cxx11-note@#cwg1467-f-char16-4 {{candidate function not viable: no known conversion from 'const char[4]' to 'const char16_t' for 1st argument}} 552 // since-cxx11-note@#cwg1467-f-char16-5 {{candidate function not viable: no known conversion from 'const char[4]' to 'const char16_t' for 1st argument}} 553 // since-cxx11-note@#cwg1467-f-char32-4 {{candidate function not viable: no known conversion from 'const char[4]' to 'const char32_t' for 1st argument}} 554 // since-cxx11-note@#cwg1467-f-char32-5 {{candidate function not viable: no known conversion from 'const char[4]' to 'const char32_t' for 1st argument}} 555 f({((("abc")))}); 556 // since-cxx11-error@-1 {{call to deleted function 'f'}} 557 // since-cxx11-note@#cwg1467-f-char-5 {{candidate function has been explicitly deleted}} 558 // since-cxx11-note@#cwg1467-f-char-4 {{candidate function not viable: expects an rvalue for 1st argument}} 559 // since-cxx11-note@#cwg1467-f-wchar-4 {{candidate function not viable: no known conversion from 'const char[4]' to 'const wchar_t' for 1st argument}} 560 // since-cxx11-note@#cwg1467-f-wchar-5 {{candidate function not viable: no known conversion from 'const char[4]' to 'const wchar_t' for 1st argument}} 561 // since-cxx11-note@#cwg1467-f-char16-4 {{candidate function not viable: no known conversion from 'const char[4]' to 'const char16_t' for 1st argument}} 562 // since-cxx11-note@#cwg1467-f-char16-5 {{candidate function not viable: no known conversion from 'const char[4]' to 'const char16_t' for 1st argument}} 563 // since-cxx11-note@#cwg1467-f-char32-4 {{candidate function not viable: no known conversion from 'const char[4]' to 'const char32_t' for 1st argument}} 564 // since-cxx11-note@#cwg1467-f-char32-5 {{candidate function not viable: no known conversion from 'const char[4]' to 'const char32_t' for 1st argument}} 565 f({L"abc"}); 566 // since-cxx11-error@-1 {{call to deleted function 'f'}} 567 // since-cxx11-note@#cwg1467-f-wchar-5 {{candidate function has been explicitly deleted}} 568 // since-cxx11-note@#cwg1467-f-char-4 {{candidate function not viable: no known conversion from 'const wchar_t[4]' to 'const char' for 1st argument}} 569 // since-cxx11-note@#cwg1467-f-char-5 {{candidate function not viable: no known conversion from 'const wchar_t[4]' to 'const char' for 1st argument}} 570 // since-cxx11-note@#cwg1467-f-wchar-4 {{candidate function not viable: expects an rvalue for 1st argument}} 571 // since-cxx11-note@#cwg1467-f-char16-4 {{candidate function not viable: no known conversion from 'const wchar_t[4]' to 'const char16_t' for 1st argument}} 572 // since-cxx11-note@#cwg1467-f-char16-5 {{candidate function not viable: no known conversion from 'const wchar_t[4]' to 'const char16_t' for 1st argument}} 573 // since-cxx11-note@#cwg1467-f-char32-4 {{candidate function not viable: no known conversion from 'const wchar_t[4]' to 'const char32_t' for 1st argument}} 574 // since-cxx11-note@#cwg1467-f-char32-5 {{candidate function not viable: no known conversion from 'const wchar_t[4]' to 'const char32_t' for 1st argument}} 575 #if __cplusplus >= 202002L 576 f2({u8"abc"}); 577 // since-cxx20-error@-1 {{call to deleted function 'f2'}} 578 // since-cxx20-note@#cwg1467-f2-char8-5 {{candidate function has been explicitly deleted}} 579 // since-cxx20-note@#cwg1467-f2-char8-4 {{candidate function not viable: expects an rvalue for 1st argument}} 580 #endif 581 f({uR"(abc)"}); 582 // since-cxx11-error@-1 {{call to deleted function 'f'}} 583 // since-cxx11-note@#cwg1467-f-char16-5 {{candidate function has been explicitly deleted}} 584 // since-cxx11-note@#cwg1467-f-char-4 {{candidate function not viable: no known conversion from 'const char16_t[4]' to 'const char' for 1st argument}} 585 // since-cxx11-note@#cwg1467-f-char-5 {{candidate function not viable: no known conversion from 'const char16_t[4]' to 'const char' for 1st argument}} 586 // since-cxx11-note@#cwg1467-f-wchar-4 {{candidate function not viable: no known conversion from 'const char16_t[4]' to 'const wchar_t' for 1st argument}} 587 // since-cxx11-note@#cwg1467-f-wchar-5 {{candidate function not viable: no known conversion from 'const char16_t[4]' to 'const wchar_t' for 1st argument}} 588 // since-cxx11-note@#cwg1467-f-char16-4 {{candidate function not viable: expects an rvalue for 1st argument}} 589 // since-cxx11-note@#cwg1467-f-char32-4 {{candidate function not viable: no known conversion from 'const char16_t[4]' to 'const char32_t' for 1st argument}} 590 // since-cxx11-note@#cwg1467-f-char32-5 {{candidate function not viable: no known conversion from 'const char16_t[4]' to 'const char32_t' for 1st argument}} 591 f({(UR"(abc)")}); 592 // since-cxx11-error@-1 {{call to deleted function 'f'}} 593 // since-cxx11-note@#cwg1467-f-char32-5 {{candidate function has been explicitly deleted}} 594 // since-cxx11-note@#cwg1467-f-char-4 {{candidate function not viable: no known conversion from 'const char32_t[4]' to 'const char' for 1st argument}} 595 // since-cxx11-note@#cwg1467-f-char-5 {{candidate function not viable: no known conversion from 'const char32_t[4]' to 'const char' for 1st argument}} 596 // since-cxx11-note@#cwg1467-f-wchar-4 {{candidate function not viable: no known conversion from 'const char32_t[4]' to 'const wchar_t' for 1st argument}} 597 // since-cxx11-note@#cwg1467-f-wchar-5 {{candidate function not viable: no known conversion from 'const char32_t[4]' to 'const wchar_t' for 1st argument}} 598 // since-cxx11-note@#cwg1467-f-char16-4 {{candidate function not viable: no known conversion from 'const char32_t[4]' to 'const char16_t' for 1st argument}} 599 // since-cxx11-note@#cwg1467-f-char16-5 {{candidate function not viable: no known conversion from 'const char32_t[4]' to 'const char16_t' for 1st argument}} 600 // since-cxx11-note@#cwg1467-f-char32-4 {{candidate function not viable: expects an rvalue for 1st argument}} 601 } 602 } // namespace StringLiterals 603 #endif 604 } // namespace cwg1467 605 606 namespace cwg1477 { // cwg1477: 2.7 607 namespace N { 608 struct A { 609 // Name "f" is not bound in N, 610 // so single searches of 'f' in N won't find it, 611 // but the targets scope of this declaration is N, 612 // making it nominable in N. 613 // (_N4988_.[dcl.meaning]/2.1, [basic.scope.scope]/7, 614 // [basic.lookup.general]/3) 615 friend int f(); 616 }; 617 } 618 // Corresponds to the friend declaration, 619 // because it's nominable in N, 620 // and binds name 'f' in N. 621 // (_N4988_.[dcl.meaning]/3.4, [basic.scope.scope]/2.5) 622 int N::f() { return 0; } 623 // Name 'f' is bound in N, 624 // so the search performed by qualified lookup finds it. 625 int i = N::f(); 626 } // namespace cwg1477 627 628 namespace cwg1479 { // cwg1479: 3.1 629 #if __cplusplus >= 201103L 630 int operator""_a(const char*, std::size_t = 0); 631 // since-cxx11-error@-1 {{literal operator cannot have a default argument}} 632 #endif 633 } // namespace cwg1479 634 635 namespace cwg1482 { // cwg1482: 3.0 636 // NB: sup 2516, test reused there 637 #if __cplusplus >= 201103L 638 template <typename T> struct S { 639 typedef char I; 640 }; 641 enum E2 : S<E2>::I { e }; 642 // since-cxx11-error@-1 {{use of undeclared identifier 'E2'}} 643 #endif 644 } // namespace cwg1482 645 646 namespace cwg1487 { // cwg1487: 3.3 647 #if __cplusplus >= 201103L 648 struct A { // #cwg1482-A 649 struct B { 650 using A::A; 651 // since-cxx11-error@-1 {{using declaration refers into 'A::', which is not a base class of 'B'}} 652 }; 653 654 struct C : A { 655 // since-cxx11-error@-1 {{base class has incomplete type}} 656 // since-cxx11-note@#cwg1482-A {{definition of 'cwg1487::A' is not complete until the closing '}'}} 657 using A::A; 658 // since-cxx11-error@-1 {{using declaration refers into 'A::', which is not a base class of 'C'}} 659 }; 660 661 struct D; 662 }; 663 664 struct D : A { 665 using A::A; 666 }; 667 #endif 668 } // namespace cwg1487 669 670 namespace cwg1490 { // cwg1490: 3.7 c++11 671 #if __cplusplus >= 201103L 672 // List-initialization from a string literal 673 674 char s[4]{"abc"}; // Ok 675 std::initializer_list<char>{"abc"}; 676 // since-cxx11-error@-1 {{expected unqualified-id}}} 677 #endif 678 } // namespace cwg1490 679 680 namespace cwg1495 { // cwg1495: 4 681 #if __cplusplus >= 201103L 682 // Deduction succeeds in both directions. 683 template<typename T, typename U> struct A {}; // #cwg1495-A 684 template<typename T, typename U> struct A<U, T> {}; 685 // since-cxx11-error@-1 {{class template partial specialization is not more specialized than the primary template}} 686 // since-cxx11-note@#cwg1495-A {{template is declared here}} 687 688 // Primary template is more specialized. 689 template<typename, typename...> struct B {}; // #cwg1495-B 690 template<typename ...Ts> struct B<Ts...> {}; 691 // since-cxx11-error@-1 {{class template partial specialization is not more specialized than the primary template}} 692 // since-cxx11-note@#cwg1495-B {{template is declared here}} 693 694 // Deduction fails in both directions. 695 template<int, typename, typename ...> struct C {}; // #cwg1495-C 696 template<typename ...Ts> struct C<0, Ts...> {}; 697 // since-cxx11-error@-1 {{class template partial specialization is not more specialized than the primary template}} 698 // since-cxx11-note@#cwg1495-C {{template is declared here}} 699 700 #if __cplusplus >= 201402L 701 // Deduction succeeds in both directions. 702 template<typename T, typename U> int a; // #cwg1495-a 703 template<typename T, typename U> int a<U, T>; 704 // since-cxx14-error@-1 {{variable template partial specialization is not more specialized than the primary template}} 705 // since-cxx14-note@#cwg1495-a {{template is declared here}} 706 707 // Primary template is more specialized. 708 template<typename, typename...> int b; // #cwg1495-b 709 template<typename ...Ts> int b<Ts...>; 710 // since-cxx14-error@-1 {{variable template partial specialization is not more specialized than the primary template}} 711 // since-cxx14-note@#cwg1495-b {{template is declared here}} 712 713 // Deduction fails in both directions. 714 template<int, typename, typename ...> int c; // #cwg1495-c 715 template<typename ...Ts> int c<0, Ts...>; 716 // since-cxx14-error@-1 {{variable template partial specialization is not more specialized than the primary template}} 717 // since-cxx14-note@#cwg1495-c {{template is declared here}} 718 #endif 719 #endif 720 } // namespace cwg1495 721 722 namespace cwg1496 { // cwg1496: no 723 #if __cplusplus >= 201103L 724 struct A { 725 A() = delete; 726 }; 727 // FIXME: 'A' should not be trivial because the class lacks at least one 728 // default constructor which is not deleted. 729 static_assert(__is_trivial(A), ""); 730 #endif 731 } // namespace cwg1496 732