1*aa53785fSArthur Eubanks // RUN: %clang_cc1 -verify=expected,enabled -emit-codegen-only %s 2*aa53785fSArthur Eubanks // RUN: %clang_cc1 -verify -emit-codegen-only -Wno-attribute-warning %s 3*aa53785fSArthur Eubanks 4*aa53785fSArthur Eubanks __attribute__((error("oh no foo"))) void foo(void); 5*aa53785fSArthur Eubanks 6*aa53785fSArthur Eubanks __attribute__((error("oh no bar"))) void bar(void); 7*aa53785fSArthur Eubanks 8*aa53785fSArthur Eubanks int x(void) { 9*aa53785fSArthur Eubanks return 8 % 2 == 1; 10*aa53785fSArthur Eubanks } 11*aa53785fSArthur Eubanks 12*aa53785fSArthur Eubanks __attribute__((warning("oh no quux"))) void quux(void); 13*aa53785fSArthur Eubanks 14*aa53785fSArthur Eubanks __attribute__((error("demangle me"))) void __compiletime_assert_455(void); 15*aa53785fSArthur Eubanks 16*aa53785fSArthur Eubanks __attribute__((error("one"), error("two"))) // expected-warning {{attribute 'error' is already applied with different arguments}} 17*aa53785fSArthur Eubanks void // expected-note@-1 {{previous attribute is here}} 18*aa53785fSArthur Eubanks duplicate_errors(void); 19*aa53785fSArthur Eubanks 20*aa53785fSArthur Eubanks __attribute__((warning("one"), warning("two"))) // expected-warning {{attribute 'warning' is already applied with different arguments}} 21*aa53785fSArthur Eubanks void // expected-note@-1 {{previous attribute is here}} 22*aa53785fSArthur Eubanks duplicate_warnings(void); 23*aa53785fSArthur Eubanks 24*aa53785fSArthur Eubanks void baz(void) { 25*aa53785fSArthur Eubanks foo(); // expected-error {{call to foo() declared with 'error' attribute: oh no foo}} 26*aa53785fSArthur Eubanks if (x()) 27*aa53785fSArthur Eubanks bar(); // expected-error {{call to bar() declared with 'error' attribute: oh no bar}} 28*aa53785fSArthur Eubanks 29*aa53785fSArthur Eubanks quux(); // enabled-warning {{call to quux() declared with 'warning' attribute: oh no quux}} 30*aa53785fSArthur Eubanks __compiletime_assert_455(); // expected-error {{call to __compiletime_assert_455() declared with 'error' attribute: demangle me}} 31*aa53785fSArthur Eubanks duplicate_errors(); // expected-error {{call to duplicate_errors() declared with 'error' attribute: two}} 32*aa53785fSArthur Eubanks duplicate_warnings(); // enabled-warning {{call to duplicate_warnings() declared with 'warning' attribute: two}} 33*aa53785fSArthur Eubanks } 34*aa53785fSArthur Eubanks 35*aa53785fSArthur Eubanks #ifdef __cplusplus 36*aa53785fSArthur Eubanks template <typename T> 37*aa53785fSArthur Eubanks __attribute__((error("demangle me, too"))) 38*aa53785fSArthur Eubanks T 39*aa53785fSArthur Eubanks nocall(T t); 40*aa53785fSArthur Eubanks 41*aa53785fSArthur Eubanks struct Widget { 42*aa53785fSArthur Eubanks __attribute__((warning("don't call me!"))) 43*aa53785fSArthur Eubanks operator int() { return 42; } 44*aa53785fSArthur Eubanks }; 45*aa53785fSArthur Eubanks 46*aa53785fSArthur Eubanks void baz_cpp(void) { 47*aa53785fSArthur Eubanks foo(); // expected-error {{call to foo() declared with 'error' attribute: oh no foo}} 48*aa53785fSArthur Eubanks if (x()) 49*aa53785fSArthur Eubanks bar(); // expected-error {{call to bar() declared with 'error' attribute: oh no bar}} 50*aa53785fSArthur Eubanks quux(); // enabled-warning {{call to quux() declared with 'warning' attribute: oh no quux}} 51*aa53785fSArthur Eubanks 52*aa53785fSArthur Eubanks // Test that we demangle correctly in the diagnostic for C++. 53*aa53785fSArthur Eubanks __compiletime_assert_455(); // expected-error {{call to __compiletime_assert_455() declared with 'error' attribute: demangle me}} 54*aa53785fSArthur Eubanks nocall<int>(42); // expected-error {{call to int nocall<int>(int) declared with 'error' attribute: demangle me, too}} 55*aa53785fSArthur Eubanks 56*aa53785fSArthur Eubanks Widget W; 57*aa53785fSArthur Eubanks int w = W; // enabled-warning {{Widget::operator int() declared with 'warning' attribute: don't call me!}} 58*aa53785fSArthur Eubanks } 59*aa53785fSArthur Eubanks #endif 60