Skip to content

Commit adb290d

Browse files
committed
[Sema][SVE] Reject atomic sizeless types
It would be difficult to guarantee atomicity for sizeless types, so the SVE ACLE makes atomic sizeless types invalid. As it happens, we already rejected them before the patch, but for the wrong reason: error: _Atomic cannot be applied to type 'svint8_t' (aka '__SVInt8_t') which is not trivially copyable The SVE types should be treated as trivially copyable; a later patch fixes that. Differential Revision: https://reviews.llvm.org/D75734
1 parent 627b5c1 commit adb290d

File tree

4 files changed

+6
-2
lines changed

4 files changed

+6
-2
lines changed

clang/include/clang/Basic/DiagnosticSemaKinds.td

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5925,7 +5925,7 @@ def err_func_def_incomplete_result : Error<
59255925
"incomplete result type %0 in function definition">;
59265926
def err_atomic_specifier_bad_type : Error<
59275927
"_Atomic cannot be applied to "
5928-
"%select{incomplete |array |function |reference |atomic |qualified |}0type "
5928+
"%select{incomplete |array |function |reference |atomic |qualified |sizeless |}0type "
59295929
"%1 %select{||||||which is not trivially copyable}0">;
59305930

59315931
// Expressions.

clang/lib/Sema/SemaType.cpp

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8564,9 +8564,11 @@ QualType Sema::BuildAtomicType(QualType T, SourceLocation Loc) {
85648564
DisallowedKind = 4;
85658565
else if (T.hasQualifiers())
85668566
DisallowedKind = 5;
8567+
else if (T->isSizelessType())
8568+
DisallowedKind = 6;
85678569
else if (!T.isTriviallyCopyableType(Context))
85688570
// Some other non-trivially-copyable type (probably a C++ class)
8569-
DisallowedKind = 6;
8571+
DisallowedKind = 7;
85708572

85718573
if (DisallowedKind != -1) {
85728574
Diag(Loc, diag::err_atomic_specifier_bad_type) << DisallowedKind << T;

clang/test/Sema/sizeless-1.c

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -84,6 +84,7 @@ void func(int sel) {
8484
const volatile svint8_t const_volatile_int8 = local_int8; // expected-note {{declared const here}}
8585
const volatile svint8_t uninit_const_volatile_int8;
8686

87+
_Atomic svint8_t atomic_int8; // expected-error {{_Atomic cannot be applied to sizeless type 'svint8_t'}}
8788
__restrict svint8_t restrict_int8; // expected-error {{requires a pointer or reference}}
8889

8990
_Bool test_int8 = init_int8; // expected-error {{initializing '_Bool' with an expression of incompatible type 'svint8_t'}}

clang/test/SemaCXX/sizeless-1.cpp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -98,6 +98,7 @@ void func(int sel) {
9898
const volatile svint8_t const_volatile_int8 = local_int8; // expected-note {{declared const here}}
9999
const volatile svint8_t uninit_const_volatile_int8; // expected-error {{default initialization of an object of const type 'const volatile svint8_t'}}
100100

101+
_Atomic svint8_t atomic_int8; // expected-error {{_Atomic cannot be applied to sizeless type 'svint8_t'}}
101102
__restrict svint8_t restrict_int8; // expected-error {{requires a pointer or reference}}
102103

103104
bool test_int8 = init_int8; // expected-error {{cannot initialize a variable of type 'bool' with an lvalue of type 'svint8_t'}}

0 commit comments

Comments
 (0)