-
Notifications
You must be signed in to change notification settings - Fork 14.3k
[clang][bytecode] Diagnose non-const initialiers in diagnoseUnknownDecl #113276
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
@llvm/pr-subscribers-clang Author: Timm Baeder (tbaederr) ChangesThis 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:
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();
};
|
This is more similar to the diagnostic output of the current interpreter
73e6cd0
to
093e6ee
Compare
LLVM Buildbot has detected a new failure on builder Full details are available at: https://lab.llvm.org/buildbot/#/builders/55/builds/3007 Here is the relevant piece of the build log for the reference
|
This is more similar to the diagnostic output of the current interpreter