Clang Project

clang_source_code/test/SemaCXX/attr-optnone.cpp
1// RUN: %clang_cc1 -std=c++11 -fms-compatibility -fsyntax-only -verify %s
2
3int foo() __attribute__((optnone));
4int bar() __attribute__((optnone)) __attribute__((noinline));
5
6int baz() __attribute__((always_inline)) __attribute__((optnone)); // expected-warning{{'always_inline' attribute ignored}} expected-note{{conflicting attribute is here}}
7int quz() __attribute__((optnone)) __attribute__((always_inline)); // expected-warning{{'always_inline' attribute ignored}} expected-note{{conflicting attribute is here}}
8
9__attribute__((always_inline)) int baz1(); // expected-warning{{'always_inline' attribute ignored}}
10__attribute__((optnone)) int baz1() { return 1; } // expected-note{{conflicting attribute is here}}
11
12__attribute__((optnone)) int quz1(); // expected-note{{conflicting attribute is here}}
13__attribute__((always_inline)) int quz1() { return 1; } // expected-warning{{'always_inline' attribute ignored}}
14
15int bay() __attribute__((minsize)) __attribute__((optnone)); // expected-warning{{'minsize' attribute ignored}} expected-note{{conflicting}}
16int quy() __attribute__((optnone)) __attribute__((minsize)); // expected-warning{{'minsize' attribute ignored}} expected-note{{conflicting}}
17
18__attribute__((minsize)) int bay1(); // expected-warning{{'minsize' attribute ignored}}
19__attribute__((optnone)) int bay1() { return 1; } // expected-note{{conflicting attribute is here}}
20
21__attribute__((optnone)) int quy1(); // expected-note{{conflicting attribute is here}}
22__attribute__((minsize)) int quy1() { return 1; } // expected-warning{{'minsize' attribute ignored}}
23
24__attribute__((always_inline)) // expected-warning{{'always_inline' attribute ignored}}
25  __attribute__((minsize)) // expected-warning{{'minsize' attribute ignored}}
26void bay2();
27__attribute__((optnone)) // expected-note 2 {{conflicting}}
28void bay2() {}
29
30__forceinline __attribute__((optnone)) int bax(); // expected-warning{{'__forceinline' attribute ignored}} expected-note{{conflicting}}
31__attribute__((optnone)) __forceinline int qux(); // expected-warning{{'__forceinline' attribute ignored}} expected-note{{conflicting}}
32
33__forceinline int bax2(); // expected-warning{{'__forceinline' attribute ignored}}
34__attribute__((optnone)) int bax2() { return 1; } // expected-note{{conflicting}}
35__attribute__((optnone)) int qux2(); // expected-note{{conflicting}}
36__forceinline int qux2() { return 1; } // expected-warning{{'__forceinline' attribute ignored}}
37
38int globalVar __attribute__((optnone)); // expected-warning{{'optnone' attribute only applies to functions}}
39
40int fubar(int __attribute__((optnone)), int); // expected-warning{{'optnone' attribute only applies to functions}}
41
42struct A {
43  int aField __attribute__((optnone));  // expected-warning{{'optnone' attribute only applies to functions}}
44};
45
46struct B {
47  void foo() __attribute__((optnone));
48  static void bar() __attribute__((optnone));
49};
50
51// Verify that we can specify the [[clang::optnone]] syntax as well.
52
53[[clang::optnone]]
54int foo2();
55[[clang::optnone]]
56int bar2() __attribute__((noinline));
57
58[[clang::optnone]] // expected-note {{conflicting}}
59int baz2() __attribute__((always_inline)); // expected-warning{{'always_inline' attribute ignored}}
60
61[[clang::optnone]] int globalVar2; //expected-warning{{'optnone' attribute only applies to functions}}
62
63struct A2 {
64  [[clang::optnone]] int aField; // expected-warning{{'optnone' attribute only applies to functions}}
65};
66
67struct B2 {
68  [[clang::optnone]]
69  void foo();
70  [[clang::optnone]]
71  static void bar();
72};
73
74// Verify that we can handle the [[_Clang::optnone]] and
75// [[__clang__::optnone]] spellings, as well as [[clang::__optnone__]].
76[[_Clang::optnone]] int foo3();
77[[__clang__::optnone]] int foo4(); // expected-warning {{'__clang__' is a predefined macro name, not an attribute scope specifier; did you mean '_Clang' instead?}}
78[[clang::__optnone__]] int foo5();
79[[_Clang::__optnone__]] int foo6();
80
81[[_Clang::optnone]] int foo7; // expected-warning {{'optnone' attribute only applies to functions}}
82