@@ -539,7 +539,6 @@ void OmpStructureChecker::CheckAtomicType(
539
539
return ;
540
540
}
541
541
542
- // Variable is a pointer.
543
542
if (typeSpec->IsPolymorphic ()) {
544
543
context_.Say (source,
545
544
" Atomic variable %s cannot be a pointer to a polymorphic type" _err_en_US,
@@ -829,6 +828,32 @@ void OmpStructureChecker::CheckAtomicWriteAssignment(
829
828
if (!IsVarOrFunctionRef (atom)) {
830
829
ErrorShouldBeVariable (atom, rsrc);
831
830
} else {
831
+ // For intrinsic assignment (x = expr), check if the variable is a pointer
832
+ // to a non-intrinsic type, which is not allowed in ATOMIC WRITE
833
+ if (!IsPointerAssignment (write)) {
834
+ std::vector<SomeExpr> dsgs{GetAllDesignators (atom)};
835
+ if (!dsgs.empty ()) {
836
+ evaluate::SymbolVector syms{evaluate::GetSymbolVector (dsgs.front ())};
837
+ if (!syms.empty () && IsPointer (syms.back ())) {
838
+ SymbolRef sym = syms.back ();
839
+ if (const DeclTypeSpec *typeSpec{sym->GetType ()}) {
840
+ using Category = DeclTypeSpec::Category;
841
+ Category cat{typeSpec->category ()};
842
+ if (cat != Category::Numeric && cat != Category::Logical) {
843
+ std::string details = " has the POINTER attribute" ;
844
+ if (const auto *derived{typeSpec->AsDerived ()}) {
845
+ details +=
846
+ " and derived type '" s + derived->name ().ToString () + " '" ;
847
+ }
848
+ context_.Say (lsrc,
849
+ " ATOMIC WRITE requires an intrinsic scalar variable; '%s'%s" _err_en_US,
850
+ sym->name (), details);
851
+ return ;
852
+ }
853
+ }
854
+ }
855
+ }
856
+ }
832
857
CheckAtomicVariable (atom, lsrc);
833
858
CheckStorageOverlap (atom, {write.rhs }, source);
834
859
}
0 commit comments