[clang] [clang][Interp] Only emit function_param_value_unknown in C++11 (PR #67990)

Timm Baeder via cfe-commits cfe-commits at lists.llvm.org
Mon Oct 2 07:29:54 PDT 2023


https://github.com/tbaederr created https://github.com/llvm/llvm-project/pull/67990

This is also what the current interpreter does.

No test for now since the only reproducer I have is from https://reviews.llvm.org/D156565 and doesn't work without that patch.

>From 5e43ab378e64ea8a852f8bf5571dab537f293c77 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Timm=20B=C3=A4der?= <tbaeder at redhat.com>
Date: Mon, 2 Oct 2023 16:26:46 +0200
Subject: [PATCH] [clang][Interp] Only emit function_param_value_unknown in
 C++11

---
 clang/lib/AST/Interp/Interp.cpp | 8 ++++++--
 1 file changed, 6 insertions(+), 2 deletions(-)

diff --git a/clang/lib/AST/Interp/Interp.cpp b/clang/lib/AST/Interp/Interp.cpp
index e1951574edb6288..9772f612b409ea3 100644
--- a/clang/lib/AST/Interp/Interp.cpp
+++ b/clang/lib/AST/Interp/Interp.cpp
@@ -549,8 +549,12 @@ bool CheckDeclRef(InterpState &S, CodePtr OpPC, const DeclRefExpr *DR) {
   const SourceInfo &E = S.Current->getSource(OpPC);
 
   if (isa<ParmVarDecl>(D)) {
-    S.FFDiag(E, diag::note_constexpr_function_param_value_unknown) << D;
-    S.Note(D->getLocation(), diag::note_declared_at) << D->getSourceRange();
+    if (S.getLangOpts().CPlusPlus11) {
+      S.FFDiag(E, diag::note_constexpr_function_param_value_unknown) << D;
+      S.Note(D->getLocation(), diag::note_declared_at) << D->getSourceRange();
+    } else {
+      S.FFDiag(E);
+    }
   } else if (const auto *VD = dyn_cast<VarDecl>(D)) {
     if (!VD->getType().isConstQualified()) {
       S.FFDiag(E,



More information about the cfe-commits mailing list