brintos

brintos / llvm-project-archived public Read only

0
0
Text · 1.1 KiB · 6b92297 Raw
26 lines · c
1// RUN: %clang_cc1 -std=c23 %s -verify2 3// Validate that the attribute works in C.4static_assert(!__has_c_attribute(assume));5static_assert(__has_c_attribute(clang::assume));6static_assert(__has_attribute(assume));7 8void test(int n) {9  // Smoke test.10  __attribute__((assume(true)));11  [[clang::assume(true)]];12 13  // Test diagnostics14  __attribute__((assume));    // expected-error {{'assume' attribute takes one argument}}15  __attribute__((assume()));  // expected-error {{expected expression}}16  [[clang::assume]];          // expected-error {{'assume' attribute takes one argument}}17  [[clang::assume()]];        // expected-error {{expected expression}}18 19  __attribute__((assume(n++))); // expected-warning {{assumption is ignored because it contains (potential) side-effects}}20  [[clang::assume(n++)]];       // expected-warning {{assumption is ignored because it contains (potential) side-effects}}21 22  [[clang::assume(true)]] int x;       // expected-error {{'clang::assume' attribute cannot be applied to a declaration}}23  __attribute__((assume(true))) int y; // expected-error {{'assume' attribute cannot be applied to a declaration}}24}25 26