From 0dc5f9aea3597f2ed400dd0c1bf45ebbb4a051f3 Mon Sep 17 00:00:00 2001 From: Anders Carlsson Date: Sun, 16 Jan 2011 22:12:43 +0000 Subject: [PATCH] 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 --- lib/Sema/AnalysisBasedWarnings.cpp | 6 ++++++ test/SemaCXX/warn-missing-noreturn.cpp | 17 +++++++++++++++++ 2 files changed, 23 insertions(+) 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()) { + // A base or member initializer. + HasPlainEdge = true; + continue; + } + CFGStmt CS = CE.getAs(); 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()) { } + }; + +} -- 2.40.0