llvm-project/clang/test/Misc/backend-stack-frame-diagnostics.cpp
Alp Toker d08473415f Make '-Werror=frame-larger-than=' and associated diagnostic pragmas GCC-compatible
It turns out the trailing '=' really is part of the option name spelling and
treating it as such gets us compatible with GCC's -Werror= and pragmas.

(GCC doesn't appear to support any -Wno- form for this diagnostic but we do.)

llvm-svn: 210503
2014-06-09 23:59:38 +00:00

62 lines
1.6 KiB
C++

// REQUIRES: x86-registered-target
// RUN: %clang -target i386-apple-darwin -std=c++11 -fblocks -Wframe-larger-than=70 -Xclang -verify -o /dev/null -c %s
// Test that:
// * The driver passes the option through to the backend.
// * The frontend diagnostic handler 'demangles' and resolves the correct function definition.
// TODO: Support rich backend diagnostics for Objective-C methods.
extern void doIt(char *);
void frameSizeWarning(int, int) {}
void frameSizeWarning();
void frameSizeWarning() { // expected-warning-re {{stack frame size of {{[0-9]+}} bytes in function 'frameSizeWarning'}}
char buffer[80];
doIt(buffer);
}
void frameSizeWarning();
void frameSizeWarning(int) {}
#pragma GCC diagnostic push
#pragma GCC diagnostic ignored "-Wframe-larger-than="
// expected-warning@+1 {{unknown warning group '-Wframe-larger-than'}}
#pragma GCC diagnostic ignored "-Wframe-larger-than"
void frameSizeWarningIgnored() {
char buffer[80];
doIt(buffer);
}
#pragma GCC diagnostic pop
void frameSizeLocalClassWarning() {
struct S {
S() { // expected-warning-re {{stack frame size of {{[0-9]+}} bytes in function 'frameSizeLocalClassWarning()::S::S'}}
char buffer[80];
doIt(buffer);
}
};
S();
}
void frameSizeLambdaWarning() {
auto fn =
[]() { // expected-warning-re {{stack frame size of {{[0-9]+}} bytes in lambda expression}}
char buffer[80];
doIt(buffer);
};
fn();
}
void frameSizeBlocksWarning() {
auto fn =
^() { // expected-warning-re {{stack frame size of {{[0-9]+}} bytes in block literal}}
char buffer[80];
doIt(buffer);
};
fn();
}