1 // RUN: %clang_cc1 -fsyntax-only -verify %s
3 #if !__has_extension(statement_attributes_with_gnu_syntax)
4 #error "We should have statement attributes with GNU syntax support"
9 __attribute__((unknown_attribute
)); // expected-warning {{unknown attribute 'unknown_attribute' ignored}}
11 __attribute__(()) if (0) {}
12 __attribute__(()) for (;;);
13 __attribute__(()) do {
14 __attribute__(()) continue;
18 __attribute__(()) while (0);
20 __attribute__(()) switch (i
) {
21 __attribute__(()) case 0 :
22 __attribute__(()) default :
23 __attribute__(()) break;
26 __attribute__(()) goto here
;
27 __attribute__(()) here
:
29 __attribute__(()) return;
31 __attribute__((noreturn
)) {} // expected-error {{'noreturn' attribute cannot be applied to a statement}}
32 __attribute__((noreturn
)) if (0) {} // expected-error {{'noreturn' attribute cannot be applied to a statement}}
33 __attribute__((noreturn
)) for (;;); // expected-error {{'noreturn' attribute cannot be applied to a statement}}
34 __attribute__((noreturn
)) do { // expected-error {{'noreturn' attribute cannot be applied to a statement}}
35 __attribute__((unavailable
)) continue; // expected-error {{'unavailable' attribute cannot be applied to a statement}}
39 __attribute__((unknown_attribute
)) while (0); // expected-warning {{unknown attribute 'unknown_attribute' ignored}}
41 __attribute__((unused
)) switch (i
) { // expected-error {{'unused' attribute cannot be applied to a statement}}
42 __attribute__((uuid
)) case 0: // expected-warning {{unknown attribute 'uuid' ignored}}
43 __attribute__((visibility(""))) default: // expected-error {{'visibility' attribute cannot be applied to a statement}}
44 __attribute__((carries_dependency
)) break; // expected-error {{'carries_dependency' attribute cannot be applied to a statement}}
47 __attribute__((fastcall
)) goto there
; // expected-error {{'fastcall' attribute cannot be applied to a statement}}
48 __attribute__((noinline
)) there
: // expected-warning {{'noinline' attribute only applies to functions and statements}}
50 __attribute__((weakref
)) return; // expected-error {{'weakref' attribute only applies to variables and functions}}
52 __attribute__((carries_dependency
)); // expected-error {{'carries_dependency' attribute cannot be applied to a statement}}
53 __attribute__((carries_dependency
)) {} // expected-error {{'carries_dependency' attribute cannot be applied to a statement}}
54 __attribute__((carries_dependency
)) if (0) {} // expected-error {{'carries_dependency' attribute cannot be applied to a statement}}
55 __attribute__((carries_dependency
)) for (;;); // expected-error {{'carries_dependency' attribute cannot be applied to a statement}}
56 __attribute__((carries_dependency
)) do { // expected-error {{'carries_dependency' attribute cannot be applied to a statement}}
57 __attribute__((carries_dependency
)) continue; // expected-error {{'carries_dependency' attribute cannot be applied to a statement}} ignored}}
61 __attribute__((carries_dependency
)) while (0); // expected-error {{'carries_dependency' attribute cannot be applied to a statement}}
63 __attribute__((carries_dependency
)) switch (i
) { // expected-error {{'carries_dependency' attribute cannot be applied to a statement}} ignored}}
64 __attribute__((carries_dependency
)) case 0: // expected-error {{'carries_dependency' attribute cannot be applied to a statement}}
65 __attribute__((carries_dependency
)) default: // expected-error {{'carries_dependency' attribute cannot be applied to a statement}}
66 __attribute__((carries_dependency
)) break; // expected-error {{'carries_dependency' attribute cannot be applied to a statement}}
69 __attribute__((carries_dependency
)) goto here
; // expected-error {{'carries_dependency' attribute cannot be applied to a statement}}
71 __attribute__((carries_dependency
)) return; // expected-error {{'carries_dependency' attribute cannot be applied to a statement}}
77 __attribute__((nomerge
)) bar();
78 __attribute__(()) bar(); // expected-error {{expected identifier or '('}}
79 __attribute__((unused
, nomerge
)) bar(); // expected-error {{expected identifier or '('}}
80 __attribute__((nomerge
, unused
)) bar(); // expected-error {{expected identifier or '('}}
81 __attribute__((nomerge(1, 2))) bar(); // expected-error {{'nomerge' attribute takes no arguments}}
83 __attribute__((nomerge
)) x
= 10; // expected-warning {{'nomerge' attribute is ignored because there exists no call expression inside the statement}}
85 __attribute__((nomerge
)) label
: bar(); // expected-error {{'nomerge' attribute only applies to functions, statements and variables}}
90 __attribute__((nomerge
)) static int (*fptr
)(void);
91 __attribute__((nomerge
)) static int i
; // expected-warning {{'nomerge' attribute is ignored because 'i' is not a function pointer}}
92 struct buz
{} __attribute__((nomerge
)); // expected-error {{'nomerge' attribute only applies to functions, statements and variables}}