@@ -1344,6 +1344,16 @@ bool Compiler<Emitter>::VisitArraySubscriptExpr(const ArraySubscriptExpr *E) {
1344
1344
template <class Emitter >
1345
1345
bool Compiler<Emitter>::visitInitList(ArrayRef<const Expr *> Inits,
1346
1346
const Expr *ArrayFiller, const Expr *E) {
1347
+ QualType QT = E->getType ();
1348
+ if (const auto *AT = QT->getAs <AtomicType>())
1349
+ QT = AT->getValueType ();
1350
+
1351
+ if (QT->isVoidType ()) {
1352
+ if (Inits.size () == 0 )
1353
+ return true ;
1354
+ return this ->emitInvalid (E);
1355
+ }
1356
+
1347
1357
// Handle discarding first.
1348
1358
if (DiscardResult) {
1349
1359
for (const Expr *Init : Inits) {
@@ -1353,13 +1363,6 @@ bool Compiler<Emitter>::visitInitList(ArrayRef<const Expr *> Inits,
1353
1363
return true ;
1354
1364
}
1355
1365
1356
- QualType QT = E->getType ();
1357
- if (const auto *AT = QT->getAs <AtomicType>())
1358
- QT = AT->getValueType ();
1359
-
1360
- if (QT->isVoidType ())
1361
- return this ->emitInvalid (E);
1362
-
1363
1366
// Primitive values.
1364
1367
if (std::optional<PrimType> T = classify (QT)) {
1365
1368
assert (!DiscardResult);
@@ -3272,9 +3275,12 @@ template <class Emitter> bool Compiler<Emitter>::visit(const Expr *E) {
3272
3275
if (E->getType ().isNull ())
3273
3276
return false ;
3274
3277
3278
+ if (E->getType ()->isVoidType ())
3279
+ return this ->discard (E);
3280
+
3275
3281
// Create local variable to hold the return value.
3276
- if (!E->getType ()-> isVoidType () && !E->isGLValue () &&
3277
- !E-> getType ()-> isAnyComplexType () && ! classify (E->getType ())) {
3282
+ if (!E->isGLValue () && !E->getType ()-> isAnyComplexType () &&
3283
+ !classify (E->getType ())) {
3278
3284
std::optional<unsigned > LocalIndex = allocateLocal (E);
3279
3285
if (!LocalIndex)
3280
3286
return false ;
@@ -5174,7 +5180,7 @@ bool Compiler<Emitter>::VisitUnaryOperator(const UnaryOperator *E) {
5174
5180
// We should already have a pointer when we get here.
5175
5181
return this ->delegate (SubExpr);
5176
5182
case UO_Deref: // *x
5177
- if (DiscardResult || E-> getType ()-> isVoidType () )
5183
+ if (DiscardResult)
5178
5184
return this ->discard (SubExpr);
5179
5185
return this ->visit (SubExpr);
5180
5186
case UO_Not: // ~x
0 commit comments