diff options
author | Anders Carlsson <andersca@mac.com> | 2011-01-16 22:12:43 +0000 |
---|---|---|
committer | Anders Carlsson <andersca@mac.com> | 2011-01-16 22:12:43 +0000 |
commit | 0dc5f9aea3597f2ed400dd0c1bf45ebbb4a051f3 (patch) | |
tree | 79fd5d56c4a2d29ce7254c900e98a44e8e913f6a | |
parent | 04eeba43040969c05cfcb563195ef5b199297b62 (diff) |
Fix a bug where the -Wmissing-noreturn would always treat constructors with base or member initializers as noreturn.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@123603 91177308-0d34-0410-b5e6-96231b3b80d8
-rw-r--r-- | lib/Sema/AnalysisBasedWarnings.cpp | 6 | ||||
-rw-r--r-- | test/SemaCXX/warn-missing-noreturn.cpp | 17 |
2 files changed, 23 insertions, 0 deletions
diff --git a/lib/Sema/AnalysisBasedWarnings.cpp b/lib/Sema/AnalysisBasedWarnings.cpp index 14d75338e0..3ded735f59 100644 --- a/lib/Sema/AnalysisBasedWarnings.cpp +++ b/lib/Sema/AnalysisBasedWarnings.cpp @@ -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; diff --git a/test/SemaCXX/warn-missing-noreturn.cpp b/test/SemaCXX/warn-missing-noreturn.cpp index f2f9b2e2b7..251117fb77 100644 --- a/test/SemaCXX/warn-missing-noreturn.cpp +++ b/test/SemaCXX/warn-missing-noreturn.cpp @@ -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()) { } + }; + +} |