1*a6e8b685SRichard Smith // RUN: %clang_cc1 -verify -std=c++2a -pedantic-errors %s 2b2997f57SRichard Smith // RUN: cp %s %t 3b2997f57SRichard Smith // RUN: not %clang_cc1 -x c++ -std=c++2a -fixit %t 4*a6e8b685SRichard Smith // RUN: %clang_cc1 -Wall -pedantic-errors -x c++ -std=c++2a %t 5*a6e8b685SRichard Smith // RUN: cat %t | FileCheck %s 6b2997f57SRichard Smith 7b2997f57SRichard Smith /* This is a test of the various code modification hints that only 8b2997f57SRichard Smith apply in C++2a. */ init_capture_pack(T...a)9b2997f57SRichard Smithtemplate<typename ...T> void init_capture_pack(T ...a) { 10b2997f57SRichard Smith [x... = a]{}; // expected-error {{must appear before the name}} 11b2997f57SRichard Smith [x = a...]{}; // expected-error {{must appear before the name}} 12b2997f57SRichard Smith [...&x = a]{}; // expected-error {{must appear before the name}} 13b2997f57SRichard Smith [...a]{}; // expected-error {{must appear after the name}} 14b2997f57SRichard Smith [&...a]{}; // expected-error {{must appear after the name}} 15b2997f57SRichard Smith [...&a]{}; // expected-error {{must appear after the name}} 16b2997f57SRichard Smith } 17*a6e8b685SRichard Smith 18*a6e8b685SRichard Smith namespace constinit_mismatch { 19*a6e8b685SRichard Smith int b = 123; // expected-note {{add the 'constinit' specifier}} 20*a6e8b685SRichard Smith extern constinit int b; // expected-error {{'constinit' specifier added after initialization of variable}} 21*a6e8b685SRichard Smith // CHECK: {{^}} extern int b; 22*a6e8b685SRichard Smith 23*a6e8b685SRichard Smith template<typename> struct X { 24*a6e8b685SRichard Smith template<int> static constinit int n; // expected-note {{constinit}} 25*a6e8b685SRichard Smith }; 26*a6e8b685SRichard Smith template<typename T> template<int N> 27*a6e8b685SRichard Smith int X<T>::n = 123; // expected-error {{missing}} 28*a6e8b685SRichard Smith // CHECK: {{^}} constinit int X<T>::n = 123; 29*a6e8b685SRichard Smith 30*a6e8b685SRichard Smith #define ABSL_CONST_INIT [[clang::require_constant_initialization]] 31*a6e8b685SRichard Smith extern constinit int c; // expected-note {{constinit}} 32*a6e8b685SRichard Smith int c; // expected-error {{missing}} 33*a6e8b685SRichard Smith // CHECK: {{^}} ABSL_CONST_INIT int c; 34*a6e8b685SRichard Smith 35*a6e8b685SRichard Smith #define MY_CONST_INIT constinit 36*a6e8b685SRichard Smith extern constinit int d; // expected-note {{constinit}} 37*a6e8b685SRichard Smith int d; // expected-error {{missing}} 38*a6e8b685SRichard Smith // CHECK: {{^}} MY_CONST_INIT int d; 39*a6e8b685SRichard Smith #undef MY_CONST_INIT 40*a6e8b685SRichard Smith 41*a6e8b685SRichard Smith extern constinit int e; // expected-note {{constinit}} 42*a6e8b685SRichard Smith int e; // expected-error {{missing}} 43*a6e8b685SRichard Smith // CHECK: {{^}} ABSL_CONST_INIT int e; 44*a6e8b685SRichard Smith #undef ABSL_CONST_INIT 45*a6e8b685SRichard Smith } 46