Quuxplusone / LLVMBugzillaTest

0 stars 0 forks source link

compound assignment invalid operands #41752

Open Quuxplusone opened 5 years ago

Quuxplusone commented 5 years ago
Bugzilla Link PR42782
Status NEW
Importance P enhancement
Reported by João Paulo Labegalini de Carvalho (jaopaulolc@gmail.com)
Reported on 2019-07-26 09:48:47 -0700
Last modified on 2019-07-26 09:49:51 -0700
Version trunk
Hardware PC Linux
CC htmldeveloper@gmail.com, llvm-bugs@lists.llvm.org, neeilans@live.com, richard-llvm@metafoo.co.uk
Fixed by commit(s)
Attachments stack-dump.txt (6748 bytes, text/plain)
atomic.c (145 bytes, text/x-csrc)
atomic-ba869c.sh (1820 bytes, application/x-shellscript)
Blocks
Blocked by
See also
Created attachment 22295
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:

https://github.com/llvm/llvm-project/blob/736e8aa8ed48fd8c29a909bf616965d0f8677bca/clang/lib/Sema/SemaExpr.cpp#L1358

Which makes LHSType and RHSType different and triggers the error message here:

https://github.com/llvm/llvm-project/blob/736e8aa8ed48fd8c29a909bf616965d0f8677bca/clang/lib/Sema/SemaExpr.cpp#L9462

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).
Quuxplusone commented 5 years ago

Attached stack-dump.txt (6748 bytes, text/plain): stack dump

Quuxplusone commented 5 years ago

Attached atomic.c (145 bytes, text/x-csrc): input program

Quuxplusone commented 5 years ago

Attached atomic-ba869c.sh (1820 bytes, application/x-shellscript): full command line