[C11] Correct the resulting type for an assignment expression
authorAaron Ballman <aaron@aaronballman.com>
Sat, 26 Mar 2022 12:01:47 +0000 (08:01 -0400)
committerAaron Ballman <aaron@aaronballman.com>
Sat, 26 Mar 2022 12:03:11 +0000 (08:03 -0400)
commitbfa2f25d350c1015b74b8a14684e68efa6500bbc
tree2b422ee462760503a1b67b089b8f4a641af5fb6c
parentc3b672a34cdef38002016ab15454c2df432e48c8
[C11] Correct the resulting type for an assignment expression

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.
clang/docs/ReleaseNotes.rst
clang/include/clang/AST/Type.h
clang/lib/Sema/SemaExpr.cpp
clang/test/Sema/atomic-expr.c