1 // RUN: %clang_cc1 -std=c++11 -fms-compatibility -fsyntax-only -verify %s 2 3 int foo() __attribute__((optnone)); 4 int bar() __attribute__((optnone)) __attribute__((noinline)); 5 6 int baz() __attribute__((always_inline)) __attribute__((optnone)); // expected-error{{'always_inline' and 'optnone' attributes are not compatible}} 7 int quz() __attribute__((optnone)) __attribute__((always_inline)); // expected-error{{'optnone' and 'always_inline' attributes are not compatible}} 8 9 __forceinline __attribute__((optnone)) int bax(); // expected-error{{'__forceinline' and 'optnone' attributes are not compatible}} 10 __attribute__((optnone)) __forceinline int qux(); // expected-error{{'optnone' and '__forceinline' attributes are not compatible}} 11 12 int globalVar __attribute__((optnone)); // expected-warning{{'optnone' attribute only applies to functions}} 13 14 int fubar(int __attribute__((optnone)), int); // expected-warning{{'optnone' attribute only applies to functions}} 15 16 struct A { 17 int aField __attribute__((optnone)); // expected-warning{{'optnone' attribute only applies to functions}} 18 }; 19 20 struct B { 21 void foo() __attribute__((optnone)); 22 static void bar() __attribute__((optnone)); 23 }; 24 25 // Verify that we can specify the [[clang::optnone]] syntax as well. 26 27 [[clang::optnone]] 28 int foo2(); 29 [[clang::optnone]] 30 int bar2() __attribute__((noinline)); 31 32 [[clang::optnone]] 33 int baz2() __attribute__((always_inline)); // expected-error{{'always_inline' and 'optnone' attributes are not compatible}} 34 35 [[clang::optnone]] int globalVar2; //expected-warning{{'optnone' attribute only applies to functions}} 36 37 struct A2 { 38 [[clang::optnone]] int aField; // expected-warning{{'optnone' attribute only applies to functions}} 39 }; 40 41 struct B2 { 42 [[clang::optnone]] 43 void foo(); 44 [[clang::optnone]] 45 static void bar(); 46 }; 47 48