[clang] [clang][bytecode] Limit "... variable whose value is not known" diags (PR #175287)
via cfe-commits
cfe-commits at lists.llvm.org
Fri Jan 9 22:16:58 PST 2026
llvmbot wrote:
<!--LLVM PR SUMMARY COMMENT-->
@llvm/pr-subscribers-clang
Author: Timm Baeder (tbaederr)
<details>
<summary>Changes</summary>
To variables with reference types.
---
Full diff: https://github.com/llvm/llvm-project/pull/175287.diff
2 Files Affected:
- (modified) clang/lib/AST/ByteCode/Interp.cpp (+2-2)
- (modified) clang/test/SemaTemplate/deduction.cpp (+2-3)
``````````diff
diff --git a/clang/lib/AST/ByteCode/Interp.cpp b/clang/lib/AST/ByteCode/Interp.cpp
index 0a083a4990856..7e901aa65af1c 100644
--- a/clang/lib/AST/ByteCode/Interp.cpp
+++ b/clang/lib/AST/ByteCode/Interp.cpp
@@ -137,7 +137,7 @@ static void diagnoseNonConstVariable(InterpState &S, CodePtr OpPC,
static bool diagnoseUnknownDecl(InterpState &S, CodePtr OpPC,
const ValueDecl *D) {
// This function tries pretty hard to produce a good diagnostic. Just skip
- // tha if nobody will see it anyway.
+ // that if nobody will see it anyway.
if (!S.diagnosing())
return false;
@@ -151,7 +151,7 @@ static bool diagnoseUnknownDecl(InterpState &S, CodePtr OpPC,
}
const SourceInfo &Loc = S.Current->getSource(OpPC);
- if (S.getLangOpts().CPlusPlus23) {
+ if (S.getLangOpts().CPlusPlus23 && D->getType()->isReferenceType()) {
S.FFDiag(Loc, diag::note_constexpr_access_unknown_variable, 1)
<< AK_Read << D;
S.Note(D->getLocation(), diag::note_declared_at) << D->getSourceRange();
diff --git a/clang/test/SemaTemplate/deduction.cpp b/clang/test/SemaTemplate/deduction.cpp
index a209615c36479..7be3f732508d7 100644
--- a/clang/test/SemaTemplate/deduction.cpp
+++ b/clang/test/SemaTemplate/deduction.cpp
@@ -1,6 +1,5 @@
-// RUN: %clang_cc1 -fsyntax-only -verify %s -std=c++11
-// RUN: %clang_cc1 -fsyntax-only -verify %s -std=c++17
-// RUN: %clang_cc1 -fsyntax-only -verify %s -std=c++23
+// RUN: %clang_cc1 -fsyntax-only -verify %s %std_cxx11-
+// RUN: %clang_cc1 -fsyntax-only -verify %s %std_cxx11- -fexperimental-new-constant-interpreter
// Template argument deduction with template template parameters.
template<typename T, template<T> class A>
``````````
</details>
https://github.com/llvm/llvm-project/pull/175287
More information about the cfe-commits
mailing list