Skip to content

Commit 242a1e2

Browse files
authored
[clang][bytecode] Load value of non-lvalue ArraySubscriptExpr (#160024)
As happens in C. Fixes #158482
1 parent ebcf1bf commit 242a1e2

File tree

2 files changed

+10
-1
lines changed

2 files changed

+10
-1
lines changed

clang/lib/AST/ByteCode/Compiler.cpp

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1787,7 +1787,12 @@ bool Compiler<Emitter>::VisitArraySubscriptExpr(const ArraySubscriptExpr *E) {
17871787
return false;
17881788
if (DiscardResult)
17891789
return this->emitPopPtr(E);
1790-
return true;
1790+
1791+
if (E->isGLValue())
1792+
return true;
1793+
1794+
OptPrimType T = classifyPrim(E);
1795+
return this->emitLoadPop(*T, E);
17911796
}
17921797

17931798
template <class Emitter>

clang/test/AST/ByteCode/c.c

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -368,3 +368,7 @@ void discardedCmp(void)
368368
{
369369
(*_b) = ((&a == &a) , a); // all-warning {{left operand of comma operator has no effect}}
370370
}
371+
372+
/// ArraySubscriptExpr that's not an lvalue
373+
typedef unsigned char U __attribute__((vector_size(1)));
374+
void nonLValueASE(U f) { f[0] = f[((U)(U){0})[0]]; }

0 commit comments

Comments
 (0)