Hello,

Le 01/08/2024 à 12:00, Jakub Jelinek a écrit :
Hi!

A static analyzer found what seems like a pasto in the PR45019 changes,
the second branch of || only accesses sym2 while the first one sym1 except
for this one spot.

Not sure I'm able to construct a testcase for this though.

What is reported exactly by the static analyzer?
This looks like dead code to me.

In any case, bootstrapped/regtested on x86_64-linux and i686-linux
successfully, ok for trunk?

2024-08-01  Jakub Jelinek  <ja...@redhat.com>

        * dependency.cc (gfc_check_dependency): Fix a pasto, check
        sym1->as->type for AS_ASSUMED_SHAPE rather than sym2->as->type.
        Formatting fix.

--- gcc/fortran/dependency.cc.jj        2024-07-01 11:28:22.705237968 +0200
+++ gcc/fortran/dependency.cc   2024-07-31 20:53:34.471588828 +0200
@@ -1368,7 +1368,7 @@ gfc_check_dependency (gfc_expr *expr1, g
          if ((attr1.pointer || attr1.target) && (attr2.pointer || 
attr2.target))
            {
              if (check_data_pointer_types (expr1, expr2)
-                   && check_data_pointer_types (expr2, expr1))
+                 && check_data_pointer_types (expr2, expr1))
                return 0;
return 1;
@@ -1380,7 +1380,7 @@ gfc_check_dependency (gfc_expr *expr1, g
              if (sym1->attr.target && sym2->attr.target

if both target attributes are true here, both attr1.target and attr2.target are true as well, so the conditional before is true and this branch is skipped.

                  && ((sym1->attr.dummy && !sym1->attr.contiguous
                       && (!sym1->attr.dimension
-                          || sym2->as->type == AS_ASSUMED_SHAPE))
+                          || sym1->as->type == AS_ASSUMED_SHAPE))
                      || (sym2->attr.dummy && !sym2->attr.contiguous
                          && (!sym2->attr.dimension
                              || sym2->as->type == AS_ASSUMED_SHAPE))))

        Jakub


Reply via email to