diff --git a/clang/lib/CIR/CodeGen/CIRGenExpr.cpp b/clang/lib/CIR/CodeGen/CIRGenExpr.cpp index 15e81143062c..a5fd4c6f774d 100644 --- a/clang/lib/CIR/CodeGen/CIRGenExpr.cpp +++ b/clang/lib/CIR/CodeGen/CIRGenExpr.cpp @@ -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: diff --git a/clang/test/CIR/CodeGen/gnu-extension.c b/clang/test/CIR/CodeGen/gnu-extension.c index 9c12aa2877ce..960ef277053a 100644 --- a/clang/test/CIR/CodeGen/gnu-extension.c +++ b/clang/test/CIR/CodeGen/gnu-extension.c @@ -9,3 +9,11 @@ int foo(void) { return __extension__ 0b101010; } //CHECK-NEXT: cir.store [[VAL]], [[ADDR]] : !s32i, cir.ptr //CHECK-NEXT: [[LOAD_VAL:%.*]] = cir.load [[ADDR]] : cir.ptr , !s32i //CHECK-NEXT: cir.return [[LOAD_VAL]] : !s32i + +void bar(void) { + __extension__ bar; +} + +//CHECK: cir.func @bar() +//CHECK: {{.*}} = cir.get_global @bar : cir.ptr > +//CHECK: cir.return