<html>
<head>
<base href="https://bugs.llvm.org/">
</head>
<body><table border="1" cellspacing="0" cellpadding="8">
<tr>
<th>Bug ID</th>
<td><a class="bz_bug_link
bz_status_NEW "
title="NEW - compound assignment invalid operands"
href="https://bugs.llvm.org/show_bug.cgi?id=42782">42782</a>
</td>
</tr>
<tr>
<th>Summary</th>
<td>compound assignment invalid operands
</td>
</tr>
<tr>
<th>Product</th>
<td>clang
</td>
</tr>
<tr>
<th>Version</th>
<td>trunk
</td>
</tr>
<tr>
<th>Hardware</th>
<td>PC
</td>
</tr>
<tr>
<th>OS</th>
<td>Linux
</td>
</tr>
<tr>
<th>Status</th>
<td>NEW
</td>
</tr>
<tr>
<th>Severity</th>
<td>enhancement
</td>
</tr>
<tr>
<th>Priority</th>
<td>P
</td>
</tr>
<tr>
<th>Component</th>
<td>-New Bugs
</td>
</tr>
<tr>
<th>Assignee</th>
<td>unassignedclangbugs@nondot.org
</td>
</tr>
<tr>
<th>Reporter</th>
<td>jaopaulolc@gmail.com
</td>
</tr>
<tr>
<th>CC</th>
<td>htmldeveloper@gmail.com, llvm-bugs@lists.llvm.org, neeilans@live.com, richard-llvm@metafoo.co.uk
</td>
</tr></table>
<p>
<div>
<pre>Created <span class=""><a href="attachment.cgi?id=22295" name="attach_22295" title="stack dump">attachment 22295</a> <a href="attachment.cgi?id=22295&action=edit" title="stack dump">[details]</a></span>
stack dump
The code I am attaching has 2 compound assignments where variable x is the LHS,
respectively, line 6 and 8.
The assignment on line 6 works fine. However line 8's assignment triggers the
following error:
atomic.c:8:5: error: invalid operands to binary expression ('_Atomic(int)' and
'_Atomic(int)')
The problem seems to be the fact that only the LHS' _Atomic type-specifier is
ignored here:
<a href="https://github.com/llvm/llvm-project/blob/736e8aa8ed48fd8c29a909bf616965d0f8677bca/clang/lib/Sema/SemaExpr.cpp#L1358">https://github.com/llvm/llvm-project/blob/736e8aa8ed48fd8c29a909bf616965d0f8677bca/clang/lib/Sema/SemaExpr.cpp#L1358</a>
Which makes LHSType and RHSType different and triggers the error message here:
<a href="https://github.com/llvm/llvm-project/blob/736e8aa8ed48fd8c29a909bf616965d0f8677bca/clang/lib/Sema/SemaExpr.cpp#L9462">https://github.com/llvm/llvm-project/blob/736e8aa8ed48fd8c29a909bf616965d0f8677bca/clang/lib/Sema/SemaExpr.cpp#L9462</a>
I tried to "fix" this by adding the following right after SemaExpr.cpp#L1358:
if (const AtomicType *AtomicRHS = RHSType->getAs<AtomicType>())
RHSType = AtomicRHS->getValueType();
However this breaks the CodeGen at ScalarExprEmitter::EmitCompoundAssignLValue.
(please find all resources attached).</pre>
</div>
</p>
<hr>
<span>You are receiving this mail because:</span>
<ul>
<li>You are on the CC list for the bug.</li>
</ul>
</body>
</html>