File tree Expand file tree Collapse file tree 2 files changed +21
-0
lines changed Expand file tree Collapse file tree 2 files changed +21
-0
lines changed Original file line number Diff line number Diff line change @@ -253,6 +253,9 @@ bool Compiler<Emitter>::VisitCastExpr(const CastExpr *CE) {
253253
254254 case CK_UncheckedDerivedToBase:
255255 case CK_DerivedToBase: {
256+ if (DiscardResult)
257+ return this ->discard (SubExpr);
258+
256259 if (!this ->delegate (SubExpr))
257260 return false ;
258261
@@ -282,6 +285,9 @@ bool Compiler<Emitter>::VisitCastExpr(const CastExpr *CE) {
282285 }
283286
284287 case CK_BaseToDerived: {
288+ if (DiscardResult)
289+ return this ->discard (SubExpr);
290+
285291 if (!this ->delegate (SubExpr))
286292 return false ;
287293
Original file line number Diff line number Diff line change @@ -1684,3 +1684,18 @@ namespace ExplicitThisInTemporary {
16841684 constexpr bool g (B b) { return &b == b.p ; }
16851685 static_assert (g({}), " " );
16861686}
1687+
1688+ namespace IgnoredMemberExpr {
1689+ class A {
1690+ public:
1691+ int a;
1692+ };
1693+ class B : public A {
1694+ public:
1695+ constexpr int foo () {
1696+ a; // both-warning {{expression result unused}}
1697+ return 0 ;
1698+ }
1699+ };
1700+ static_assert (B{}.foo() == 0 , " " );
1701+ }
You can’t perform that action at this time.
0 commit comments