summaryrefslogtreecommitdiffstats
path: root/clang/test
diff options
context:
space:
mode:
authorTed Kremenek <kremenek@apple.com>2014-03-06 06:50:46 +0000
committerTed Kremenek <kremenek@apple.com>2014-03-06 06:50:46 +0000
commitec2dc73e8638eecc7c95404d575ea9d94e197cf3 (patch)
tree5924b2745d9a736042348c9b461108b8d728a9a2 /clang/test
parentb3fd21a42fc3bf620c1c81cc1c131c24e142cee7 (diff)
downloadbcm5719-llvm-ec2dc73e8638eecc7c95404d575ea9d94e197cf3.tar.gz
bcm5719-llvm-ec2dc73e8638eecc7c95404d575ea9d94e197cf3.zip
[-Wunreachable-code] don't warn about dead 'return <string literal>' dominated by a 'noreturn' call, where literal becomes an std::string.
I have mixed feelings about this one. It's used all over the codebase, and is analogous to the current heuristic for ordinary C string literals. This requires some ad hoc pattern matching of the AST. While the test case mirrors what we see std::string in libc++, it's not really testing the libc++ headers. llvm-svn: 203091
Diffstat (limited to 'clang/test')
-rw-r--r--clang/test/SemaCXX/warn-unreachable.cpp21
1 files changed, 21 insertions, 0 deletions
diff --git a/clang/test/SemaCXX/warn-unreachable.cpp b/clang/test/SemaCXX/warn-unreachable.cpp
index dbbcc8c50e0..1fbe15c0f02 100644
--- a/clang/test/SemaCXX/warn-unreachable.cpp
+++ b/clang/test/SemaCXX/warn-unreachable.cpp
@@ -129,4 +129,25 @@ PR19040_test_return_t PR19040_fn1 ()
return PR19040_TEST_FAILURE; // expected-warning {{will never be executed}}
}
+__attribute__((noreturn))
+void raze();
+
+namespace std {
+template<typename T> struct basic_string {
+ basic_string(const T* x) {}
+ ~basic_string() {};
+};
+typedef basic_string<char> string;
+}
+
+std::string testStr() {
+ raze();
+ return ""; // no-warning
+}
+
+std::string testStrWarn(const char *s) {
+ raze();
+ return s; // expected-warning {{will never be executed}}
+}
+
OpenPOWER on IntegriCloud