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) {
253
253
254
254
case CK_UncheckedDerivedToBase:
255
255
case CK_DerivedToBase: {
256
+ if (DiscardResult)
257
+ return this ->discard (SubExpr);
258
+
256
259
if (!this ->delegate (SubExpr))
257
260
return false ;
258
261
@@ -282,6 +285,9 @@ bool Compiler<Emitter>::VisitCastExpr(const CastExpr *CE) {
282
285
}
283
286
284
287
case CK_BaseToDerived: {
288
+ if (DiscardResult)
289
+ return this ->discard (SubExpr);
290
+
285
291
if (!this ->delegate (SubExpr))
286
292
return false ;
287
293
Original file line number Diff line number Diff line change @@ -1684,3 +1684,18 @@ namespace ExplicitThisInTemporary {
1684
1684
constexpr bool g (B b) { return &b == b.p ; }
1685
1685
static_assert (g({}), " " );
1686
1686
}
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