Skip to content

Commit 9daab7f

Browse files
committedJun 8, 2023
1 parent 4524a31 commit 9daab7f

File tree

3 files changed

+25
-0
lines changed

3 files changed

+25
-0
lines changed
 

‎clang/docs/ReleaseNotes.rst

+2
Original file line numberDiff line numberDiff line change
@@ -488,6 +488,8 @@ Bug Fixes in This Version
488488
(`#63010 <https://github.com/llvm/llvm-project/issues/63010>`_).
489489
- Fix rejects-valid when consteval operator appears inside of a template.
490490
(`#62886 <https://github.com/llvm/llvm-project/issues/62886>`_).
491+
- Fix crash for code using ``_Atomic`` types in C++
492+
(`See patch <https://reviews.llvm.org/D152303>`_).
491493

492494
Bug Fixes to Compiler Builtins
493495
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

‎clang/lib/AST/ExprConstant.cpp

+1
Original file line numberDiff line numberDiff line change
@@ -15064,6 +15064,7 @@ static bool Evaluate(APValue &Result, EvalInfo &Info, const Expr *E) {
1506415064
E, Unqual, ScopeKind::FullExpression, LV);
1506515065
if (!EvaluateAtomic(E, &LV, Value, Info))
1506615066
return false;
15067+
Result = Value;
1506715068
} else {
1506815069
if (!EvaluateAtomic(E, nullptr, Result, Info))
1506915070
return false;

‎clang/test/CodeGenCXX/atomicinit.cpp

+22
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,10 @@ AtomicInt PR22043 = AtomicInt();
88
// CHECK-DAG: @_ZN7PR180978constant1bE ={{.*}} local_unnamed_addr global { i16, i8 } { i16 2, i8 6 }, align 4
99
// CHECK-DAG: @_ZN7PR180978constant1cE ={{.*}} local_unnamed_addr global { i16, i8 } { i16 3, i8 6 }, align 4
1010
// CHECK-DAG: @_ZN7PR180978constant1yE ={{.*}} local_unnamed_addr global { { i16, i8 }, i32 } { { i16, i8 } { i16 4, i8 6 }, i32 5 }, align 4
11+
// CHECK-DAG: @_ZN7PR180978constant1zE ={{.*}} global i32 0, align 4
12+
// CHECK-DAG: @_ZN7PR180978constant2y2E ={{.*}} global %"struct.PR18097::constant::Y" zeroinitializer
13+
// CHECK-DAG: @_ZN7PR180978constant1gE ={{.*}} global %"struct.PR18097::constant::Struct0" zeroinitializer
14+
// CHECK-DAG: @_ZN7PR180978constantL1xE = internal {{.*}} constant { i16, i8 } { i16 1, i8 6 }
1115

1216
struct A {
1317
_Atomic(int) i;
@@ -102,5 +106,23 @@ namespace PR18097 {
102106
_Atomic(int) b;
103107
};
104108
Y y = { X(4), 5 };
109+
110+
// CHECK-LABEL: define {{.*}} @__cxx_global_var_init
111+
// CHECK: tail call void @llvm.memcpy.p0.p0.i32(ptr{{.*}} @_ZN7PR180978constant2y2E, ptr{{.*}} @_ZN7PR180978constantL1xE, i32 3, i1 false)
112+
// CHECK: %0 = load i32, ptr @_ZN7PR180978constant1zE
113+
// CHECK: store i32 %0, ptr getelementptr inbounds (%"struct.PR18097::constant::Y", ptr @_ZN7PR180978constant2y2E, i32 0, i32 1)
114+
int z;
115+
constexpr X x{1};
116+
Y y2 = { x, z };
117+
118+
typedef union {
119+
unsigned int f0;
120+
} Union0;
121+
122+
typedef struct {
123+
_Atomic(Union0) f1;
124+
} Struct0;
125+
126+
Struct0 g = {};
105127
}
106128
}

0 commit comments

Comments
 (0)