[clang] 7802fb5 - [clang][bytecode] Fix `__extension__` handling for vector operators (#118482)

via cfe-commits cfe-commits at lists.llvm.org
Tue Dec 3 05:48:58 PST 2024


Author: Timm Baeder
Date: 2024-12-03T14:48:55+01:00
New Revision: 7802fb5f514be327576b69569556ec9096e5fdd7

URL: https://github.com/llvm/llvm-project/commit/7802fb5f514be327576b69569556ec9096e5fdd7
DIFF: https://github.com/llvm/llvm-project/commit/7802fb5f514be327576b69569556ec9096e5fdd7.diff

LOG: [clang][bytecode] Fix `__extension__` handling for vector operators (#118482)

Don't reject them, but delegate to the subexpression.

Added: 
    

Modified: 
    clang/lib/AST/ByteCode/Compiler.cpp
    clang/test/AST/ByteCode/vectors.cpp

Removed: 
    


################################################################################
diff  --git a/clang/lib/AST/ByteCode/Compiler.cpp b/clang/lib/AST/ByteCode/Compiler.cpp
index 705ab1ec8e8ab6..eb102f1e5c7f22 100644
--- a/clang/lib/AST/ByteCode/Compiler.cpp
+++ b/clang/lib/AST/ByteCode/Compiler.cpp
@@ -5914,6 +5914,9 @@ bool Compiler<Emitter>::VisitVectorUnaryOperator(const UnaryOperator *E) {
     return this->discard(SubExpr);
 
   auto UnaryOp = E->getOpcode();
+  if (UnaryOp == UO_Extension)
+    return this->delegate(SubExpr);
+
   if (UnaryOp != UO_Plus && UnaryOp != UO_Minus && UnaryOp != UO_LNot &&
       UnaryOp != UO_Not && UnaryOp != UO_AddrOf)
     return this->emitInvalid(E);

diff  --git a/clang/test/AST/ByteCode/vectors.cpp b/clang/test/AST/ByteCode/vectors.cpp
index 08e2ca2adbf5cd..a04b678a623a1e 100644
--- a/clang/test/AST/ByteCode/vectors.cpp
+++ b/clang/test/AST/ByteCode/vectors.cpp
@@ -37,6 +37,7 @@ static_assert(arr4[1][0] == 0, "");
 static_assert(arr4[1][0] == 0, "");
 static_assert(arr4[1][0] == 0, "");
 
+constexpr VI4 B = __extension__(A);
 
 /// From constant-expression-cxx11.cpp
 namespace Vector {


        


More information about the cfe-commits mailing list