]> granicus.if.org Git - clang/commitdiff
Fix a bug where the -Wmissing-noreturn would always treat constructors with base...
authorAnders Carlsson <andersca@mac.com>
Sun, 16 Jan 2011 22:12:43 +0000 (22:12 +0000)
committerAnders Carlsson <andersca@mac.com>
Sun, 16 Jan 2011 22:12:43 +0000 (22:12 +0000)
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@123603 91177308-0d34-0410-b5e6-96231b3b80d8

lib/Sema/AnalysisBasedWarnings.cpp
test/SemaCXX/warn-missing-noreturn.cpp

index 14d75338e0d2d0f1eb07d0da7d07912da8aedb82..3ded735f592b41a25a653138cca4851fcc70d265 100644 (file)
@@ -131,6 +131,12 @@ static ControlFlowKind CheckFallThrough(AnalysisContext &AC) {
       continue;
     }
     CFGElement CE = B[B.size()-1];
+    if (CFGInitializer CI = CE.getAs<CFGInitializer>()) {
+      // A base or member initializer.
+      HasPlainEdge = true;
+      continue;
+    }
+
     CFGStmt CS = CE.getAs<CFGStmt>();
     if (!CS.isValid())
       continue;
index f2f9b2e2b75137f8ce78b4934272660f45b6145a..251117fb77411fcce336a47e521b02109e50bc54 100644 (file)
@@ -50,3 +50,20 @@ void f_R7880658(R7880658 f, R7880658 l) {  // no-warning
   for (; f != l; ++f) {
   }
 }
+
+namespace test2 {
+
+  bool g();
+  void *h() __attribute__((noreturn));
+  void *j();
+
+  struct A {
+    void *f;
+
+    A() : f(0) { }
+    A(int) : f(h()) { } // expected-warning {{function could be attribute 'noreturn'}}
+    A(char) : f(j()) { }
+    A(bool b) : f(b ? h() : j()) { }
+  };
+
+}