Skip to content

Commit c45466c

Browse files
authored
[clang][Interp] Only emit function_param_value_unknown in C++11 (#67990)
This is also what the current interpreter does.
1 parent b44763c commit c45466c

File tree

2 files changed

+9
-6
lines changed

2 files changed

+9
-6
lines changed

clang/lib/AST/Interp/Interp.cpp

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -555,8 +555,12 @@ bool CheckDeclRef(InterpState &S, CodePtr OpPC, const DeclRefExpr *DR) {
555555
const SourceInfo &E = S.Current->getSource(OpPC);
556556

557557
if (isa<ParmVarDecl>(D)) {
558-
S.FFDiag(E, diag::note_constexpr_function_param_value_unknown) << D;
559-
S.Note(D->getLocation(), diag::note_declared_at) << D->getSourceRange();
558+
if (S.getLangOpts().CPlusPlus11) {
559+
S.FFDiag(E, diag::note_constexpr_function_param_value_unknown) << D;
560+
S.Note(D->getLocation(), diag::note_declared_at) << D->getSourceRange();
561+
} else {
562+
S.FFDiag(E);
563+
}
560564
} else if (const auto *VD = dyn_cast<VarDecl>(D)) {
561565
if (!VD->getType().isConstQualified()) {
562566
S.FFDiag(E,

clang/test/SemaCXX/offsetof.cpp

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
// RUN: %clang_cc1 -triple x86_64-apple-darwin10.0.0 -fsyntax-only -verify %s -Winvalid-offsetof -std=c++98
2-
// 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
2+
// RUN: %clang_cc1 -triple x86_64-apple-darwin10.0.0 -fsyntax-only -verify %s -Winvalid-offsetof -std=c++98 -fexperimental-new-constant-interpreter
33

44
struct NonPOD {
55
virtual void f();
@@ -25,10 +25,9 @@ struct HasArray {
2525
};
2626

2727
// Constant and non-constant offsetof expressions
28-
void test_ice(int i) { // new-interp-note {{declared here}}
28+
void test_ice(int i) {
2929
int array0[__builtin_offsetof(HasArray, array[5])];
30-
int array1[__builtin_offsetof(HasArray, array[i])]; // expected-warning {{variable length arrays in C++ are a Clang extension}} \
31-
new-interp-note {{function parameter 'i' with unknown value cannot be used in a constant expression}}
30+
int array1[__builtin_offsetof(HasArray, array[i])]; // expected-warning {{variable length arrays in C++ are a Clang extension}}
3231
}
3332

3433
// Bitfields

0 commit comments

Comments
 (0)