[llvm-branch-commits] [clang] [clang] fix error: cannot compile this l-value expression yet (#187755) (PR #188084)
Joe Kirchoff via llvm-branch-commits
llvm-branch-commits at lists.llvm.org
Tue Apr 7 11:06:22 PDT 2026
https://github.com/Rinn updated https://github.com/llvm/llvm-project/pull/188084
>From 4b2b8343dad5e5ada09f4bea55cd0b79d908d925 Mon Sep 17 00:00:00 2001
From: Joe Kirchoff <Kirchoff.Joseph.P at gmail.com>
Date: Fri, 20 Mar 2026 16:30:53 -0700
Subject: [PATCH 1/2] [clang] fix error: cannot compile this l-value expression
yet (#187755)
---
clang/docs/ReleaseNotes.rst | 1 +
clang/lib/AST/Expr.cpp | 2 +-
clang/test/CodeGenCXX/builtin_FUNCTION.cpp | 17 +++++++++++++++++
3 files changed, 19 insertions(+), 1 deletion(-)
diff --git a/clang/docs/ReleaseNotes.rst b/clang/docs/ReleaseNotes.rst
index d4c6025ee0638..07993d6f7bc1f 100644
--- a/clang/docs/ReleaseNotes.rst
+++ b/clang/docs/ReleaseNotes.rst
@@ -675,6 +675,7 @@ Miscellaneous Clang Crashes Fixed
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
- Fixed a crash when attempting to jump over initialization of a variable with variably modified type. (#GH175540)
+- Fixed a crash when ``decltype(__builtin_FUNCTION())`` is used as a template type argument. (#GH167433)
OpenACC Specific Changes
------------------------
diff --git a/clang/lib/AST/Expr.cpp b/clang/lib/AST/Expr.cpp
index 4bb979e51b75d..d3e381ba4bb3f 100644
--- a/clang/lib/AST/Expr.cpp
+++ b/clang/lib/AST/Expr.cpp
@@ -2254,7 +2254,7 @@ SourceLocExpr::SourceLocExpr(const ASTContext &Ctx, SourceLocIdentKind Kind,
SourceLocExprBits.Kind = llvm::to_underlying(Kind);
// In dependent contexts, function names may change.
setDependence(MayBeDependent(Kind) && ParentContext->isDependentContext()
- ? ExprDependence::Value
+ ? ExprDependence::ValueInstantiation
: ExprDependence::None);
}
diff --git a/clang/test/CodeGenCXX/builtin_FUNCTION.cpp b/clang/test/CodeGenCXX/builtin_FUNCTION.cpp
index 44821b92d33fe..02d85239ec554 100644
--- a/clang/test/CodeGenCXX/builtin_FUNCTION.cpp
+++ b/clang/test/CodeGenCXX/builtin_FUNCTION.cpp
@@ -39,3 +39,20 @@ void do_default_arg_test() {
}
} // namespace test_func
+
+namespace test_decltype_template {
+
+template <typename> void template_func() {}
+
+// CHECK: define linkonce_odr {{(dso_local )?}}void @_ZN22test_decltype_template21use_decltype_templateIiEEvv(
+// CHECK: call void @_ZN22test_decltype_template13template_funcIPKcEEvv()
+template <typename> void use_decltype_template() {
+ template_func<decltype(__builtin_FUNCTION())>();
+}
+
+// CHECK: define linkonce_odr {{(dso_local )?}}void @_ZN22test_decltype_template13template_funcIPKcEEvv()
+void do_decltype_template_test() {
+ use_decltype_template<int>();
+}
+
+} // namespace test_decltype_template
>From 6ca3fe3cc5f83b193d296700b7fa3bb8b327159f Mon Sep 17 00:00:00 2001
From: Matheus Izvekov <mizvekov at gmail.com>
Date: Sat, 4 Apr 2026 19:10:29 -0300
Subject: [PATCH 2/2] [clang] NFC: Add test case for #178324 and mark it as
fixed (#190490)
Issue #178324 was actually fixed by #187755
We lost the "declaration does not declare anything" warning since the
regression was introduced, but that was because:
1) Since #78436 we treat __builtin_FUNCSIG in a dependent context
effectivelly as if it contained a template parameter.
2) Our decltype implementation treats eexpressions containing template
parameters as if they were completely opaque (but alas this goes against
the spec, which says in [temp.type]p4 this should be looking only at
type dependence).
3) Since the decltype is opaque, we don't know what lookup will find, so
we can't issue the warning because we don't know if we are going to end
up with a type or an expression.
Fixes #178324
---
clang/test/SemaCXX/source_location.cpp | 10 ++++++++++
1 file changed, 10 insertions(+)
diff --git a/clang/test/SemaCXX/source_location.cpp b/clang/test/SemaCXX/source_location.cpp
index c8b65d6eab50d..eaa6cb04c5d1c 100644
--- a/clang/test/SemaCXX/source_location.cpp
+++ b/clang/test/SemaCXX/source_location.cpp
@@ -1081,3 +1081,13 @@ static_assert(X{}.
static_assert(X{}.
foo() == 10001);
}
+
+#ifdef MS
+namespace GH178324 {
+ struct a {
+ using e = int;
+ };
+ void current(const char * = __builtin_FUNCSIG());
+ template <class> void c() { decltype(a(current()))::e; }
+} // namespace GH178324
+#endif
More information about the llvm-branch-commits
mailing list