brintos

brintos / llvm-project-archived public Read only

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