summaryrefslogtreecommitdiffstats
path: root/clang/test/SemaCXX/cxx98-compat.cpp
diff options
context:
space:
mode:
authorRichard Smith <richard-llvm@metafoo.co.uk>2011-10-20 21:42:12 +0000
committerRichard Smith <richard-llvm@metafoo.co.uk>2011-10-20 21:42:12 +0000
commitfe2750db42c0ffb0fd1a44ddbd4591f4f0222a2c (patch)
treeedf9e529cf0f0a2cd63a20b91dd3b865bb4d20f7 /clang/test/SemaCXX/cxx98-compat.cpp
parent3acac94b60c0822d7e0889ef4598cc64dda0e32a (diff)
downloadbcm5719-llvm-fe2750db42c0ffb0fd1a44ddbd4591f4f0222a2c.tar.gz
bcm5719-llvm-fe2750db42c0ffb0fd1a44ddbd4591f4f0222a2c.zip
Add -Wc++98-compat diagnostics for jumps which bypass initialization of non-POD
but trivially constructible and destructible variables in C++11 mode. Also incidentally improve the precision of the wording for jump diagnostics in C++98 mode. llvm-svn: 142619
Diffstat (limited to 'clang/test/SemaCXX/cxx98-compat.cpp')
-rw-r--r--clang/test/SemaCXX/cxx98-compat.cpp17
1 files changed, 17 insertions, 0 deletions
diff --git a/clang/test/SemaCXX/cxx98-compat.cpp b/clang/test/SemaCXX/cxx98-compat.cpp
index 260e86b0ece..051176bf9c3 100644
--- a/clang/test/SemaCXX/cxx98-compat.cpp
+++ b/clang/test/SemaCXX/cxx98-compat.cpp
@@ -243,3 +243,20 @@ template<typename T> void EnumNNSFn() {
int k = T::enum_val; // expected-warning {{enumeration type in nested name specifier is incompatible with C++98}}
};
template void EnumNNSFn<Enum>(); // expected-note {{in instantiation}}
+
+void JumpDiagnostics(int n) {
+ goto DirectJump; // expected-warning {{goto would jump into protected scope in C++98}}
+ TrivialButNonPOD tnp1; // expected-note {{jump bypasses initialization of non-POD variable}}
+
+DirectJump:
+ void *Table[] = {&&DirectJump, &&Later};
+ goto *Table[n]; // expected-warning {{indirect goto might cross protected scopes in C++98}}
+
+ TrivialButNonPOD tnp2; // expected-note {{jump bypasses initialization of non-POD variable}}
+Later: // expected-note {{possible target of indirect goto}}
+ switch (n) {
+ TrivialButNonPOD tnp3; // expected-note {{jump bypasses initialization of non-POD variable}}
+ default: // expected-warning {{switch case would be in a protected scope in C++98}}
+ return;
+ }
+}
OpenPOWER on IntegriCloud