Skip to content

Conversation

tbaederr
Copy link
Contributor

@tbaederr tbaederr commented Aug 9, 2025

This is the correct function to use and it will create a variable scope.

Fixes #152822

@llvmbot llvmbot added clang Clang issues not falling into any other category clang:frontend Language frontend issues, e.g. anything involving "Sema" clang:bytecode Issues for the clang bytecode constexpr interpreter labels Aug 9, 2025
@llvmbot
Copy link
Member

llvmbot commented Aug 9, 2025

@llvm/pr-subscribers-clang

Author: Timm Baeder (tbaederr)

Changes

This is the correct function to use and it will create a variable scope.

Fixes #152822


Full diff: https://github.com/llvm/llvm-project/pull/152857.diff

2 Files Affected:

  • (modified) clang/lib/AST/ByteCode/EvalEmitter.cpp (+1-1)
  • (modified) clang/test/AST/ByteCode/functions.cpp (+5)
diff --git a/clang/lib/AST/ByteCode/EvalEmitter.cpp b/clang/lib/AST/ByteCode/EvalEmitter.cpp
index 9ed61c7b0be78..ecd42012987d4 100644
--- a/clang/lib/AST/ByteCode/EvalEmitter.cpp
+++ b/clang/lib/AST/ByteCode/EvalEmitter.cpp
@@ -98,7 +98,7 @@ bool EvalEmitter::interpretCall(const FunctionDecl *FD, const Expr *E) {
     this->Params.insert({PD, {0, false}});
   }
 
-  if (!this->visit(E))
+  if (!this->visitExpr(E, /*DestroyToplevelScope=*/true))
     return false;
   PrimType T = Ctx.classify(E).value_or(PT_Ptr);
   return this->emitPop(T, E);
diff --git a/clang/test/AST/ByteCode/functions.cpp b/clang/test/AST/ByteCode/functions.cpp
index 36e7bb32b2d86..0a38122df4fc8 100644
--- a/clang/test/AST/ByteCode/functions.cpp
+++ b/clang/test/AST/ByteCode/functions.cpp
@@ -708,3 +708,8 @@ namespace NoDiags {
     return true;
   }
 }
+
+namespace EnableIfWithTemporary {
+  struct A { ~A(); };
+  int &h() __attribute__((enable_if((A(), true), "")));
+}

This is the correct function to use and it will create a variable scope.

Fixes llvm#152822
@tbaederr tbaederr merged commit 870aa97 into llvm:main Aug 9, 2025
9 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

clang:bytecode Issues for the clang bytecode constexpr interpreter clang:frontend Language frontend issues, e.g. anything involving "Sema" clang Clang issues not falling into any other category

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[clang] -fexperimental-new-constant-interpreter option causes a crash

2 participants