Home | History | Annotate | Download | only in SemaCXX
      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-warning{{'always_inline' attribute ignored}} expected-note{{conflicting attribute is here}}
      7 int 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 
     15 int bay() __attribute__((minsize)) __attribute__((optnone)); // expected-warning{{'minsize' attribute ignored}} expected-note{{conflicting}}
     16 int 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}}
     26 void bay2();
     27 __attribute__((optnone)) // expected-note 2 {{conflicting}}
     28 void 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 
     38 int globalVar __attribute__((optnone)); // expected-warning{{'optnone' attribute only applies to functions}}
     39 
     40 int fubar(int __attribute__((optnone)), int); // expected-warning{{'optnone' attribute only applies to functions}}
     41 
     42 struct A {
     43   int aField __attribute__((optnone));  // expected-warning{{'optnone' attribute only applies to functions}}
     44 };
     45 
     46 struct 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]]
     54 int foo2();
     55 [[clang::optnone]]
     56 int bar2() __attribute__((noinline));
     57 
     58 [[clang::optnone]] // expected-note {{conflicting}}
     59 int 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 
     63 struct A2 {
     64   [[clang::optnone]] int aField; // expected-warning{{'optnone' attribute only applies to functions}}
     65 };
     66 
     67 struct B2 {
     68   [[clang::optnone]]
     69   void foo();
     70   [[clang::optnone]]
     71   static void bar();
     72 };
     73 
     74