Skip to content

Commit ed3955a

Browse files
authored
[CIR][CIRGen] Add handling __extension__ keyword for lvalue (#519)
This change is taken from the original codegen
1 parent 33a6861 commit ed3955a

File tree

2 files changed

+10
-1
lines changed

2 files changed

+10
-1
lines changed

clang/lib/CIR/CodeGen/CIRGenExpr.cpp

+2-1
Original file line numberDiff line numberDiff line change
@@ -1012,7 +1012,8 @@ mlir::Value CIRGenFunction::evaluateExprAsBool(const Expr *E) {
10121012

10131013
LValue CIRGenFunction::buildUnaryOpLValue(const UnaryOperator *E) {
10141014
// __extension__ doesn't affect lvalue-ness.
1015-
assert(E->getOpcode() != UO_Extension && "not implemented");
1015+
if (E->getOpcode() == UO_Extension)
1016+
return buildLValue(E->getSubExpr());
10161017

10171018
switch (E->getOpcode()) {
10181019
default:

clang/test/CIR/CodeGen/gnu-extension.c

+8
Original file line numberDiff line numberDiff line change
@@ -9,3 +9,11 @@ int foo(void) { return __extension__ 0b101010; }
99
//CHECK-NEXT: cir.store [[VAL]], [[ADDR]] : !s32i, cir.ptr <!s32i>
1010
//CHECK-NEXT: [[LOAD_VAL:%.*]] = cir.load [[ADDR]] : cir.ptr <!s32i>, !s32i
1111
//CHECK-NEXT: cir.return [[LOAD_VAL]] : !s32i
12+
13+
void bar(void) {
14+
__extension__ bar;
15+
}
16+
17+
//CHECK: cir.func @bar()
18+
//CHECK: {{.*}} = cir.get_global @bar : cir.ptr <!cir.func<!void ()>>
19+
//CHECK: cir.return

0 commit comments

Comments
 (0)