[clang] a2535a5 - [clang][Interp] Remove assertion to fix comma operators...

Timm Bäder via cfe-commits cfe-commits at lists.llvm.org
Mon Feb 19 02:16:49 PST 2024


Author: Timm Bäder
Date: 2024-02-19T11:16:35+01:00
New Revision: a2535a5786894c54fb657f3b142ce88e8810e1ea

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

LOG: [clang][Interp] Remove assertion to fix comma operators...

... involving function pointers on the RHS. The conversion to
an RValue _can_ be requested, but we just ignore it.

Added: 
    clang/test/AST/Interp/comma.cpp

Modified: 
    clang/lib/AST/Interp/EvalEmitter.cpp

Removed: 
    


################################################################################
diff  --git a/clang/lib/AST/Interp/EvalEmitter.cpp b/clang/lib/AST/Interp/EvalEmitter.cpp
index 6715921ff1d975..d90cf1812bb774 100644
--- a/clang/lib/AST/Interp/EvalEmitter.cpp
+++ b/clang/lib/AST/Interp/EvalEmitter.cpp
@@ -152,7 +152,6 @@ template <> bool EvalEmitter::emitRet<PT_FnPtr>(const SourceInfo &Info) {
   if (!isActive())
     return true;
   // Function pointers cannot be converted to rvalues.
-  assert(!ConvertResultToRValue);
   EvalResult.setFunctionPointer(S.Stk.pop<FunctionPointer>());
   return true;
 }

diff  --git a/clang/test/AST/Interp/comma.cpp b/clang/test/AST/Interp/comma.cpp
new file mode 100644
index 00000000000000..795958e90b0921
--- /dev/null
+++ b/clang/test/AST/Interp/comma.cpp
@@ -0,0 +1,10 @@
+// RUN: %clang_cc1 -fsyntax-only -verify %s
+// RUN: %clang_cc1 -fsyntax-only -verify %s -fexperimental-new-constant-interpreter
+// expected-no-diagnostics
+
+// PR6076
+void f();
+void (&g)() = (void(), f);
+
+int a[1];
+int (&b)[1] = (void(), a);


        


More information about the cfe-commits mailing list