[clang] [clang][bytecode] Reject functions with dependent return type (PR #194114)
Timm Baeder via cfe-commits
cfe-commits at lists.llvm.org
Fri Apr 24 21:58:52 PDT 2026
https://github.com/tbaederr created https://github.com/llvm/llvm-project/pull/194114
This unfortunately crashes the current interpreter as well.
>From e2cdfe8a613a40fe892a5ceb9b94405f9a6969dc Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Timm=20B=C3=A4der?= <tbaeder at redhat.com>
Date: Sat, 25 Apr 2026 06:57:55 +0200
Subject: [PATCH] [clang][bytecode] Reject functions with dependent return type
---
clang/lib/AST/ByteCode/Compiler.cpp | 3 +++
clang/test/AST/ByteCode/functions.cpp | 15 ++++++++++++---
2 files changed, 15 insertions(+), 3 deletions(-)
diff --git a/clang/lib/AST/ByteCode/Compiler.cpp b/clang/lib/AST/ByteCode/Compiler.cpp
index abdf4dca10cc2..5a0f90d514ad1 100644
--- a/clang/lib/AST/ByteCode/Compiler.cpp
+++ b/clang/lib/AST/ByteCode/Compiler.cpp
@@ -6882,6 +6882,9 @@ bool Compiler<Emitter>::compileUnionAssignmentOperator(
template <class Emitter>
bool Compiler<Emitter>::visitFunc(const FunctionDecl *F) {
+ if (F->getReturnType()->isDependentType())
+ return false;
+
// Classify the return type.
ReturnType = this->classify(F->getReturnType());
diff --git a/clang/test/AST/ByteCode/functions.cpp b/clang/test/AST/ByteCode/functions.cpp
index 5540ce0baf4bf..05dea564baec7 100644
--- a/clang/test/AST/ByteCode/functions.cpp
+++ b/clang/test/AST/ByteCode/functions.cpp
@@ -1,6 +1,6 @@
-// RUN: %clang_cc1 -pedantic -verify=expected,both %s -fexperimental-new-constant-interpreter
-// RUN: %clang_cc1 -std=c++14 -pedantic -verify=expected,both %s -fexperimental-new-constant-interpreter
-// RUN: %clang_cc1 -std=c++20 -pedantic -verify=expected,both %s -fexperimental-new-constant-interpreter
+// RUN: %clang_cc1 -pedantic -verify=expected,both %s -fexperimental-new-constant-interpreter -DINTERP
+// RUN: %clang_cc1 -std=c++14 -pedantic -verify=expected,both %s -fexperimental-new-constant-interpreter -DINTERP
+// RUN: %clang_cc1 -std=c++20 -pedantic -verify=expected,both %s -fexperimental-new-constant-interpreter -DINTERP
// RUN: %clang_cc1 -pedantic -verify=ref,both %s
// RUN: %clang_cc1 -std=c++14 -pedantic -verify=ref,both %s
// RUN: %clang_cc1 -std=c++20 -pedantic -verify=ref,both %s
@@ -765,3 +765,12 @@ namespace NestedDiags {
return true;
}
}
+
+#ifdef INTERP
+namespace DependentReturnType {
+ template <typename T> struct S {
+ int a = [] { return [](auto t) noexcept((zomg(f))) { return 0; }(0); }(); // both-error {{use of undeclared identifier 'zomg'}}
+ };
+ S<float> x;
+}
+#endif
More information about the cfe-commits
mailing list