[clang] 69cd2d2 - [clang][Interp] Handle __extension__ for complex values

Timm Bäder via cfe-commits cfe-commits at lists.llvm.org
Sun Jun 9 05:58:57 PDT 2024


Author: Timm Bäder
Date: 2024-06-09T14:29:12+02:00
New Revision: 69cd2d288d465b01a120d7544e99061921c66c28

URL: https://github.com/llvm/llvm-project/commit/69cd2d288d465b01a120d7544e99061921c66c28
DIFF: https://github.com/llvm/llvm-project/commit/69cd2d288d465b01a120d7544e99061921c66c28.diff

LOG: [clang][Interp] Handle __extension__ for complex values

Added: 
    

Modified: 
    clang/lib/AST/Interp/ByteCodeExprGen.cpp
    clang/test/AST/Interp/complex.cpp

Removed: 
    


################################################################################
diff  --git a/clang/lib/AST/Interp/ByteCodeExprGen.cpp b/clang/lib/AST/Interp/ByteCodeExprGen.cpp
index 5eecc6921a062..05921e833d7cc 100644
--- a/clang/lib/AST/Interp/ByteCodeExprGen.cpp
+++ b/clang/lib/AST/Interp/ByteCodeExprGen.cpp
@@ -3839,6 +3839,9 @@ bool ByteCodeExprGen<Emitter>::VisitComplexUnaryOperator(
       return false;
     return DiscardResult ? this->emitPopPtr(E) : true;
 
+  case UO_Extension:
+    return this->delegate(SubExpr);
+
   default:
     return this->emitInvalid(E);
   }

diff  --git a/clang/test/AST/Interp/complex.cpp b/clang/test/AST/Interp/complex.cpp
index ea54df38a9eb8..003f33e092d25 100644
--- a/clang/test/AST/Interp/complex.cpp
+++ b/clang/test/AST/Interp/complex.cpp
@@ -117,6 +117,9 @@ static_assert(__imag(Doubles[3]) == 0.0, "");
 
 static_assert(~(0.5 + 1.5j) == (0.5 + -1.5j), "");
 
+static_assert(__extension__ __imag(A) == 0, "");
+static_assert(__imag(__extension__ A) == 0, "");
+
 void func(void) {
   __complex__ int arr;
   _Complex int result;


        


More information about the cfe-commits mailing list