forked from OSchip/llvm-project
Sema: demote invalid atomic ordering message to warning.
Someone could write: if (0) { __c11_atomic_load(ptr, memory_order_release); } or the equivalent, which is perfectly valid, so we shouldn't outright reject invalid orderings on purely static grounds. rdar://problem/16242991 llvm-svn: 203564
This commit is contained in:
parent
f8502272ef
commit
c83472e0ff
|
@ -5689,8 +5689,9 @@ def err_atomic_op_needs_atomic_int_or_ptr : Error<
|
|||
def err_atomic_op_bitwise_needs_atomic_int : Error<
|
||||
"address argument to bitwise atomic operation must be a pointer to "
|
||||
"%select{|atomic }0integer (%1 invalid)">;
|
||||
def err_atomic_op_has_invalid_memory_order : Error<
|
||||
"memory order argument to atomic operation is invalid">;
|
||||
def warn_atomic_op_has_invalid_memory_order : Warning<
|
||||
"memory order argument to atomic operation is invalid">,
|
||||
InGroup<DiagGroup<"atomic-memory-ordering">>;
|
||||
|
||||
def err_atomic_load_store_uses_lib : Error<
|
||||
"atomic %select{load|store}0 requires runtime support that is not "
|
||||
|
|
|
@ -1231,9 +1231,9 @@ ExprResult Sema::SemaAtomicOpsOverloaded(ExprResult TheCallResult,
|
|||
llvm::APSInt Result(32);
|
||||
if (SubExprs[1]->isIntegerConstantExpr(Result, Context) &&
|
||||
!isValidOrderingForOp(Result.getSExtValue(), Op))
|
||||
return ExprError(Diag(SubExprs[1]->getLocStart(),
|
||||
diag::err_atomic_op_has_invalid_memory_order)
|
||||
<< SubExprs[1]->getSourceRange());
|
||||
Diag(SubExprs[1]->getLocStart(),
|
||||
diag::warn_atomic_op_has_invalid_memory_order)
|
||||
<< SubExprs[1]->getSourceRange();
|
||||
}
|
||||
|
||||
AtomicExpr *AE = new (Context) AtomicExpr(TheCall->getCallee()->getLocStart(),
|
||||
|
|
|
@ -187,18 +187,18 @@ void memory_checks(_Atomic(int) *Ap, int *p, int val) {
|
|||
(void)__c11_atomic_load(Ap, memory_order_relaxed);
|
||||
(void)__c11_atomic_load(Ap, memory_order_acquire);
|
||||
(void)__c11_atomic_load(Ap, memory_order_consume);
|
||||
(void)__c11_atomic_load(Ap, memory_order_release); // expected-error {{memory order argument to atomic operation is invalid}}
|
||||
(void)__c11_atomic_load(Ap, memory_order_acq_rel); // expected-error {{memory order argument to atomic operation is invalid}}
|
||||
(void)__c11_atomic_load(Ap, memory_order_release); // expected-warning {{memory order argument to atomic operation is invalid}}
|
||||
(void)__c11_atomic_load(Ap, memory_order_acq_rel); // expected-warning {{memory order argument to atomic operation is invalid}}
|
||||
(void)__c11_atomic_load(Ap, memory_order_seq_cst);
|
||||
(void)__c11_atomic_load(Ap, val);
|
||||
(void)__c11_atomic_load(Ap, -1); // expected-error {{memory order argument to atomic operation is invalid}}
|
||||
(void)__c11_atomic_load(Ap, 42); // expected-error {{memory order argument to atomic operation is invalid}}
|
||||
(void)__c11_atomic_load(Ap, -1); // expected-warning {{memory order argument to atomic operation is invalid}}
|
||||
(void)__c11_atomic_load(Ap, 42); // expected-warning {{memory order argument to atomic operation is invalid}}
|
||||
|
||||
(void)__c11_atomic_store(Ap, val, memory_order_relaxed);
|
||||
(void)__c11_atomic_store(Ap, val, memory_order_acquire); // expected-error {{memory order argument to atomic operation is invalid}}
|
||||
(void)__c11_atomic_store(Ap, val, memory_order_consume); // expected-error {{memory order argument to atomic operation is invalid}}
|
||||
(void)__c11_atomic_store(Ap, val, memory_order_acquire); // expected-warning {{memory order argument to atomic operation is invalid}}
|
||||
(void)__c11_atomic_store(Ap, val, memory_order_consume); // expected-warning {{memory order argument to atomic operation is invalid}}
|
||||
(void)__c11_atomic_store(Ap, val, memory_order_release);
|
||||
(void)__c11_atomic_store(Ap, val, memory_order_acq_rel); // expected-error {{memory order argument to atomic operation is invalid}}
|
||||
(void)__c11_atomic_store(Ap, val, memory_order_acq_rel); // expected-warning {{memory order argument to atomic operation is invalid}}
|
||||
(void)__c11_atomic_store(Ap, val, memory_order_seq_cst);
|
||||
|
||||
(void)__c11_atomic_fetch_add(Ap, 1, memory_order_relaxed);
|
||||
|
@ -267,29 +267,29 @@ void memory_checks(_Atomic(int) *Ap, int *p, int val) {
|
|||
(void)__atomic_load_n(p, memory_order_relaxed);
|
||||
(void)__atomic_load_n(p, memory_order_acquire);
|
||||
(void)__atomic_load_n(p, memory_order_consume);
|
||||
(void)__atomic_load_n(p, memory_order_release); // expected-error {{memory order argument to atomic operation is invalid}}
|
||||
(void)__atomic_load_n(p, memory_order_acq_rel); // expected-error {{memory order argument to atomic operation is invalid}}
|
||||
(void)__atomic_load_n(p, memory_order_release); // expected-warning {{memory order argument to atomic operation is invalid}}
|
||||
(void)__atomic_load_n(p, memory_order_acq_rel); // expected-warning {{memory order argument to atomic operation is invalid}}
|
||||
(void)__atomic_load_n(p, memory_order_seq_cst);
|
||||
|
||||
(void)__atomic_load(p, p, memory_order_relaxed);
|
||||
(void)__atomic_load(p, p, memory_order_acquire);
|
||||
(void)__atomic_load(p, p, memory_order_consume);
|
||||
(void)__atomic_load(p, p, memory_order_release); // expected-error {{memory order argument to atomic operation is invalid}}
|
||||
(void)__atomic_load(p, p, memory_order_acq_rel); // expected-error {{memory order argument to atomic operation is invalid}}
|
||||
(void)__atomic_load(p, p, memory_order_release); // expected-warning {{memory order argument to atomic operation is invalid}}
|
||||
(void)__atomic_load(p, p, memory_order_acq_rel); // expected-warning {{memory order argument to atomic operation is invalid}}
|
||||
(void)__atomic_load(p, p, memory_order_seq_cst);
|
||||
|
||||
(void)__atomic_store(p, p, memory_order_relaxed);
|
||||
(void)__atomic_store(p, p, memory_order_acquire); // expected-error {{memory order argument to atomic operation is invalid}}
|
||||
(void)__atomic_store(p, p, memory_order_consume); // expected-error {{memory order argument to atomic operation is invalid}}
|
||||
(void)__atomic_store(p, p, memory_order_acquire); // expected-warning {{memory order argument to atomic operation is invalid}}
|
||||
(void)__atomic_store(p, p, memory_order_consume); // expected-warning {{memory order argument to atomic operation is invalid}}
|
||||
(void)__atomic_store(p, p, memory_order_release);
|
||||
(void)__atomic_store(p, p, memory_order_acq_rel); // expected-error {{memory order argument to atomic operation is invalid}}
|
||||
(void)__atomic_store(p, p, memory_order_acq_rel); // expected-warning {{memory order argument to atomic operation is invalid}}
|
||||
(void)__atomic_store(p, p, memory_order_seq_cst);
|
||||
|
||||
(void)__atomic_store_n(p, val, memory_order_relaxed);
|
||||
(void)__atomic_store_n(p, val, memory_order_acquire); // expected-error {{memory order argument to atomic operation is invalid}}
|
||||
(void)__atomic_store_n(p, val, memory_order_consume); // expected-error {{memory order argument to atomic operation is invalid}}
|
||||
(void)__atomic_store_n(p, val, memory_order_acquire); // expected-warning {{memory order argument to atomic operation is invalid}}
|
||||
(void)__atomic_store_n(p, val, memory_order_consume); // expected-warning {{memory order argument to atomic operation is invalid}}
|
||||
(void)__atomic_store_n(p, val, memory_order_release);
|
||||
(void)__atomic_store_n(p, val, memory_order_acq_rel); // expected-error {{memory order argument to atomic operation is invalid}}
|
||||
(void)__atomic_store_n(p, val, memory_order_acq_rel); // expected-warning {{memory order argument to atomic operation is invalid}}
|
||||
(void)__atomic_store_n(p, val, memory_order_seq_cst);
|
||||
|
||||
(void)__atomic_fetch_add(p, val, memory_order_relaxed);
|
||||
|
|
Loading…
Reference in New Issue