Index: lib/Sema/SemaExpr.cpp =================================================================== --- lib/Sema/SemaExpr.cpp +++ lib/Sema/SemaExpr.cpp @@ -13375,6 +13375,8 @@ if (const Expr *Value = LastStmt->getExprStmt()) { StmtExprMayBindToTemp = true; Ty = Value->getType(); + if (const AtomicType *AtomicRHS = Ty->getAs()) + Ty = AtomicRHS->getValueType(); } } } Index: test/Sema/atomic-expr-stmt.c =================================================================== --- /dev/null +++ test/Sema/atomic-expr-stmt.c @@ -0,0 +1,23 @@ +// RUN: %clang_cc1 -triple x86_64-unknown-linux-gnu -emit-llvm < %s | FileCheck %s +void test_assign(_Atomic int a, int b) { + //CHECK: define void @test_assign(i32 %a, i32 %b) + // assignment is OK + b = ({a;}); + //CHECK: %atomic-load = load atomic i32, i32* %a.addr seq_cst, align 4 + //CHECK: store atomic i32 %atomic-load, i32* %tmp seq_cst, align 4 + //CHECK: %0 = load i32, i32* %tmp, align 4 + //CHECK: store i32 %0, i32* %b.addr, align 4 +} + +int test_compare(_Atomic int x, int y) { + //CHECK: define i32 @test_compare(i32 %x, i32 %y) + // comparison is OK + //CHECK: %0 = load i32, i32* %y.addr, align 4 + //CHECK: %atomic-load = load atomic i32, i32* %x.addr seq_cst, align 4 + //CHECK: store atomic i32 %atomic-load, i32* %tmp seq_cst, align 4 + //CHECK: %1 = load i32, i32* %tmp, align 4 + //CHECK: %cmp = icmp slt i32 %0, %1 + if (y <({x;})) + return 0; + else return 1; +}