This is an archive of the discontinued LLVM Phabricator instance.

[C11] Correct the resulting type for an assignment expression
ClosedPublic

Authored by aaron.ballman on Mar 25 2022, 11:58 AM.

Details

Reviewers
eli.friedman
jyknight
erichkeane
cor3ntin
Group Reviewers
Restricted Project
Summary

In C, assignment expressions result in an rvalue whose type is the type of the lhs of the assignment after it undergoes lvalue to rvalue conversion. lvalue to rvalue conversion in C strips all qualifiers including _Atomic.

We used getUnqualifiedType() which does not strip the _Atomic qualifier when we should have used getAtomicUnqualifiedType(). This corrects the usage and adds some comments to getUnqualifiedType() to make it more clear that it does not strip _Atomic and that's on purpose (see C11 6.2.5p27).

This addresses Issue 48742.

Diff Detail

Event Timeline

aaron.ballman created this revision.Mar 25 2022, 11:58 AM
Herald added a project: Restricted Project. · View Herald TranscriptMar 25 2022, 11:58 AM
aaron.ballman requested review of this revision.Mar 25 2022, 11:58 AM
Herald added a project: Restricted Project. · View Herald TranscriptMar 25 2022, 11:58 AM
erichkeane accepted this revision.Mar 25 2022, 12:04 PM
This revision is now accepted and ready to land.Mar 25 2022, 12:04 PM
cor3ntin accepted this revision.Mar 25 2022, 12:13 PM
cor3ntin added a subscriber: cor3ntin.

Beside maybe a comment that could help understanding, I think this looks good!

clang/lib/Sema/SemaExpr.cpp
13647

I wonder if we want another comment here to make it extra clear that atomic should be stripped?

aaron.ballman marked an inline comment as done.Mar 26 2022, 5:03 AM
aaron.ballman added inline comments.
clang/lib/Sema/SemaExpr.cpp
13647

I've updated the standard wording comments above to make this more clear; good call!

aaron.ballman closed this revision.Mar 26 2022, 5:04 AM
aaron.ballman marked an inline comment as done.

Thanks for the reviews, I've commit in bfa2f25d350c1015b74b8a14684e68efa6500bbc.