1 // RUN: %clang_cc1 -verify -fsyntax-only %s -Wno-c++17-extensions
5 // expected-note@+1{{conflicting attribute is here}}
6 [[gnu::always_inline
]] void always_inline_fn(void) { }
7 // expected-note@+1{{conflicting attribute is here}}
8 [[gnu::flatten
]] void flatten_fn(void) { }
9 [[gnu::noinline
]] void noinline_fn(void) { }
12 [[clang::noinline
]] bar();
13 [[clang::noinline(0)]] bar(); // expected-error {{'noinline' attribute takes no arguments}}
15 [[clang::noinline
]] x
= 0; // expected-warning {{'noinline' attribute is ignored because there exists no call expression inside the statement}}
16 [[clang::noinline
]] { asm("nop"); } // expected-warning {{'noinline' attribute is ignored because there exists no call expression inside the statement}}
17 [[clang::noinline
]] label
: x
= 1; // expected-warning {{'noinline' attribute only applies to functions and statements}}
20 [[clang::noinline
]] always_inline_fn(); // expected-warning {{statement attribute 'noinline' has higher precedence than function attribute 'always_inline'}}
21 [[clang::noinline
]] flatten_fn(); // expected-warning {{statement attribute 'noinline' has higher precedence than function attribute 'flatten'}}
22 [[clang::noinline
]] noinline_fn();
24 [[gnu::noinline
]] bar(); // expected-warning {{attribute is ignored on this statement as it only applies to functions; use '[[clang::noinline]]' on statements}}
25 __attribute__((noinline
)) bar(); // expected-warning {{attribute is ignored on this statement as it only applies to functions; use '[[clang::noinline]]' on statements}}
28 [[clang::noinline
]] static int i
= bar(); // expected-warning {{'noinline' attribute only applies to functions and statements}}
30 // This used to crash the compiler.
33 [[clang::noinline
]] return foo
<D
-1>(x
+ 1);
37 [[clang::always_inline
]]
38 int dependent(int x
){ return x
+ D
;} // #DEP
39 [[clang::always_inline
]]
40 int non_dependent(int x
){return x
;} // #NO_DEP
42 template<int D
> [[clang::always_inline
]]
43 int baz(int x
) { // #BAZ
44 // expected-warning@+2{{statement attribute 'noinline' has higher precedence than function attribute 'always_inline'}}
45 // expected-note@#NO_DEP{{conflicting attribute is here}}
46 [[clang::noinline
]] non_dependent(x
);
48 // expected-warning@+6{{statement attribute 'noinline' has higher precedence than function attribute 'always_inline'}}
49 // expected-note@#NO_DEP{{conflicting attribute is here}}
50 // expected-warning@+4 3{{statement attribute 'noinline' has higher precedence than function attribute 'always_inline'}}
51 // expected-note@#BAZ 3{{conflicting attribute is here}}
52 // expected-note@#BAZ_INST 3{{in instantiation}}
53 // expected-note@+1 3{{in instantiation}}
54 [[clang::noinline
]] return non_dependent(x
), baz
<D
-1>(x
+ 1);
59 // We can't suppress if there is a variadic involved.
61 int variadic_baz(int x
) {
62 // Diagnoses NO_DEP 2x, once during phase 1, the second during instantiation.
63 // Dianoses DEP 3x, once per variadic expansion.
64 // expected-warning@+5 2{{statement attribute 'noinline' has higher precedence than function attribute 'always_inline'}}
65 // expected-note@#NO_DEP 2{{conflicting attribute is here}}
66 // expected-warning@+3 3{{statement attribute 'noinline' has higher precedence than function attribute 'always_inline'}}
67 // expected-note@#DEP 3{{conflicting attribute is here}}
68 // expected-note@#VARIADIC_INST{{in instantiation}}
69 [[clang::noinline
]] return non_dependent(x
) + (dependent
<D
>(x
) + ...);
73 baz
<3>(0); // #BAZ_INST
74 variadic_baz
<0, 1, 2>(0); // #VARIADIC_INST