Author: Timm Bäder
Date: 2024-07-14T07:28:02+02:00
New Revision: 7645823564a34db84f0da53e53e38eb0ceb429ec

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

LOG: [clang][Interp] Don't require StmtExpr result to be an expression

It can be a statement containing an expression.

Added: 
    

Modified: 
    clang/lib/AST/Interp/Compiler.cpp
    clang/test/CodeGenCXX/cxx1z-constexpr-if.cpp

Removed: 
    


################################################################################
diff  --git a/clang/lib/AST/Interp/Compiler.cpp 
b/clang/lib/AST/Interp/Compiler.cpp
index 48e7519f8f89d..209fb54ecdcb5 100644
--- a/clang/lib/AST/Interp/Compiler.cpp
+++ b/clang/lib/AST/Interp/Compiler.cpp
@@ -3073,13 +3073,13 @@ bool Compiler<Emitter>::VisitStmtExpr(const StmtExpr 
*E) {
     }
 
     assert(S == Result);
-    // This better produces a value (i.e. is an expression).
     if (const Expr *ResultExpr = dyn_cast<Expr>(S)) {
       if (DiscardResult)
         return this->discard(ResultExpr);
       return this->delegate(ResultExpr);
     }
-    return false;
+
+    return this->visitStmt(S);
   }
 
   return BS.destroyLocals();

diff  --git a/clang/test/CodeGenCXX/cxx1z-constexpr-if.cpp 
b/clang/test/CodeGenCXX/cxx1z-constexpr-if.cpp
index d14e36406a45e..5a11afb8dec40 100644
--- a/clang/test/CodeGenCXX/cxx1z-constexpr-if.cpp
+++ b/clang/test/CodeGenCXX/cxx1z-constexpr-if.cpp
@@ -1,4 +1,5 @@
 // RUN: %clang_cc1 -std=c++1z %s -emit-llvm -fblocks -triple 
x86_64-apple-darwin10 -o - | FileCheck %s 
--implicit-check-not=should_not_be_used
+// RUN: %clang_cc1 -std=c++1z %s -emit-llvm -fblocks -triple 
x86_64-apple-darwin10 -o - -fexperimental-new-constant-interpreter | FileCheck 
%s --implicit-check-not=should_not_be_used
 
 void should_be_used_1();
 void should_be_used_2();


        
_______________________________________________
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

Reply via email to