Skip to content

Commit

Permalink
[CIR][CIRGen] Add handling __extension__ keyword for lvalue (#519)
Browse files Browse the repository at this point in the history
This change is taken from the original codegen
  • Loading branch information
YazZz1k authored and lanza committed Mar 30, 2024
1 parent d4b70df commit 330c983
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 1 deletion.
3 changes: 2 additions & 1 deletion clang/lib/CIR/CodeGen/CIRGenExpr.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1012,7 +1012,8 @@ mlir::Value CIRGenFunction::evaluateExprAsBool(const Expr *E) {

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

switch (E->getOpcode()) {
default:
Expand Down
8 changes: 8 additions & 0 deletions clang/test/CIR/CodeGen/gnu-extension.c
Original file line number Diff line number Diff line change
Expand Up @@ -9,3 +9,11 @@ int foo(void) { return __extension__ 0b101010; }
//CHECK-NEXT: cir.store [[VAL]], [[ADDR]] : !s32i, cir.ptr <!s32i>
//CHECK-NEXT: [[LOAD_VAL:%.*]] = cir.load [[ADDR]] : cir.ptr <!s32i>, !s32i
//CHECK-NEXT: cir.return [[LOAD_VAL]] : !s32i

void bar(void) {
__extension__ bar;
}

//CHECK: cir.func @bar()
//CHECK: {{.*}} = cir.get_global @bar : cir.ptr <!cir.func<!void ()>>
//CHECK: cir.return

0 comments on commit 330c983

Please sign in to comment.