// RUN: %clang_cc1 -std=c++98 %s -verify -fexceptions -fcxx-exceptions -pedantic-errors 2>&1 | FileCheck %s // RUN: %clang_cc1 -std=c++11 %s -verify -fexceptions -fcxx-exceptions -pedantic-errors 2>&1 | FileCheck %s // RUN: %clang_cc1 -std=c++14 %s -verify -fexceptions -fcxx-exceptions -pedantic-errors 2>&1 | FileCheck %s // RUN: %clang_cc1 -std=c++17 %s -verify -fexceptions -fcxx-exceptions -pedantic-errors 2>&1 | FileCheck %s // RUN: %clang_cc1 -std=c++2a %s -verify -fexceptions -fcxx-exceptions -pedantic-errors 2>&1 | FileCheck %s #if __cplusplus <= 201103L // expected-no-diagnostics #endif namespace dr2353 { // dr2353: 9 struct X { static const int n = 0; }; // CHECK: FunctionDecl {{.*}} use int use(X x) { // CHECK: MemberExpr {{.*}} .n // CHECK-NOT: non_odr_use // CHECK: DeclRefExpr {{.*}} 'x' // CHECK-NOT: non_odr_use return *&x.n; } #pragma clang __debug dump use // CHECK: FunctionDecl {{.*}} not_use int not_use(X x) { // CHECK: MemberExpr {{.*}} .n {{.*}} non_odr_use_constant // CHECK: DeclRefExpr {{.*}} 'x' return x.n; } #pragma clang __debug dump not_use // CHECK: FunctionDecl {{.*}} not_use_2 int not_use_2(X *x) { // CHECK: MemberExpr {{.*}} ->n {{.*}} non_odr_use_constant // CHECK: DeclRefExpr {{.*}} 'x' return x->n; } #pragma clang __debug dump not_use_2 } #if __cplusplus >= 201707L // Otherwise, if the qualified-id std::tuple_size names a complete class // type **with a member value**, the expression std::tuple_size::value shall // be a well-formed integral constant expression namespace dr2386 { // dr2386: 9 struct Bad1 { int a, b; }; struct Bad2 { int a, b; }; } // namespace dr2386 namespace std { template struct tuple_size; template <> struct std::tuple_size {}; template <> struct std::tuple_size { static const int value = 42; }; } // namespace std namespace dr2386 { void no_value() { auto [x, y] = Bad1(); } void wrong_value() { auto [x, y] = Bad2(); } // expected-error {{decomposes into 42 elements}} } // namespace dr2386 #endif namespace dr2387 { // dr2387: 9 #if __cplusplus >= 201402L template int a = 0; extern template int a<0>; // ok template static int b = 0; extern template int b<0>; // expected-error {{internal linkage}} template const int c = 0; extern template const int c<0>; // ok, has external linkage despite 'const' template T d = 0; extern template int d; extern template const int d; #endif }