
The underlying type of an enumeration is the non-atomic, unqualified version of the specified type. Clang was rejecting such enumerations, with a hard error, but now has the ability to downgrade the error into a warning. Additionally, we diagnose (as a warning) dropping other qualifiers. _Atomic is special given that an atomic type need not have the same size as its non-atomic counterpart, and that the C++ version of <stdatomic.h> defines _Atomic to std::atomic for easing cross- language atomic use and std::atomic is an invalid enum base in C++. (Note: we expose _Atomic in C++ even without including <stdatomic,h>.) Fixes #147736
27 lines
886 B
C
27 lines
886 B
C
// NOTE: Assertions have been autogenerated by utils/update_cc_test_checks.py UTC_ARGS: --version 5
|
|
// RUN: %clang_cc1 -triple x86_64-unknown-unknown -Wno-error=underlying-atomic-qualifier-ignored -std=c23 %s -emit-llvm -o - | FileCheck %s
|
|
|
|
// Ensure that an "atomic" underlying type has no actual atomic semantics
|
|
// because the qualifier is stripped.
|
|
|
|
enum E : _Atomic(int) {
|
|
Foo
|
|
};
|
|
|
|
// CHECK-LABEL: define {{.*}} void @test(
|
|
// CHECK-SAME: i32 noundef [[E:%.*]]) #[[ATTR0:[0-9]+]] {
|
|
// CHECK-NEXT: [[ENTRY:.*:]]
|
|
// CHECK-NEXT: [[E_ADDR:%.*]] = alloca i32
|
|
// CHECK-NEXT: [[X:%.*]] = alloca i32
|
|
// CHECK-NEXT: store i32 [[E]], ptr [[E_ADDR]]
|
|
// CHECK-NEXT: [[TMP0:%.*]] = load i32, ptr [[E_ADDR]]
|
|
// CHECK-NEXT: store i32 [[TMP0]], ptr [[X]]
|
|
// CHECK-NEXT: store i32 0, ptr [[E_ADDR]]
|
|
// CHECK-NEXT: ret void
|
|
//
|
|
void test(enum E e) {
|
|
int x = e;
|
|
e = Foo;
|
|
}
|
|
|