Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 4 additions & 4 deletions clang/lib/Sema/SemaExpr.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -9317,14 +9317,14 @@ AssignConvertType Sema::CheckAssignmentConstraints(QualType LHSType,
// If we have an atomic type, try a non-atomic assignment, then just add an
// atomic qualification step.
if (const AtomicType *AtomicTy = dyn_cast<AtomicType>(LHSType)) {
AssignConvertType result =
AssignConvertType Result =
CheckAssignmentConstraints(AtomicTy->getValueType(), RHS, Kind);
if (result != AssignConvertType::Compatible)
return result;
if (!IsAssignConvertCompatible(Result))
return Result;
if (Kind != CK_NoOp && ConvertRHS)
RHS = ImpCastExprToType(RHS.get(), AtomicTy->getValueType(), Kind);
Kind = CK_NonAtomicToAtomic;
return AssignConvertType::Compatible;
return Result;
}

// If the left-hand side is a reference type, then we are in a
Expand Down
8 changes: 8 additions & 0 deletions clang/test/Sema/implicit-void-ptr-cast.c
Original file line number Diff line number Diff line change
Expand Up @@ -82,3 +82,11 @@ void more(void) {
ptr3 = SOMETHING_THAT_IS_NOT_NULL; // c-warning {{implicit conversion when assigning to 'char *' from type 'void *' is not permitted in C++}} \
cxx-error {{assigning to 'char *' from incompatible type 'void *'}}
}

void gh154157(void) {
#define ATOMIC_VAR_INIT(value) (value)

typedef const struct T * T_Ref;
static T_Ref _Atomic x = ATOMIC_VAR_INIT((void*)NULL); // c-warning {{implicit conversion when initializing '_Atomic(T_Ref)' with an expression of type 'void *' is not permitted in C++}} \
cxx-error {{cannot initialize a variable of type '_Atomic(T_Ref)' with an rvalue of type 'void *'}}
}
Loading