Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions clang/lib/AST/ByteCode/Compiler.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1705,6 +1705,9 @@ bool Compiler<Emitter>::VisitFixedPointUnaryOperator(const UnaryOperator *E) {
template <class Emitter>
bool Compiler<Emitter>::VisitImplicitValueInitExpr(
const ImplicitValueInitExpr *E) {
if (DiscardResult)
return true;

QualType QT = E->getType();

if (OptPrimType T = classify(QT))
Expand Down
13 changes: 13 additions & 0 deletions clang/test/AST/ByteCode/c.c
Original file line number Diff line number Diff line change
Expand Up @@ -392,3 +392,16 @@ void plainComplex(void) {
_Complex cd; // all-warning {{_Complex double}}
cd = *(_Complex *)&(struct { double r, i; }){0.0, 0.0}; // all-warning {{_Complex double}}
}

/// This test results in an ImplicitValueInitExpr with DiscardResult set.
struct M{
char c;
};
typedef struct S64 {
struct M m;
char a[64];
} I64;

_Static_assert((((I64){}, 1)), ""); // all-warning {{left operand of comma operator has no effect}} \
// pedantic-warning {{use of an empty initializer is a C23 extension}} \
// pedantic-warning {{expression is not an integer constant expression; folding it to a constant is a GNU extension}}