|
@@ -6502,6 +6502,20 @@ InitializationSequence::Perform(Sema &S,
|
|
|
<< Init->getSourceRange();
|
|
|
}
|
|
|
|
|
|
+ // OpenCL v2.0 s6.13.11.1. atomic variables can be initialized in global scope
|
|
|
+ QualType ETy = Entity.getType();
|
|
|
+ Qualifiers TyQualifiers = ETy.getQualifiers();
|
|
|
+ bool HasGlobalAS = TyQualifiers.hasAddressSpace() &&
|
|
|
+ TyQualifiers.getAddressSpace() == LangAS::opencl_global;
|
|
|
+
|
|
|
+ if (S.getLangOpts().OpenCLVersion >= 200 &&
|
|
|
+ ETy->isAtomicType() && !HasGlobalAS &&
|
|
|
+ Entity.getKind() == InitializedEntity::EK_Variable && Args.size() > 0) {
|
|
|
+ S.Diag(Args[0]->getLocStart(), diag::err_opencl_atomic_init) << 1 <<
|
|
|
+ SourceRange(Entity.getDecl()->getLocStart(), Args[0]->getLocEnd());
|
|
|
+ return ExprError();
|
|
|
+ }
|
|
|
+
|
|
|
// Diagnose cases where we initialize a pointer to an array temporary, and the
|
|
|
// pointer obviously outlives the temporary.
|
|
|
if (Args.size() == 1 && Args[0]->getType()->isArrayType() &&
|