1 // RUN: %clang_cc1 -triple x86_64-unknown-unknown -fsyntax-only -verify %s 2 // UNSUPPORTED: ppc64be 3 4 /// Prevent use of all builtins. valid_attribute_all_1()5void valid_attribute_all_1() __attribute__((no_builtin)) {} valid_attribute_all_2()6void valid_attribute_all_2() __attribute__((no_builtin())) {} 7 8 /// Prevent use of specific builtins. valid_attribute_function()9void valid_attribute_function() __attribute__((no_builtin("memcpy"))) {} valid_attribute_functions()10void valid_attribute_functions() __attribute__((no_builtin("memcpy"))) __attribute__((no_builtin("memcmp"))) {} 11 12 /// Many times the same builtin is fine. many_attribute_function_1()13void many_attribute_function_1() __attribute__((no_builtin)) __attribute__((no_builtin)) {} many_attribute_function_2()14void many_attribute_function_2() __attribute__((no_builtin("memcpy"))) __attribute__((no_builtin("memcpy"))) {} many_attribute_function_3()15void many_attribute_function_3() __attribute__((no_builtin("memcpy", "memcpy"))) {} many_attribute_function_4()16void many_attribute_function_4() __attribute__((no_builtin("memcpy", "memcpy"))) __attribute__((no_builtin("memcpy"))) {} 17 18 /// Invalid builtin name. invalid_builtin()19void invalid_builtin() __attribute__((no_builtin("not_a_builtin"))) {} 20 // expected-warning@-1 {{'not_a_builtin' is not a valid builtin name for 'no_builtin'}} 21 22 /// Can't use bare no_builtin with a named one. wildcard_and_functionname()23void wildcard_and_functionname() __attribute__((no_builtin)) __attribute__((no_builtin("memcpy"))) {} 24 // expected-error@-1 {{empty 'no_builtin' cannot be composed with named ones}} 25 26 /// Can't attach attribute to a variable. 27 int __attribute__((no_builtin)) variable; 28 // expected-warning@-1 {{'no_builtin' attribute only applies to functions}} 29 30 /// Can't attach attribute to a declaration. 31 void nobuiltin_on_declaration() __attribute__((no_builtin)); 32 // expected-error@-1 {{no_builtin attribute is permitted on definitions only}} 33 34 struct S { 35 /// Can't attach attribute to a defaulted function, 36 S() 37 __attribute__((no_builtin)) = default; 38 // expected-error@-1 {{no_builtin attribute has no effect on defaulted or deleted functions}} 39 40 /// Can't attach attribute to a deleted function, 41 S(const S &) 42 __attribute__((no_builtin)) = delete; 43 // expected-error@-1 {{no_builtin attribute has no effect on defaulted or deleted functions}} 44 45 void whatever() __attribute__((no_builtin("memcpy"))); 46 // expected-error@-1 {{no_builtin attribute is permitted on definitions only}} 47 }; 48 49 /// Can't attach attribute to an aliased function. alised_function()50void alised_function() {} 51 void aliasing_function() __attribute__((no_builtin)) __attribute__((alias("alised_function"))); 52 // expected-error@-1 {{no_builtin attribute is permitted on definitions only}} 53