annotate clang/test/Sema/no-builtin.cpp @ 207:2e18cbf3894f

LLVM12
author Shinji KONO <kono@ie.u-ryukyu.ac.jp>
date Tue, 08 Jun 2021 06:07:14 +0900
parents 0572611fdcc8
children 1f2b6ac9f198
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
150
anatofuz
parents:
diff changeset
1 // RUN: %clang_cc1 -triple x86_64-unknown-unknown -fsyntax-only -verify %s
anatofuz
parents:
diff changeset
2 // UNSUPPORTED: ppc64be
anatofuz
parents:
diff changeset
3
anatofuz
parents:
diff changeset
4 /// Prevent use of all builtins.
anatofuz
parents:
diff changeset
5 void valid_attribute_all_1() __attribute__((no_builtin)) {}
anatofuz
parents:
diff changeset
6 void valid_attribute_all_2() __attribute__((no_builtin())) {}
anatofuz
parents:
diff changeset
7
anatofuz
parents:
diff changeset
8 /// Prevent use of specific builtins.
anatofuz
parents:
diff changeset
9 void valid_attribute_function() __attribute__((no_builtin("memcpy"))) {}
anatofuz
parents:
diff changeset
10 void valid_attribute_functions() __attribute__((no_builtin("memcpy"))) __attribute__((no_builtin("memcmp"))) {}
anatofuz
parents:
diff changeset
11
anatofuz
parents:
diff changeset
12 /// Many times the same builtin is fine.
anatofuz
parents:
diff changeset
13 void many_attribute_function_1() __attribute__((no_builtin)) __attribute__((no_builtin)) {}
anatofuz
parents:
diff changeset
14 void many_attribute_function_2() __attribute__((no_builtin("memcpy"))) __attribute__((no_builtin("memcpy"))) {}
anatofuz
parents:
diff changeset
15 void many_attribute_function_3() __attribute__((no_builtin("memcpy", "memcpy"))) {}
anatofuz
parents:
diff changeset
16 void many_attribute_function_4() __attribute__((no_builtin("memcpy", "memcpy"))) __attribute__((no_builtin("memcpy"))) {}
anatofuz
parents:
diff changeset
17
anatofuz
parents:
diff changeset
18 /// Invalid builtin name.
anatofuz
parents:
diff changeset
19 void invalid_builtin() __attribute__((no_builtin("not_a_builtin"))) {}
173
0572611fdcc8 reorgnization done
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 150
diff changeset
20 // expected-warning@-1 {{'not_a_builtin' is not a valid builtin name for 'no_builtin'}}
150
anatofuz
parents:
diff changeset
21
anatofuz
parents:
diff changeset
22 /// Can't use bare no_builtin with a named one.
anatofuz
parents:
diff changeset
23 void wildcard_and_functionname() __attribute__((no_builtin)) __attribute__((no_builtin("memcpy"))) {}
173
0572611fdcc8 reorgnization done
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 150
diff changeset
24 // expected-error@-1 {{empty 'no_builtin' cannot be composed with named ones}}
150
anatofuz
parents:
diff changeset
25
anatofuz
parents:
diff changeset
26 /// Can't attach attribute to a variable.
anatofuz
parents:
diff changeset
27 int __attribute__((no_builtin)) variable;
anatofuz
parents:
diff changeset
28 // expected-warning@-1 {{'no_builtin' attribute only applies to functions}}
anatofuz
parents:
diff changeset
29
anatofuz
parents:
diff changeset
30 /// Can't attach attribute to a declaration.
anatofuz
parents:
diff changeset
31 void nobuiltin_on_declaration() __attribute__((no_builtin));
anatofuz
parents:
diff changeset
32 // expected-error@-1 {{no_builtin attribute is permitted on definitions only}}
anatofuz
parents:
diff changeset
33
anatofuz
parents:
diff changeset
34 struct S {
anatofuz
parents:
diff changeset
35 /// Can't attach attribute to a defaulted function,
anatofuz
parents:
diff changeset
36 S()
anatofuz
parents:
diff changeset
37 __attribute__((no_builtin)) = default;
anatofuz
parents:
diff changeset
38 // expected-error@-1 {{no_builtin attribute has no effect on defaulted or deleted functions}}
anatofuz
parents:
diff changeset
39
anatofuz
parents:
diff changeset
40 /// Can't attach attribute to a deleted function,
anatofuz
parents:
diff changeset
41 S(const S &)
anatofuz
parents:
diff changeset
42 __attribute__((no_builtin)) = delete;
anatofuz
parents:
diff changeset
43 // expected-error@-1 {{no_builtin attribute has no effect on defaulted or deleted functions}}
anatofuz
parents:
diff changeset
44
anatofuz
parents:
diff changeset
45 void whatever() __attribute__((no_builtin("memcpy")));
anatofuz
parents:
diff changeset
46 // expected-error@-1 {{no_builtin attribute is permitted on definitions only}}
anatofuz
parents:
diff changeset
47 };
anatofuz
parents:
diff changeset
48
anatofuz
parents:
diff changeset
49 /// Can't attach attribute to an aliased function.
anatofuz
parents:
diff changeset
50 void alised_function() {}
anatofuz
parents:
diff changeset
51 void aliasing_function() __attribute__((no_builtin)) __attribute__((alias("alised_function")));
anatofuz
parents:
diff changeset
52 // expected-error@-1 {{no_builtin attribute is permitted on definitions only}}