brintos

brintos / llvm-project-archived public Read only

0
0
Text · 2.6 KiB · 1ed549c Raw
61 lines · cpp
1// REQUIRES: x86-registered-target2// RUN: %clang_cc1 -triple x86_64-linux-gnu -verify=expected,enabled -emit-codegen-only %s3// RUN: %clang_cc1 -verify -triple x86_64-linux-gnu -emit-codegen-only -Wno-attribute-warning %s4 5__attribute__((error("oh no foo"))) void foo(void);6 7__attribute__((error("oh no bar"))) void bar(void);8 9int x(void) {10  return 8 % 2 == 1;11}12 13__attribute__((warning("oh no quux"))) void quux(void);14 15__attribute__((error("demangle me"))) void __compiletime_assert_455(void);16 17__attribute__((error("one"), error("two"))) // expected-warning {{attribute 'error' is already applied with different arguments}}18void                                        // expected-note@-1 {{previous attribute is here}}19duplicate_errors(void);20 21__attribute__((warning("one"), warning("two"))) // expected-warning {{attribute 'warning' is already applied with different arguments}}22void                                            // expected-note@-1 {{previous attribute is here}}23duplicate_warnings(void);24 25void 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}}29 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}}34}35 36#ifdef __cplusplus37template <typename T>38__attribute__((error("demangle me, too")))39T40nocall(T t);41 42struct Widget {43  __attribute__((warning("don't call me!")))44  operator int() { return 42; }45};46 47void 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}}52 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}}56 57  Widget W;58  int w = W; // enabled-warning {{call to 'Widget::operator int()' declared with 'warning' attribute: don't call me!}}59}60#endif61