File tree Expand file tree Collapse file tree 2 files changed +58
-3
lines changed Expand file tree Collapse file tree 2 files changed +58
-3
lines changed Original file line number Diff line number Diff line change @@ -1837,9 +1837,23 @@ inline void OmpStructureChecker::ErrIfLHSAndRHSSymbolsMatch(
18371837 const Symbol &varSymbol = vSyms.front ();
18381838 for (const Symbol &symbol : evaluate::GetSymbolVector (*e)) {
18391839 if (varSymbol == symbol) {
1840- context_.Say (expr.source ,
1841- " RHS expression on atomic assignment statement cannot access '%s'" _err_en_US,
1842- var.GetSource ().ToString ());
1840+ const Fortran::common::Indirection<Fortran::parser::Designator>
1841+ *designator = std::get_if<
1842+ Fortran::common::Indirection<Fortran::parser::Designator>>(
1843+ &expr.u );
1844+ if (designator) {
1845+ auto *z{var.typedExpr .get ()};
1846+ auto *c{expr.typedExpr .get ()};
1847+ if (z->v == c->v ) {
1848+ context_.Say (expr.source ,
1849+ " RHS expression on atomic assignment statement cannot access '%s'" _err_en_US,
1850+ var.GetSource ());
1851+ }
1852+ } else {
1853+ context_.Say (expr.source ,
1854+ " RHS expression on atomic assignment statement cannot access '%s'" _err_en_US,
1855+ var.GetSource ());
1856+ }
18431857 }
18441858 }
18451859 }
Original file line number Diff line number Diff line change 1+ ! RUN: %flang_fc1 -fopenmp %s -o -
2+
3+ integer :: x, vv(2 ), xx(2 )
4+ type t1
5+ integer :: v,y,yy(2 )
6+ end type t1
7+ type (t1):: t,tt(2 )
8+ x= 1
9+ xx= 1
10+ vv= 1
11+ t% y= 1
12+ t% yy= 1
13+ tt(1 )% y= 1
14+ tt(1 )% yy= 1
15+ tt(2 )% v= 1
16+ tt(2 )% y= 1
17+ tt(2 )% yy= 1
18+
19+ ! $omp atomic read
20+ vv(1 ) = vv(2 )
21+ ! $omp atomic read
22+ t% v = t% y
23+ ! $omp atomic read
24+ t% v = t% yy(1 )
25+ ! $omp atomic read
26+ tt(1 )% v = tt(1 )% y
27+ ! $omp atomic read
28+ tt(1 )% v = tt(2 )% v
29+ ! $omp atomic read
30+ tt(1 )% v = tt(1 )% yy(1 )
31+ ! $omp atomic read
32+ t% yy(2 ) = t% y
33+ ! $omp atomic read
34+ t% yy(2 ) = t% yy(1 )
35+ ! $omp atomic read
36+ tt(1 )% yy(2 ) = tt(1 )% y
37+ ! $omp atomic read
38+ tt(1 )% yy(2 ) = tt(1 )% yy(1 )
39+ ! $omp atomic read
40+ tt(1 )% yy(2 ) = tt(2 )% yy(2 )
41+ end
You can’t perform that action at this time.
0 commit comments