[clang][bytecode] Fix reporting non-constant variables in C (#109516)
We need to call FFDiag() to get the usual "invalid subexpression" diagnostic.
This commit is contained in:
@@ -90,10 +90,12 @@ static bool diagnoseUnknownDecl(InterpState &S, CodePtr OpPC,
|
||||
|
||||
static void diagnoseNonConstVariable(InterpState &S, CodePtr OpPC,
|
||||
const ValueDecl *VD) {
|
||||
if (!S.getLangOpts().CPlusPlus)
|
||||
return;
|
||||
|
||||
const SourceInfo &Loc = S.Current->getSource(OpPC);
|
||||
if (!S.getLangOpts().CPlusPlus) {
|
||||
S.FFDiag(Loc);
|
||||
return;
|
||||
}
|
||||
|
||||
if (const auto *VarD = dyn_cast<VarDecl>(VD);
|
||||
VarD && VarD->getType().isConstQualified() &&
|
||||
!VarD->getAnyInitializer()) {
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
// RUN: %clang_cc1 %s -fsyntax-only -verify
|
||||
// RUN: %clang_cc1 %s -fsyntax-only -verify -fexperimental-new-constant-interpreter
|
||||
|
||||
const char *some_function();
|
||||
|
||||
|
||||
Reference in New Issue
Block a user