diff --git a/clang/lib/AST/ByteCode/Compiler.cpp b/clang/lib/AST/ByteCode/Compiler.cpp index fafec47f7de3c..7518cfd2cf94d 100644 --- a/clang/lib/AST/ByteCode/Compiler.cpp +++ b/clang/lib/AST/ByteCode/Compiler.cpp @@ -1787,7 +1787,12 @@ bool Compiler::VisitArraySubscriptExpr(const ArraySubscriptExpr *E) { return false; if (DiscardResult) return this->emitPopPtr(E); - return true; + + if (E->isGLValue()) + return true; + + OptPrimType T = classifyPrim(E); + return this->emitLoadPop(*T, E); } template diff --git a/clang/test/AST/ByteCode/c.c b/clang/test/AST/ByteCode/c.c index 6681a4f427093..657a920e7d02c 100644 --- a/clang/test/AST/ByteCode/c.c +++ b/clang/test/AST/ByteCode/c.c @@ -368,3 +368,7 @@ void discardedCmp(void) { (*_b) = ((&a == &a) , a); // all-warning {{left operand of comma operator has no effect}} } + +/// ArraySubscriptExpr that's not an lvalue +typedef unsigned char U __attribute__((vector_size(1))); +void nonLValueASE(U f) { f[0] = f[((U)(U){0})[0]]; }