[ELF] Reorder SectionBase/InputSectionBase members
[llvm-project.git] / clang / test / Frontend / backend-attribute-error-warning.cpp
blob1ed549c271241ab0955e4663862a8094f4425a78
1 // REQUIRES: x86-registered-target
2 // RUN: %clang_cc1 -triple x86_64-linux-gnu -verify=expected,enabled -emit-codegen-only %s
3 // RUN: %clang_cc1 -verify -triple x86_64-linux-gnu -emit-codegen-only -Wno-attribute-warning %s
5 __attribute__((error("oh no foo"))) void foo(void);
7 __attribute__((error("oh no bar"))) void bar(void);
9 int x(void) {
10 return 8 % 2 == 1;
13 __attribute__((warning("oh no quux"))) void quux(void);
15 __attribute__((error("demangle me"))) void __compiletime_assert_455(void);
17 __attribute__((error("one"), error("two"))) // expected-warning {{attribute 'error' is already applied with different arguments}}
18 void // expected-note@-1 {{previous attribute is here}}
19 duplicate_errors(void);
21 __attribute__((warning("one"), warning("two"))) // expected-warning {{attribute 'warning' is already applied with different arguments}}
22 void // expected-note@-1 {{previous attribute is here}}
23 duplicate_warnings(void);
25 void baz(void) {
26 foo(); // expected-error {{call to 'foo()' declared with 'error' attribute: oh no foo}}
27 if (x())
28 bar(); // expected-error {{call to 'bar()' declared with 'error' attribute: oh no bar}}
30 quux(); // enabled-warning {{call to 'quux()' declared with 'warning' attribute: oh no quux}}
31 __compiletime_assert_455(); // expected-error {{call to '__compiletime_assert_455()' declared with 'error' attribute: demangle me}}
32 duplicate_errors(); // expected-error {{call to 'duplicate_errors()' declared with 'error' attribute: two}}
33 duplicate_warnings(); // enabled-warning {{call to 'duplicate_warnings()' declared with 'warning' attribute: two}}
36 #ifdef __cplusplus
37 template <typename T>
38 __attribute__((error("demangle me, too")))
40 nocall(T t);
42 struct Widget {
43 __attribute__((warning("don't call me!")))
44 operator int() { return 42; }
47 void baz_cpp(void) {
48 foo(); // expected-error {{call to 'foo()' declared with 'error' attribute: oh no foo}}
49 if (x())
50 bar(); // expected-error {{call to 'bar()' declared with 'error' attribute: oh no bar}}
51 quux(); // enabled-warning {{call to 'quux()' declared with 'warning' attribute: oh no quux}}
53 // Test that we demangle correctly in the diagnostic for C++.
54 __compiletime_assert_455(); // expected-error {{call to '__compiletime_assert_455()' declared with 'error' attribute: demangle me}}
55 nocall<int>(42); // expected-error {{call to 'int nocall<int>(int)' declared with 'error' attribute: demangle me, too}}
57 Widget W;
58 int w = W; // enabled-warning {{call to 'Widget::operator int()' declared with 'warning' attribute: don't call me!}}
60 #endif