forked from OSchip/llvm-project
Evaluate union cast subexpressions when the cast value is unused
Fixes PR23597. llvm-svn: 237839
This commit is contained in:
parent
0c28fd7fda
commit
892bb0cace
|
@ -584,7 +584,12 @@ void AggExprEmitter::VisitCastExpr(CastExpr *E) {
|
|||
}
|
||||
|
||||
case CK_ToUnion: {
|
||||
if (Dest.isIgnored()) break;
|
||||
// Evaluate even if the destination is ignored.
|
||||
if (Dest.isIgnored()) {
|
||||
CGF.EmitAnyExpr(E->getSubExpr(), AggValueSlot::ignored(),
|
||||
/*ignoreResult=*/true);
|
||||
break;
|
||||
}
|
||||
|
||||
// GCC union extension
|
||||
QualType Ty = E->getSubExpr()->getType();
|
||||
|
|
|
@ -184,3 +184,14 @@ void f17() {
|
|||
extfunc(x);
|
||||
// CHECK: add nsw i128 %{{.}}, -1
|
||||
}
|
||||
|
||||
// PR23597: We should evaluate union cast operands even if the cast is unused.
|
||||
typedef union u {
|
||||
int i;
|
||||
} strct;
|
||||
int returns_int(void);
|
||||
void f18() {
|
||||
(strct)returns_int();
|
||||
}
|
||||
// CHECK-LABEL: define void @f18()
|
||||
// CHECK: call i32 @returns_int()
|
||||
|
|
Loading…
Reference in New Issue