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