xref: /llvm-project/clang/test/Frontend/backend-attribute-error-warning.c (revision e588d23a91fd28cd4218995a33c2a46fe721ff62)
1 // RUN: %clang_cc1 -verify=expected,enabled -emit-codegen-only %s
2 // RUN: %clang_cc1 -verify -emit-codegen-only -Wno-attribute-warning %s
3 
4 __attribute__((error("oh no foo"))) void foo(void);
5 
6 __attribute__((error("oh no bar"))) void bar(void);
7 
x(void)8 int x(void) {
9   return 8 % 2 == 1;
10 }
11 
12 __attribute__((warning("oh no quux"))) void quux(void);
13 
14 __attribute__((error("demangle me"))) void __compiletime_assert_455(void);
15 
16 __attribute__((error("one"), error("two"))) // expected-warning {{attribute 'error' is already applied with different arguments}}
17 void                                        // expected-note@-1 {{previous attribute is here}}
18 duplicate_errors(void);
19 
20 __attribute__((warning("one"), warning("two"))) // expected-warning {{attribute 'warning' is already applied with different arguments}}
21 void                                            // expected-note@-1 {{previous attribute is here}}
22 duplicate_warnings(void);
23 
baz(void)24 void baz(void) {
25   foo(); // expected-error {{call to 'foo' declared with 'error' attribute: oh no foo}}
26   if (x())
27     bar(); // expected-error {{call to 'bar' declared with 'error' attribute: oh no bar}}
28 
29   quux();                     // enabled-warning {{call to 'quux' declared with 'warning' attribute: oh no quux}}
30   __compiletime_assert_455(); // expected-error {{call to '__compiletime_assert_455' declared with 'error' attribute: demangle me}}
31   duplicate_errors();         // expected-error {{call to 'duplicate_errors' declared with 'error' attribute: two}}
32   duplicate_warnings();       // enabled-warning {{call to 'duplicate_warnings' declared with 'warning' attribute: two}}
33 }
34