// RUN: %clang_cc1 -std=c++20 -fsyntax-only -verify -Wno-strict-prototypes %s // RUN: %clang_cc1 -x c -fsyntax-only -verify -Wno-strict-prototypes %s int x __attribute__((constructor)); // expected-warning {{'constructor' attribute only applies to functions}} int f(void) __attribute__((constructor)); int f(void) __attribute__((constructor(1))); int f(void) __attribute__((constructor(1,2))); // expected-error {{'constructor' attribute takes no more than 1 argument}} int f(void) __attribute__((constructor(1.0))); // expected-error {{'constructor' attribute requires an integer constant}} int f(void) __attribute__((constructor(0x100000000))); // expected-error {{integer constant expression evaluates to value 4294967296 that cannot be represented in a 32-bit unsigned integer type}} void knr() __attribute__((constructor)); #ifdef __cplusplus template [[gnu::constructor(P)]] void f(); // expected-error {{'gnu::constructor' attribute requires an integer constant}} template [[gnu::constructor(P)]] void f(); // expected-error {{'gnu::constructor' attribute requires an integer constant}} template [[gnu::constructor(P)]] void f(); // expected-error {{'gnu::constructor' attribute requires an integer constant}} template [[gnu::constructor(P)]] void f() {} // expected-error {{integer constant expression evaluates to value 4294967296 that cannot be represented in a 32-bit unsigned integer type}} template void f<1LL<<32>(); // expected-note {{in instantiation of function template specialization 'f<4294967296LL>' requested here}} template void f<101>(); template [[gnu::constructor(static_cast(1LL<<32))]] void f() {} // expected-error {{integer constant expression evaluates to value 4294967296 that cannot be represented in a 32-bit unsigned integer type}} template void f(); // expected-note {{in instantiation of function template specialization 'f' requested here}} template void f(); template [[gnu::constructor(static_cast(101))]] void g() {} template void g(); template void g(); template [[gnu::constructor(static_cast(T{101}))]] void h() {} template void h(); template void h(); template [[gnu::constructor(static_cast(sizeof(T[101])))]] void a() {} template void a(); template void a(); #endif int yd __attribute__((destructor)); // expected-warning {{'destructor' attribute only applies to functions}} int fd(void) __attribute__((destructor)); int fd(void) __attribute__((destructor(1))); int fd(void) __attribute__((destructor(1,2))); // expected-error {{'destructor' attribute takes no more than 1 argument}} int fd(void) __attribute__((destructor(1.0))); // expected-error {{'destructor' attribute requires an integer constant}} #ifdef __cplusplus template [[gnu::destructor(P)]] void fd(); // expected-error {{'gnu::destructor' attribute requires an integer constant}} template [[gnu::destructor(P)]] void fd(); // expected-error {{'gnu::destructor' attribute requires an integer constant}} template [[gnu::destructor(P)]] void fd(); // expected-error {{'gnu::destructor' attribute requires an integer constant}} template [[gnu::destructor(P)]] void fd() {} // expected-error {{integer constant expression evaluates to value 4294967296 that cannot be represented in a 32-bit unsigned integer type}} template void fd<1LL<<32>(); // expected-note {{in instantiation of function template specialization 'fd<4294967296LL>' requested here}} template void fd<101>(); template [[gnu::destructor(static_cast(1LL<<32))]] void fd() {} // expected-error {{integer constant expression evaluates to value 4294967296 that cannot be represented in a 32-bit unsigned integer type}} template void fd(); // expected-note {{in instantiation of function template specialization 'fd' requested here}} template void fd(); template [[gnu::destructor(static_cast(101))]] void gd() {} template void gd(); template void gd(); template [[gnu::destructor(static_cast(T{101}))]] void hd() {} template void hd(); template void hd(); template [[gnu::destructor(static_cast(sizeof(T[101])))]] void ad() {} template void ad(); template void ad(); #endif