18 lines · cpp
1// RUN: %clang_cc1 -std=c++20 -fexperimental-new-constant-interpreter -verify=expected,both %s2// RUN: %clang_cc1 -std=c++20 -verify=ref,both %s3 4[[gnu::weak]] extern int a;5int ha[(bool)&a]; // both-warning {{variable length arrays in C++ are a Clang extension}} \6 // both-error {{variable length array declaration not allowed at file scope}}7int ha2[&a == nullptr]; // both-warning {{variable length arrays in C++ are a Clang extension}} \8 // both-note {{comparison against address of weak declaration '&a' can only be performed at runtime}} \9 // both-error {{variable length array declaration not allowed at file scope}}10 11extern const int W1 __attribute__((weak)) = 10; // both-note {{declared here}}12static_assert(W1 == 10, ""); // both-error {{static assertion expression is not an integral constant expression}} \13 // both-note {{initializer of weak variable 'W1' is not considered constant because it may be different at runtime}}14 15extern const int W2 __attribute__((weak)); // both-note {{declared here}}16static_assert(W2 == 10, ""); // both-error {{static assertion expression is not an integral constant expression}} \17 // both-note {{initializer of 'W2' is unknown}}18