https://github.com/tbaederr created https://github.com/llvm/llvm-project/pull/175287
To variables with reference types. >From 5a29e993713bb41f054f14a7dc645db006e62399 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Timm=20B=C3=A4der?= <[email protected]> Date: Sat, 10 Jan 2026 07:13:40 +0100 Subject: [PATCH] [clang][bytecode] Limit "... variable whose value is not known" diags To variables with reference types. --- clang/lib/AST/ByteCode/Interp.cpp | 4 ++-- clang/test/SemaTemplate/deduction.cpp | 5 ++--- 2 files changed, 4 insertions(+), 5 deletions(-) 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> _______________________________________________ cfe-commits mailing list [email protected] https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
