llvmorg-github-actions[bot] wrote:
<!--LLVM PR SUMMARY COMMENT--> @llvm/pr-subscribers-clang Author: Timm Baeder (tbaederr) <details> <summary>Changes</summary> ... "read outside its lifetime" diagnostics. We should be pointing to the first decl. --- Full diff: https://github.com/llvm/llvm-project/pull/209696.diff 2 Files Affected: - (modified) clang/lib/AST/ByteCode/Interp.cpp (+2-3) - (modified) clang/test/AST/ByteCode/cxx11.cpp (+7) ``````````diff diff --git a/clang/lib/AST/ByteCode/Interp.cpp b/clang/lib/AST/ByteCode/Interp.cpp index 58bbf4aaf5f89..f4a5ddc99d95d 100644 --- a/clang/lib/AST/ByteCode/Interp.cpp +++ b/clang/lib/AST/ByteCode/Interp.cpp @@ -762,11 +762,10 @@ bool DiagnoseUninitialized(InterpState &S, CodePtr OpPC, bool Extern, // Diagnose as non-const read. diagnoseNonConstVariable(S, OpPC, VD); } else { - const SourceInfo &Loc = S.Current->getSource(OpPC); // Diagnose as "read of object outside its lifetime". - S.FFDiag(Loc, diag::note_constexpr_access_uninit) + S.FFDiag(S.Current->getSource(OpPC), diag::note_constexpr_access_uninit) << AK << /*IsIndeterminate=*/false; - S.Note(VD->getLocation(), diag::note_declared_at); + S.Note(VD->getFirstDecl()->getLocation(), diag::note_declared_at); } return false; } diff --git a/clang/test/AST/ByteCode/cxx11.cpp b/clang/test/AST/ByteCode/cxx11.cpp index 3553ab3ba68ad..1e3668f8f2e99 100644 --- a/clang/test/AST/ByteCode/cxx11.cpp +++ b/clang/test/AST/ByteCode/cxx11.cpp @@ -233,6 +233,13 @@ namespace ExternPointer { constexpr const int *pua = &pu.a; // Ok. } +namespace ExternRedecl { + extern const int q; // both-note {{declared here}} + constexpr int g() { return q; } // both-note {{outside its lifetime}} + constexpr int q = g(); // both-error {{constant expression}} \ + // both-note {{in call}} +} + namespace PseudoDtor { typedef int I; constexpr int f(int a = 1) { // both-error {{never produces a constant expression}} \ `````````` </details> https://github.com/llvm/llvm-project/pull/209696 _______________________________________________ cfe-commits mailing list [email protected] https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
