[docs] Add LICENSE.txt to the root of the mono-repo
[llvm-project.git] / clang / test / Sema / attr-noinline.cpp
blobd35782f11adbbdc1baca0c09c5ae438a71f6b32f
1 // RUN: %clang_cc1 -verify -fsyntax-only %s
3 int bar();
5 [[gnu::always_inline]] void always_inline_fn(void) { }
6 [[gnu::flatten]] void flatten_fn(void) { }
8 [[gnu::noinline]] void noinline_fn(void) { }
10 void foo() {
11 [[clang::noinline]] bar();
12 [[clang::noinline(0)]] bar(); // expected-error {{'noinline' attribute takes no arguments}}
13 int x;
14 [[clang::noinline]] x = 0; // expected-warning {{'noinline' attribute is ignored because there exists no call expression inside the statement}}
15 [[clang::noinline]] { asm("nop"); } // expected-warning {{'noinline' attribute is ignored because there exists no call expression inside the statement}}
16 [[clang::noinline]] label: x = 1; // expected-warning {{'noinline' attribute only applies to functions and statements}}
19 [[clang::noinline]] always_inline_fn(); // expected-warning {{statement attribute 'noinline' has higher precedence than function attribute 'always_inline'}}
20 [[clang::noinline]] flatten_fn(); // expected-warning {{statement attribute 'noinline' has higher precedence than function attribute 'flatten'}}
21 [[clang::noinline]] noinline_fn();
23 [[gnu::noinline]] bar(); // expected-warning {{attribute is ignored on this statement as it only applies to functions; use '[[clang::noinline]]' on statements}}
24 __attribute__((noinline)) bar(); // expected-warning {{attribute is ignored on this statement as it only applies to functions; use '[[clang::noinline]]' on statements}}
27 [[clang::noinline]] static int i = bar(); // expected-warning {{'noinline' attribute only applies to functions and statements}}