This is an archive of the discontinued LLVM Phabricator instance.

[Clang] Improve designated inits diagnostic location
ClosedPublic

Authored by void on Apr 5 2023, 5:20 PM.

Details

Summary

A "null" designator won't have a valid location. Try to approximate this
location as best we can in that situation.

Closes 61118
Closes 46132

Diff Detail

Event Timeline

void created this revision.Apr 5 2023, 5:20 PM
Herald added a project: Restricted Project. · View Herald TranscriptApr 5 2023, 5:20 PM
void requested review of this revision.Apr 5 2023, 5:20 PM
Herald added a project: Restricted Project. · View Herald TranscriptApr 5 2023, 5:20 PM
Herald added a subscriber: cfe-commits. · View Herald Transcript
void updated this revision to Diff 511529.Apr 6 2023, 2:27 PM

Remove extraneous space.

shafik accepted this revision.Apr 6 2023, 6:01 PM

Thank you for taking care of this, LGTM

clang/lib/Sema/SemaInit.cpp
2646

nitpick, I think the comment should be above the if statement

This revision is now accepted and ready to land.Apr 6 2023, 6:01 PM
rsmith added inline comments.Apr 6 2023, 7:20 PM
clang/test/SemaCXX/cxx2b-designated-initializers.cpp
14

Why are we rejecting this?

aaron.ballman added inline comments.Apr 7 2023, 4:50 AM
clang/test/SemaCXX/cxx2b-designated-initializers.cpp
14

That's existing behavior: https://godbolt.org/z/48ThKbTor but we don't get the behavior when it's not a template (https://godbolt.org/z/f3zWaqdWr) or in C (https://godbolt.org/z/P1TqG43nG), so I agree that this should be accepted.

void marked an inline comment as done.Apr 7 2023, 11:36 AM
void added inline comments.
clang/test/SemaCXX/cxx2b-designated-initializers.cpp
14

Also, if the "auto" above is changed to "int" this compiles just fine.

This revision was landed with ongoing or failed builds.Apr 7 2023, 11:37 AM
This revision was automatically updated to reflect the committed changes.