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