1 // REQUIRES: x86-registered-target 2 // RUN: %clang -target i386-apple-darwin -std=c++11 -fblocks -Wframe-larger-than=70 -Xclang -verify -o /dev/null -c %s 3 // RUN: %clang -target i386-apple-darwin -std=c++11 -fblocks -Wframe-larger-than=70 -Xclang -verify -o /dev/null -c %s -DIS_SYSHEADER 4 5 // Test that: 6 // * The driver passes the option through to the backend. 7 // * The frontend diagnostic handler 'demangles' and resolves the correct function definition. 8 9 // Test that link invocations don't emit an "argument unused during compilation" diagnostic. 10 // RUN: touch %t.o 11 // RUN: %clang -Werror -Wframe-larger-than=0 %t.o -### 2>&1 | not grep ' error: ' 12 13 // TODO: Support rich backend diagnostics for Objective-C methods. 14 15 // Backend diagnostics aren't suppressed in system headers because such results 16 // are significant and actionable. 17 #ifdef IS_HEADER 18 19 #ifdef IS_SYSHEADER 20 #pragma clang system_header 21 #endif 22 23 extern void doIt(char *); 24 25 void frameSizeWarning(int, int) {} 26 27 void frameSizeWarning(); 28 29 void frameSizeWarning() { // expected-warning-re {{stack frame size of {{[0-9]+}} bytes in function 'frameSizeWarning'}} 30 char buffer[80]; 31 doIt(buffer); 32 } 33 34 void frameSizeWarning(); 35 36 void frameSizeWarning(int) {} 37 38 #pragma GCC diagnostic push 39 #pragma GCC diagnostic ignored "-Wframe-larger-than=" 40 void frameSizeWarningIgnored() { 41 char buffer[80]; 42 doIt(buffer); 43 } 44 #pragma GCC diagnostic pop 45 46 #pragma GCC diagnostic push 47 #ifndef IS_SYSHEADER 48 // expected-warning@+2 {{unknown warning group '-Wframe-larger-than'}} 49 #endif 50 #pragma GCC diagnostic ignored "-Wframe-larger-than" 51 #pragma GCC diagnostic pop 52 53 void frameSizeLocalClassWarning() { 54 struct S { 55 S() { // expected-warning-re {{stack frame size of {{[0-9]+}} bytes in function 'frameSizeLocalClassWarning()::S::S'}} 56 char buffer[80]; 57 doIt(buffer); 58 } 59 }; 60 S(); 61 } 62 63 void frameSizeLambdaWarning() { 64 auto fn = 65 []() { // expected-warning-re {{stack frame size of {{[0-9]+}} bytes in lambda expression}} 66 char buffer[80]; 67 doIt(buffer); 68 }; 69 fn(); 70 } 71 72 void frameSizeBlocksWarning() { 73 auto fn = 74 ^() { // expected-warning-re {{stack frame size of {{[0-9]+}} bytes in block literal}} 75 char buffer[80]; 76 doIt(buffer); 77 }; 78 fn(); 79 } 80 81 #else 82 83 #define IS_HEADER 84 #include __FILE__ 85 #endif 86