[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:
Timm Baeder
2024-09-21 09:58:56 +02:00
committed by GitHub
parent f5f61c802e
commit c57b9f5a13
2 changed files with 6 additions and 3 deletions

View File

@@ -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()) {

View File

@@ -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();