https://bugs.llvm.org/show_bug.cgi?id=42782

            Bug ID: 42782
           Summary: compound assignment invalid operands
           Product: clang
           Version: trunk
          Hardware: PC
                OS: Linux
            Status: NEW
          Severity: enhancement
          Priority: P
         Component: -New Bugs
          Assignee: unassignedclangb...@nondot.org
          Reporter: jaopaul...@gmail.com
                CC: htmldevelo...@gmail.com, llvm-bugs@lists.llvm.org,
                    neeil...@live.com, richard-l...@metafoo.co.uk

Created attachment 22295
  --> https://bugs.llvm.org/attachment.cgi?id=22295&action=edit
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).

-- 
You are receiving this mail because:
You are on the CC list for the bug.
_______________________________________________
llvm-bugs mailing list
llvm-bugs@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-bugs

Reply via email to