diff mbox

[fortran] Cosmetics: Dup. code removal, indent fix, typo fix.

Message ID 20150130131029.3b61ba87@vepi2
State New
Headers show

Commit Message

Andre Vehreschild Jan. 30, 2015, 12:10 p.m. UTC
Hi all,

I fear this fix is not so obvious in one location, I therefore ask for a
review. The attached patch fixes:

- a duplicate code fragment (possibly due to merged twice),
- the indentation in the trans-expr.c block (in my first patch), and
- a typo on the datatype-size to create for the charlen.

The length of a char-array is stored as a 4-byte BT_INTEGER. Due to a typo a
1-byte BT_INTEGER was requested. The patch fixes this. I know this patch mixes
several trivial issues. Should I do separate patches for each of them, or what
is the most desirable method?

Bootstraps and regtests ok on x86_64-linux-gnu/FC20.

Regards,
	Andre

Comments

Jerry DeLisle Jan. 31, 2015, 3:41 p.m. UTC | #1
On 01/30/2015 04:10 AM, Andre Vehreschild wrote:
> Hi all,
>
> I fear this fix is not so obvious in one location, I therefore ask for a
> review. The attached patch fixes:
>
> - a duplicate code fragment (possibly due to merged twice),
> - the indentation in the trans-expr.c block (in my first patch), and
> - a typo on the datatype-size to create for the charlen.
>
> The length of a char-array is stored as a 4-byte BT_INTEGER. Due to a typo a
> 1-byte BT_INTEGER was requested. The patch fixes this. I know this patch mixes
> several trivial issues. Should I do separate patches for each of them, or what
> is the most desirable method?
>

Cosmetic things are OK to throw in the mix as long as you have the Changelog. 
Duplicate code removal is just about as obvious as one can get. No need for 
separate patches.

> Bootstraps and regtests ok on x86_64-linux-gnu/FC20.
>

I have learned the hard way that if you forget the testing even on trivial 
things it can byte you.  OK to commit!  Thanks.
diff mbox

Patch

diff --git a/gcc/fortran/trans-decl.c b/gcc/fortran/trans-decl.c
index 8a65d2b..3664824 100644
--- a/gcc/fortran/trans-decl.c
+++ b/gcc/fortran/trans-decl.c
@@ -1443,8 +1443,6 @@  gfc_get_symbol_decl (gfc_symbol * sym)
       if (sym->ts.type == BT_CLASS && sym->backend_decl)
 	GFC_DECL_CLASS(sym->backend_decl) = 1;
 
-      if (sym->ts.type == BT_CLASS && sym->backend_decl)
-	GFC_DECL_CLASS(sym->backend_decl) = 1;
      return sym->backend_decl;
     }
 
diff --git a/gcc/fortran/trans-expr.c b/gcc/fortran/trans-expr.c
index 91cac41..c001d13 100644
--- a/gcc/fortran/trans-expr.c
+++ b/gcc/fortran/trans-expr.c
@@ -660,26 +660,26 @@  gfc_conv_intrinsic_to_class (gfc_se *parmse, gfc_expr *e,
 	 expression can be evaluated to a constant one.  */
       else
         {
-          /* Try to simplify the expression.  */
-          gfc_simplify_expr (e, 0);
-          if (e->expr_type == EXPR_CONSTANT && !e->ts.u.cl->resolved)
-            {
-              /* Amazingly all data is present to compute the length of a
-                 constant string, but the expression is not yet there.  */
-              e->ts.u.cl->length = gfc_get_constant_expr (BT_INTEGER, 1,
-                                                          &e->where);
-              mpz_set_ui (e->ts.u.cl->length->value.integer,
-                          e->value.character.length);
-              gfc_conv_const_charlen (e->ts.u.cl);
-              e->ts.u.cl->resolved = 1;
-              gfc_add_modify (&parmse->pre, ctree, e->ts.u.cl->backend_decl);
-            }
-          else
-            {
-              gfc_error ("Can't compute the length of the char array at %L.",
-                         &e->where);
-            }
-        }
+	  /* Try to simplify the expression.  */
+	  gfc_simplify_expr (e, 0);
+	  if (e->expr_type == EXPR_CONSTANT && !e->ts.u.cl->resolved)
+	    {
+	      /* Amazingly all data is present to compute the length of a
+		 constant string, but the expression is not yet there.  */
+	      e->ts.u.cl->length = gfc_get_constant_expr (BT_INTEGER, 4,
+							  &e->where);
+	      mpz_set_ui (e->ts.u.cl->length->value.integer,
+			  e->value.character.length);
+	      gfc_conv_const_charlen (e->ts.u.cl);
+	      e->ts.u.cl->resolved = 1;
+	      gfc_add_modify (&parmse->pre, ctree, e->ts.u.cl->backend_decl);
+	    }
+	  else
+	    {
+	      gfc_error ("Can't compute the length of the char array at %L.",
+			 &e->where);
+	    }
+	}
     }
   /* Pass the address of the class object.  */
   parmse->expr = gfc_build_addr_expr (NULL_TREE, var);