[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 23 06:21:39 PDT 2023
Timm =?utf-8?q?Bäder?= <tbaeder at redhat.com>
Message-ID:
In-Reply-To: <llvm/llvm-project/pull/67990/clang at github.com>
https://github.com/tbaederr updated https://github.com/llvm/llvm-project/pull/67990
>From 0056d67f145fd0d5f8056325bc70246314c9b117 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 1/2] [clang][Interp] Only emit function_param_value_unknown in
C++11
---
clang/lib/AST/Interp/Interp.cpp | 8 ++++++--
clang/test/SemaCXX/offsetof.cpp | 7 +++----
2 files changed, 9 insertions(+), 6 deletions(-)
diff --git a/clang/lib/AST/Interp/Interp.cpp b/clang/lib/AST/Interp/Interp.cpp
index a4d6844ebe61722..8b0e7beb4a1acc1 100644
--- a/clang/lib/AST/Interp/Interp.cpp
+++ b/clang/lib/AST/Interp/Interp.cpp
@@ -555,8 +555,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,
diff --git a/clang/test/SemaCXX/offsetof.cpp b/clang/test/SemaCXX/offsetof.cpp
index cb91f2bed0b9224..f54ee06c43147dd 100644
--- a/clang/test/SemaCXX/offsetof.cpp
+++ b/clang/test/SemaCXX/offsetof.cpp
@@ -1,5 +1,5 @@
// RUN: %clang_cc1 -triple x86_64-apple-darwin10.0.0 -fsyntax-only -verify %s -Winvalid-offsetof -std=c++98
-// RUN: %clang_cc1 -triple x86_64-apple-darwin10.0.0 -fsyntax-only -verify=expected,new-interp %s -Winvalid-offsetof -std=c++98 -fexperimental-new-constant-interpreter
+// RUN: %clang_cc1 -triple x86_64-apple-darwin10.0.0 -fsyntax-only -verify=expected %s -Winvalid-offsetof -std=c++98 -fexperimental-new-constant-interpreter
struct NonPOD {
virtual void f();
@@ -25,10 +25,9 @@ struct HasArray {
};
// Constant and non-constant offsetof expressions
-void test_ice(int i) { // new-interp-note {{declared here}}
+void test_ice(int i) {
int array0[__builtin_offsetof(HasArray, array[5])];
- int array1[__builtin_offsetof(HasArray, array[i])]; // expected-warning {{variable length arrays in C++ are a Clang extension}} \
- new-interp-note {{function parameter 'i' with unknown value cannot be used in a constant expression}}
+ int array1[__builtin_offsetof(HasArray, array[i])]; // expected-warning {{variable length arrays in C++ are a Clang extension}}
}
// Bitfields
>From d1c4e6dd573ac38d0190286e263c03e00fdee49b Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Timm=20B=C3=A4der?= <tbaeder at redhat.com>
Date: Mon, 23 Oct 2023 15:21:13 +0200
Subject: [PATCH 2/2] Remove =expected from test case
---
clang/test/SemaCXX/offsetof.cpp | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/clang/test/SemaCXX/offsetof.cpp b/clang/test/SemaCXX/offsetof.cpp
index f54ee06c43147dd..1722b91fafc8696 100644
--- a/clang/test/SemaCXX/offsetof.cpp
+++ b/clang/test/SemaCXX/offsetof.cpp
@@ -1,5 +1,5 @@
// RUN: %clang_cc1 -triple x86_64-apple-darwin10.0.0 -fsyntax-only -verify %s -Winvalid-offsetof -std=c++98
-// RUN: %clang_cc1 -triple x86_64-apple-darwin10.0.0 -fsyntax-only -verify=expected %s -Winvalid-offsetof -std=c++98 -fexperimental-new-constant-interpreter
+// RUN: %clang_cc1 -triple x86_64-apple-darwin10.0.0 -fsyntax-only -verify %s -Winvalid-offsetof -std=c++98 -fexperimental-new-constant-interpreter
struct NonPOD {
virtual void f();
More information about the cfe-commits
mailing list