This is an archive of the discontinued LLVM Phabricator instance.

[Clang] Support case and default labels at end of compound statement
ClosedPublic

Authored by Izaron on Sep 19 2022, 12:26 PM.

Details

Diff Detail

Event Timeline

Izaron created this revision.Sep 19 2022, 12:26 PM
Herald added a project: Restricted Project. · View Herald TranscriptSep 19 2022, 12:26 PM
Izaron requested review of this revision.Sep 19 2022, 12:26 PM
Herald added a project: Restricted Project. · View Herald TranscriptSep 19 2022, 12:26 PM
Herald added a subscriber: cfe-commits. · View Herald Transcript
Izaron added inline comments.Sep 19 2022, 12:30 PM
clang/include/clang/Basic/DiagnosticParseKinds.td
298–299

This is not an error anymore

clang/lib/Parse/ParseStmt.cpp
932–940

We have copy-pasted this piece of code in 3 places (simple label, case label, default label). Does it make sense to have a method for label diags?

clang/test/Parser/c2x-label.c
12–30

I feel like we may be having redundant tests, because Parser/c2x-label.c and C2x/n2508.c test the same things...

Izaron updated this revision to Diff 461347.Sep 19 2022, 1:40 PM

Fix corresponding FixIt clang test

aaron.ballman added inline comments.Sep 20 2022, 1:07 PM
clang/lib/Parse/ParseStmt.cpp
932–940

I think a helper function to diagnose this would not be a bad thing.

clang/test/Parser/c2x-label.c
12–30

Yup, we'll definitely have redundancy in the tests -- the tests under the C directory are for (eventually) automatically filling out: https://clang.llvm.org/c_status.html instead of relying on folks to manually modify the HTML every time. So they're mostly "do the examples from the paper work" kind of tests, whereas the Parser/Sema/etc tests are going to test a LOT more edge cases.

Izaron updated this revision to Diff 461942.Sep 21 2022, 10:32 AM

Add helper method DiagnoseLabelAtEndOfCompoundStatement

Izaron marked 2 inline comments as done.Sep 21 2022, 10:32 AM
This revision is now accepted and ready to land.Sep 21 2022, 12:07 PM
This revision was landed with ongoing or failed builds.Sep 21 2022, 12:37 PM
This revision was automatically updated to reflect the committed changes.