llvmbot wrote:
<!--LLVM PR SUMMARY COMMENT--> @llvm/pr-subscribers-clang Author: Timm Baeder (tbaederr) <details> <summary>Changes</summary> This is more similar to the diagnostic output of the current interpreter --- Full diff: https://github.com/llvm/llvm-project/pull/113276.diff 2 Files Affected: - (modified) clang/lib/AST/ByteCode/Interp.cpp (+10-4) - (modified) clang/test/SemaCXX/c99-variable-length-array.cpp (+1) ``````````diff diff --git a/clang/lib/AST/ByteCode/Interp.cpp b/clang/lib/AST/ByteCode/Interp.cpp index fdc4b38b8aa6dc..b7a6c224c80f8e 100644 --- a/clang/lib/AST/ByteCode/Interp.cpp +++ b/clang/lib/AST/ByteCode/Interp.cpp @@ -81,11 +81,17 @@ static bool diagnoseUnknownDecl(InterpState &S, CodePtr OpPC, return false; } - if (!D->getType().isConstQualified()) + if (!D->getType().isConstQualified()) { diagnoseNonConstVariable(S, OpPC, D); - else if (const auto *VD = dyn_cast<VarDecl>(D); - VD && !VD->getAnyInitializer()) - diagnoseMissingInitializer(S, OpPC, VD); + } else if (const auto *VD = dyn_cast<VarDecl>(D)) { + if (!VD->getAnyInitializer()) { + diagnoseMissingInitializer(S, OpPC, VD); + } else { + const SourceInfo &Loc = S.Current->getSource(OpPC); + S.FFDiag(Loc, diag::note_constexpr_var_init_non_constant, 1) << VD; + S.Note(VD->getLocation(), diag::note_declared_at); + } + } return false; } diff --git a/clang/test/SemaCXX/c99-variable-length-array.cpp b/clang/test/SemaCXX/c99-variable-length-array.cpp index 82ddb0fd2e2337..d9eb65e4355c31 100644 --- a/clang/test/SemaCXX/c99-variable-length-array.cpp +++ b/clang/test/SemaCXX/c99-variable-length-array.cpp @@ -1,4 +1,5 @@ // RUN: %clang_cc1 -fsyntax-only -verify -Wvla-extension %s +// RUN: %clang_cc1 -fsyntax-only -verify -Wvla-extension %s -fexperimental-new-constant-interpreter struct NonPOD { NonPOD(); }; `````````` </details> https://github.com/llvm/llvm-project/pull/113276 _______________________________________________ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits