This is the mail archive of the gcc-bugs@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

[Bug fortran/29489] LBOUND (array) and LBOUND (array, DIM) give different results.



------- Comment #5 from fxcoudert at gcc dot gnu dot org  2006-10-18 22:05 -------
Yet another bug found, yet another patch. I think this one is the last:

Index: trans-intrinsic.c
===================================================================
--- trans-intrinsic.c   (revision 117862)
+++ trans-intrinsic.c   (working copy)
@@ -710,7 +710,7 @@
   tree type;
   tree bound;
   tree tmp;
-  tree cond, cond1, cond2, cond3, size;
+  tree cond, cond1, cond2, cond3, cond4, size;
   tree ubound;
   tree lbound;
   gfc_se argse;
@@ -840,15 +840,21 @@
   if (as)
     {
       tree stride = gfc_conv_descriptor_stride (desc, bound);
+
       cond1 = fold_build2 (GE_EXPR, boolean_type_node, ubound, lbound);
       cond2 = fold_build2 (LE_EXPR, boolean_type_node, ubound, lbound);
+
       cond3 = fold_build2 (GT_EXPR, boolean_type_node, stride,
                           gfc_index_zero_node);
+      cond3 = fold_build2 (TRUTH_AND_EXPR, boolean_type_node, cond3, cond1);

+      cond4 = fold_build2 (LT_EXPR, boolean_type_node, stride,
+                          gfc_index_zero_node);
+      cond4 = fold_build2 (TRUTH_AND_EXPR, boolean_type_node, cond4, cond2);
+
       if (upper)
        {
-         cond = fold_build2 (TRUTH_AND_EXPR, boolean_type_node, cond3, cond1);
-         cond = fold_build2 (TRUTH_OR_EXPR, boolean_type_node, cond, cond2);
+         cond = fold_build2 (TRUTH_OR_EXPR, boolean_type_node, cond3, cond4);

          se->expr = fold_build3 (COND_EXPR, gfc_array_index_type, cond,
                                  ubound, gfc_index_zero_node);
@@ -858,13 +864,11 @@
          if (as->type == AS_ASSUMED_SIZE)
            cond = fold_build2 (EQ_EXPR, boolean_type_node, bound,
                                build_int_cst (TREE_TYPE (bound),
-                                              arg->expr->rank));
+                                              arg->expr->rank - 1));
          else
            cond = boolean_false_node;

-         cond1 = fold_build2 (TRUTH_AND_EXPR, boolean_type_node, cond3,
cond1);
-         cond1 = fold_build2 (TRUTH_OR_EXPR, boolean_type_node, cond1, cond2);
-
+         cond1 = fold_build2 (TRUTH_OR_EXPR, boolean_type_node, cond3, cond4);
          cond = fold_build2 (TRUTH_OR_EXPR, boolean_type_node, cond, cond1);

          se->expr = fold_build3 (COND_EXPR, gfc_array_index_type, cond,


-- 


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=29489


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]