summaryrefslogtreecommitdiffstats
path: root/clang/test/Sema
diff options
context:
space:
mode:
authorTed Kremenek <kremenek@apple.com>2010-09-09 00:06:07 +0000
committerTed Kremenek <kremenek@apple.com>2010-09-09 00:06:07 +0000
commit50205744c32d3925ba50d1bd69b1c9e6ab3a28b8 (patch)
tree346d958e0b2e43f060c814c73acd5ee82cab2371 /clang/test/Sema
parentb037185b52556e011023dcdb622b46a4f1284e9a (diff)
downloadbcm5719-llvm-50205744c32d3925ba50d1bd69b1c9e6ab3a28b8.tar.gz
bcm5719-llvm-50205744c32d3925ba50d1bd69b1c9e6ab3a28b8.zip
Enhance -Wreturn-type to not warn when control-flow is most likely limited by a switch statement explicitly covering
all the cases for an enum value. llvm-svn: 113450
Diffstat (limited to 'clang/test/Sema')
-rw-r--r--clang/test/Sema/return.c13
1 files changed, 13 insertions, 0 deletions
diff --git a/clang/test/Sema/return.c b/clang/test/Sema/return.c
index 54c340634d3..597b50214e4 100644
--- a/clang/test/Sema/return.c
+++ b/clang/test/Sema/return.c
@@ -242,3 +242,16 @@ static inline int si_forward() {} // expected-warning{{control reaches end of no
// Test warnings on ignored qualifiers on return types.
const int ignored_c_quals(); // expected-warning{{'const' type qualifier on return type has no effect}}
const volatile int ignored_cv_quals(); // expected-warning{{'const volatile' type qualifiers on return type have no effect}}
+
+// Test that for switch(enum) that if the switch statement covers all the cases
+// that we don't consider that for -Wreturn-type.
+enum Cases { C1, C2, C3, C4 };
+int test_enum_cases(enum Cases C) {
+ switch (C) {
+ case C1: return 1;
+ case C2: return 2;
+ case C4: return 3;
+ case C3: return 4;
+ }
+} // no-warning
+
OpenPOWER on IntegriCloud