blob: 58776caf7ae60b47967ab0f83ed18fab2255b56f [file] [log] [blame]
Paul Robinsonf0674352014-03-31 22:29:15 +00001// RUN: %clang_cc1 -std=c++11 -fms-compatibility -fsyntax-only -verify %s
2
3int foo() __attribute__((optnone));
4int bar() __attribute__((optnone)) __attribute__((noinline));
5
Paul Robinson080b1f32015-01-13 18:34:56 +00006int 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}}
Paul Robinsonf0674352014-03-31 22:29:15 +00008
Paul Robinson30e41fb2014-12-15 18:57:28 +00009__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
Paul Robinson080b1f32015-01-13 18:34:56 +000015int 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}}
Paul Robinsonaae2fba2014-12-10 23:34:36 +000017
Paul Robinson30e41fb2014-12-15 18:57:28 +000018__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
Paul Robinson080b1f32015-01-13 18:34:56 +000030__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}}
Paul Robinsonf0674352014-03-31 22:29:15 +000037
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
Paul Robinson080b1f32015-01-13 18:34:56 +000058[[clang::optnone]] // expected-note {{conflicting}}
59int baz2() __attribute__((always_inline)); // expected-warning{{'always_inline' attribute ignored}}
Paul Robinsonf0674352014-03-31 22:29:15 +000060
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