150
|
1 // RUN: %clang_cc1 -triple x86_64-unknown-unknown -fsyntax-only -verify %s
|
|
2 // UNSUPPORTED: ppc64be
|
|
3
|
|
4 /// Prevent use of all builtins.
|
|
5 void valid_attribute_all_1() __attribute__((no_builtin)) {}
|
|
6 void valid_attribute_all_2() __attribute__((no_builtin())) {}
|
|
7
|
|
8 /// Prevent use of specific builtins.
|
|
9 void valid_attribute_function() __attribute__((no_builtin("memcpy"))) {}
|
|
10 void valid_attribute_functions() __attribute__((no_builtin("memcpy"))) __attribute__((no_builtin("memcmp"))) {}
|
|
11
|
|
12 /// Many times the same builtin is fine.
|
|
13 void many_attribute_function_1() __attribute__((no_builtin)) __attribute__((no_builtin)) {}
|
|
14 void many_attribute_function_2() __attribute__((no_builtin("memcpy"))) __attribute__((no_builtin("memcpy"))) {}
|
|
15 void many_attribute_function_3() __attribute__((no_builtin("memcpy", "memcpy"))) {}
|
|
16 void many_attribute_function_4() __attribute__((no_builtin("memcpy", "memcpy"))) __attribute__((no_builtin("memcpy"))) {}
|
|
17
|
|
18 /// Invalid builtin name.
|
|
19 void invalid_builtin() __attribute__((no_builtin("not_a_builtin"))) {}
|
173
|
20 // expected-warning@-1 {{'not_a_builtin' is not a valid builtin name for 'no_builtin'}}
|
150
|
21
|
|
22 /// Can't use bare no_builtin with a named one.
|
|
23 void wildcard_and_functionname() __attribute__((no_builtin)) __attribute__((no_builtin("memcpy"))) {}
|
173
|
24 // expected-error@-1 {{empty 'no_builtin' cannot be composed with named ones}}
|
150
|
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.
|
|
50 void 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}}
|