Skip to content

Commit cdae331

Browse files
committed
[clang][bytecode] Fix discarding ImplitiValueInitExprs
1 parent 7925a9e commit cdae331

File tree

2 files changed

+12
-0
lines changed

2 files changed

+12
-0
lines changed

clang/lib/AST/ByteCode/Compiler.cpp

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1705,6 +1705,9 @@ bool Compiler<Emitter>::VisitFixedPointUnaryOperator(const UnaryOperator *E) {
17051705
template <class Emitter>
17061706
bool Compiler<Emitter>::VisitImplicitValueInitExpr(
17071707
const ImplicitValueInitExpr *E) {
1708+
if (DiscardResult)
1709+
return true;
1710+
17081711
QualType QT = E->getType();
17091712

17101713
if (OptPrimType T = classify(QT))

clang/test/AST/ByteCode/c.c

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -392,3 +392,12 @@ void plainComplex(void) {
392392
_Complex cd; // all-warning {{_Complex double}}
393393
cd = *(_Complex *)&(struct { double r, i; }){0.0, 0.0}; // all-warning {{_Complex double}}
394394
}
395+
396+
/// This test results in an ImplicitValueInitExpr with DiscardResult set.
397+
struct M{};
398+
typedef struct S64 {
399+
struct M m;
400+
char a[64];
401+
} I64;
402+
403+
_Static_assert((((I64){}, 1)), ""); // all-warning {{left operand of comma operator has no effect}}

0 commit comments

Comments
 (0)