annotate clang/test/SemaCXX/cxx11-gnu-attrs.cpp @ 150:1d019706d866

LLVM10
author anatofuz
date Thu, 13 Feb 2020 15:10:13 +0900
parents
children
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 -std=c++11 -Wno-gcc-compat -verify %s
anatofuz
parents:
diff changeset
2
anatofuz
parents:
diff changeset
3 // Error cases.
anatofuz
parents:
diff changeset
4
anatofuz
parents:
diff changeset
5 [[gnu::this_attribute_does_not_exist]] int unknown_attr;
anatofuz
parents:
diff changeset
6 // expected-warning@-1 {{unknown attribute 'this_attribute_does_not_exist' ignored}}
anatofuz
parents:
diff changeset
7 int [[gnu::unused]] attr_on_type;
anatofuz
parents:
diff changeset
8 // expected-error@-1 {{'unused' attribute cannot be applied to types}}
anatofuz
parents:
diff changeset
9 int *[[gnu::unused]] attr_on_ptr;
anatofuz
parents:
diff changeset
10 // expected-warning@-1 {{attribute 'unused' ignored, because it cannot be applied to a type}}
anatofuz
parents:
diff changeset
11 [[gnu::fastcall]] void pr17424_1();
anatofuz
parents:
diff changeset
12 // expected-warning@-1 {{'fastcall' calling convention is not supported for this target}}
anatofuz
parents:
diff changeset
13 [[gnu::fastcall]] [[gnu::stdcall]] void pr17424_2();
anatofuz
parents:
diff changeset
14 // expected-warning@-1 {{'fastcall' calling convention is not supported for this target}}
anatofuz
parents:
diff changeset
15 // expected-warning@-2 {{'stdcall' calling convention is not supported for this target}}
anatofuz
parents:
diff changeset
16 [[gnu::fastcall]] __stdcall void pr17424_3();
anatofuz
parents:
diff changeset
17 // expected-warning@-1 {{'fastcall' calling convention is not supported for this target}}
anatofuz
parents:
diff changeset
18 // expected-warning@-2 {{'__stdcall' calling convention is not supported for this target}}
anatofuz
parents:
diff changeset
19 [[gnu::fastcall]] void pr17424_4() [[gnu::stdcall]];
anatofuz
parents:
diff changeset
20 // expected-warning@-1 {{'fastcall' calling convention is not supported for this target}}
anatofuz
parents:
diff changeset
21 // expected-warning@-2 {{'stdcall' calling convention is not supported for this target}}
anatofuz
parents:
diff changeset
22 void pr17424_5 [[gnu::fastcall]]();
anatofuz
parents:
diff changeset
23 // expected-warning@-1 {{'fastcall' calling convention is not supported for this target}}
anatofuz
parents:
diff changeset
24
anatofuz
parents:
diff changeset
25 // Valid cases.
anatofuz
parents:
diff changeset
26
anatofuz
parents:
diff changeset
27 void aliasb [[gnu::alias("_Z6alias1v")]] ();
anatofuz
parents:
diff changeset
28 void alias1() {}
anatofuz
parents:
diff changeset
29 void aliasa [[gnu::alias("_Z6alias1v")]] ();
anatofuz
parents:
diff changeset
30
anatofuz
parents:
diff changeset
31 extern struct PR22493Ty {
anatofuz
parents:
diff changeset
32 } PR22493 [[gnu::alias("_ZN7pcrecpp2RE6no_argE")]];
anatofuz
parents:
diff changeset
33
anatofuz
parents:
diff changeset
34 [[gnu::aligned(8)]] int aligned;
anatofuz
parents:
diff changeset
35 void aligned_fn [[gnu::aligned(32)]] ();
anatofuz
parents:
diff changeset
36 struct [[gnu::aligned(8)]] aligned_struct {};
anatofuz
parents:
diff changeset
37
anatofuz
parents:
diff changeset
38 void always_inline [[gnu::always_inline]] ();
anatofuz
parents:
diff changeset
39
anatofuz
parents:
diff changeset
40 __thread int tls_model [[gnu::tls_model("local-exec")]];
anatofuz
parents:
diff changeset
41
anatofuz
parents:
diff changeset
42 void cleanup(int *p) {
anatofuz
parents:
diff changeset
43 int n [[gnu::cleanup(cleanup)]];
anatofuz
parents:
diff changeset
44 }
anatofuz
parents:
diff changeset
45
anatofuz
parents:
diff changeset
46 void deprecated1 [[gnu::deprecated]] (); // expected-note {{here}}
anatofuz
parents:
diff changeset
47 [[gnu::deprecated("custom message")]] void deprecated2(); // expected-note {{here}}
anatofuz
parents:
diff changeset
48 void deprecated3() {
anatofuz
parents:
diff changeset
49 deprecated1(); // expected-warning {{deprecated}}
anatofuz
parents:
diff changeset
50 deprecated2(); // expected-warning {{custom message}}
anatofuz
parents:
diff changeset
51 }
anatofuz
parents:
diff changeset
52
anatofuz
parents:
diff changeset
53 [[gnu::naked(1,2,3)]] void naked(); // expected-error {{takes no arguments}}
anatofuz
parents:
diff changeset
54
anatofuz
parents:
diff changeset
55 void nonnull [[gnu::nonnull]] (); // expected-warning {{applied to function with no pointer arguments}}
anatofuz
parents:
diff changeset
56
anatofuz
parents:
diff changeset
57 // [[gnu::noreturn]] appertains to a declaration, and marks the innermost
anatofuz
parents:
diff changeset
58 // function declarator in that declaration as being noreturn.
anatofuz
parents:
diff changeset
59 int noreturn [[gnu::noreturn]]; // expected-warning {{'noreturn' only applies to function types}}
anatofuz
parents:
diff changeset
60 int noreturn_fn_1();
anatofuz
parents:
diff changeset
61 int noreturn_fn_2() [[gnu::noreturn]]; // expected-warning {{cannot be applied to a type}}
anatofuz
parents:
diff changeset
62 int noreturn_fn_3 [[gnu::noreturn]] ();
anatofuz
parents:
diff changeset
63 [[gnu::noreturn]] int noreturn_fn_4();
anatofuz
parents:
diff changeset
64 int (*noreturn_fn_ptr_1 [[gnu::noreturn]])() = &noreturn_fn_1; // expected-error {{cannot initialize}}
anatofuz
parents:
diff changeset
65 int (*noreturn_fn_ptr_2 [[gnu::noreturn]])() = &noreturn_fn_3;
anatofuz
parents:
diff changeset
66 [[gnu::noreturn]] int (*noreturn_fn_ptr_3)() = &noreturn_fn_1; // expected-error {{cannot initialize}}
anatofuz
parents:
diff changeset
67 [[gnu::noreturn]] int (*noreturn_fn_ptr_4)() = &noreturn_fn_3;
anatofuz
parents:
diff changeset
68
anatofuz
parents:
diff changeset
69 struct [[gnu::packed]] packed { char c; int n; };
anatofuz
parents:
diff changeset
70 static_assert(sizeof(packed) == sizeof(char) + sizeof(int), "not packed");