blob: 58776caf7ae60b47967ab0f83ed18fab2255b56f [file] [log] [blame]
Stephen Hines651f13c2014-04-23 16:59:28 -07001// RUN: %clang_cc1 -std=c++11 -fms-compatibility -fsyntax-only -verify %s
2
3int foo() __attribute__((optnone));
4int bar() __attribute__((optnone)) __attribute__((noinline));
5
Stephen Hines0e2c34f2015-03-23 12:09:02 -07006int 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}}
Stephen Hines651f13c2014-04-23 16:59:28 -07008
Stephen Hines0e2c34f2015-03-23 12:09:02 -07009__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}}
Stephen Hines651f13c2014-04-23 16:59:28 -070037
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
Stephen Hines0e2c34f2015-03-23 12:09:02 -070058[[clang::optnone]] // expected-note {{conflicting}}
59int baz2() __attribute__((always_inline)); // expected-warning{{'always_inline' attribute ignored}}
Stephen Hines651f13c2014-04-23 16:59:28 -070060
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