[PATCH] D148690: [clang][Interp] Handle __extension__ unary operators

Timm Bäder via Phabricator via cfe-commits cfe-commits at lists.llvm.org
Wed Apr 19 00:16:14 PDT 2023


tbaeder created this revision.
tbaeder added reviewers: aaron.ballman, tahonermann, shafik, erichkeane.
Herald added a project: All.
tbaeder requested review of this revision.
Herald added a project: clang.
Herald added a subscriber: cfe-commits.

AFAIK this is just used to suppress warnings, so ignore it altogether.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D148690

Files:
  clang/lib/AST/Interp/ByteCodeExprGen.cpp
  clang/test/AST/Interp/literals.cpp


Index: clang/test/AST/Interp/literals.cpp
===================================================================
--- clang/test/AST/Interp/literals.cpp
+++ clang/test/AST/Interp/literals.cpp
@@ -782,6 +782,12 @@
 
 namespace PredefinedExprs {
   constexpr char heh(unsigned index) {
+#if __cplusplus >= 201402L
+    __FUNCTION__;               // ref-warning {{result unused}} \
+                                // expected-warning {{result unused}}
+    __extension__ __FUNCTION__; // ref-warning {{result unused}} \
+                                // expected-warning {{result unused}}
+#endif
     return __FUNCTION__[index];
   }
   static_assert(heh(0) == 'h', "");
Index: clang/lib/AST/Interp/ByteCodeExprGen.cpp
===================================================================
--- clang/lib/AST/Interp/ByteCodeExprGen.cpp
+++ clang/lib/AST/Interp/ByteCodeExprGen.cpp
@@ -1856,6 +1856,9 @@
   case UO_Real:   // __real x
   case UO_Imag:   // __imag x
   case UO_Extension:
+    if (DiscardResult)
+      return this->discard(SubExpr);
+    return this->visit(SubExpr);
   case UO_Coawait:
     assert(false && "Unhandled opcode");
   }


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D148690.514844.patch
Type: text/x-patch
Size: 1144 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20230419/e2ae6e59/attachment.bin>


More information about the cfe-commits mailing list