Page MenuHomePhabricator

[clang][AST] Print name instead of type when diagnosing uninitialized subobject in constexpr variables
Needs ReviewPublic

Authored by hazohelet on Sat, Mar 18, 5:14 AM.

Details

Summary

This patch improves the diagnostic on uninitialized subobjects in constexpr variables by modifying the diagnostic message to display the subobject's name instead of its type.

Fixes https://github.com/llvm/llvm-project/issues/58601

Diff Detail

Unit TestsFailed

TimeTest
120 msx64 debian > Flang.Driver::code-gen-rv64.f90
Script: -- : 'RUN: at line 5'; rm -f /var/lib/buildkite-agent/builds/llvm-project/build/tools/flang/test/Driver/Output/code-gen-rv64.f90.tmp.o

Event Timeline

hazohelet created this revision.Sat, Mar 18, 5:14 AM
Herald added a project: Restricted Project. · View Herald TranscriptSat, Mar 18, 5:14 AM
hazohelet requested review of this revision.Sat, Mar 18, 5:14 AM
Herald added a project: Restricted Project. · View Herald TranscriptSat, Mar 18, 5:14 AM

Thank you for submitting this fix.

clang/lib/AST/ExprConstant.cpp
2270
2399

same here.

2444

Also here

2456

and here

clang/lib/AST/Interp/Interp.cpp
373

Do we need to check that SubObjDecl is not nullptr ever?

shafik added inline comments.Sat, Mar 18, 12:59 PM
clang/lib/AST/Interp/Interp.cpp
373

If we are sure it can never be nullptr then we should assert(SubObjDecl)

"subobject named 'foo'" sounds a bit weird to me, I'd expect just "subobject 'foo'", but that's just a suggestion and I'll wait for a native spearker to chime in on this.

clang/lib/AST/Interp/Interp.cpp
373

Should never be null here.

hazohelet updated this revision to Diff 506358.Sun, Mar 19, 1:17 AM

Address comments from @shafik and @tbaeder