diff --git a/clang/lib/AST/ComputeDependence.cpp b/clang/lib/AST/ComputeDependence.cpp --- a/clang/lib/AST/ComputeDependence.cpp +++ b/clang/lib/AST/ComputeDependence.cpp @@ -136,6 +136,13 @@ // lambda-expressions and GCC. if (TemplateDepth) D |= ExprDependence::ValueInstantiation; + + // Populate dependence bits from the expr that consider to be the result + // of the compound statements. + if (const auto *CompoundExprResult = + dyn_cast_or_null(E->getSubStmt()->getStmtExprResult())) + if (const Expr *ResultExpr = CompoundExprResult->getExprStmt()) + D |= ResultExpr->getDependence(); return D; } diff --git a/clang/test/SemaCXX/invalid-constructor-init.cpp b/clang/test/SemaCXX/invalid-constructor-init.cpp --- a/clang/test/SemaCXX/invalid-constructor-init.cpp +++ b/clang/test/SemaCXX/invalid-constructor-init.cpp @@ -14,6 +14,12 @@ constexpr X2() {} // expected-error {{constexpr constructor never produces a constant expression}} }; +struct X3 { + int Y; + constexpr X3() // expected-error {{constexpr constructor never produces}} + : Y(({foo();})) {} // expected-error {{use of undeclared identifier 'foo'}} +}; + struct CycleDelegate { int Y; CycleDelegate(int)