This is an archive of the discontinued LLVM Phabricator instance.

[Sema] Make C++ functional-style cast warn about dropped qualifiers (-Wcast-qual)
ClosedPublic

Authored by krisb on Aug 29 2023, 12:10 PM.

Details

Summary

Functional-style cast (i.e. a simple-type-specifier or typename-specifier
followed by a parenthesize single expression [expr.type.conv]) is equivalent
to the C-style cast, so that makes sense they have identical behavior
including warnings.

This also matches GCC https://godbolt.org/z/b8Ma9Thjb.

Diff Detail

Event Timeline

krisb created this revision.Aug 29 2023, 12:10 PM
Herald added a project: Restricted Project. · View Herald TranscriptAug 29 2023, 12:10 PM
Herald added a subscriber: StephenFan. · View Herald Transcript
krisb requested review of this revision.Aug 29 2023, 12:10 PM
Herald added a project: Restricted Project. · View Herald TranscriptAug 29 2023, 12:10 PM
Herald added a subscriber: cfe-commits. · View Herald Transcript
shafik added reviewers: aaron.ballman, Restricted Project.Aug 29 2023, 2:35 PM
shafik added a subscriber: shafik.

Add more reviewers for visibility.

I think this makes sense especially if it matches up w/ gcc but would like to see more feedback.

rnk accepted this revision.Aug 29 2023, 4:24 PM

This seems like it will generate warning cleanup work for vendors, so I'll mention #clang-vendors , but I think the code looks good. I don't think it makes sense to add a fine-grained diagnostic category to allow people to clean up incrementally in this case.

This revision is now accepted and ready to land.Aug 29 2023, 4:24 PM

I think this should get a mention in clang's releases notes. Otherwise LGTM

krisb updated this revision to Diff 554818.Aug 30 2023, 1:30 PM

Add release note.

krisb added a subscriber: Restricted Project.Aug 30 2023, 1:30 PM