diff mbox

[Fortran] PR 50070: Segmentation fault at size_binop_loc in fold-const.c

Message ID CAKwh3qhgdP9n5UvwzJpFeLoqqWjbOtmxUi4DC3GG+CvTG6aJaA@mail.gmail.com
State New
Headers show

Commit Message

Janus Weil Aug. 16, 2011, 5:18 p.m. UTC
Hi all,

here is a small patch for an ICE-on-invalid problem with COMMON and
character length. I was kinda surprised that we don't catch this
already. The fix is rather simple, but after the amount of discussion
(that I had with myself) in the PR, I probably cannot claim that it
was 'obvious' to me.

In any case, the patch was regtested on x86_64-unknown-linux-gnu. Ok for trunk?

Cheers,
Janus


2011-08-16  Janus Weil  <janus@gcc.gnu.org>

	PR fortran/50070
	* resolve.c (resolve_fl_variable): Reject non-constant character lengths
	in COMMON variables.


2011-08-16  Janus Weil  <janus@gcc.gnu.org>

	PR fortran/50070
	* gfortran.dg/common_13.f90: New.

Comments

Tobias Burnus Aug. 16, 2011, 9:47 p.m. UTC | #1
Janus Weil wrote:
> In any case, the patch was regtested on x86_64-unknown-linux-gnu. Ok for trunk?

OK. Thanks for the patch!

Tobias

> 2011-08-16  Janus Weil<janus@gcc.gnu.org>
>
> 	PR fortran/50070
> 	* resolve.c (resolve_fl_variable): Reject non-constant character lengths
> 	in COMMON variables.
>
>
> 2011-08-16  Janus Weil<janus@gcc.gnu.org>
>
> 	PR fortran/50070
> 	* gfortran.dg/common_13.f90: New.
Janus Weil Aug. 17, 2011, 9:20 a.m. UTC | #2
>> In any case, the patch was regtested on x86_64-unknown-linux-gnu. Ok for
>> trunk?
>
> OK. Thanks for the patch!

Thanks, Tobias. Committed as r177825.

Cheers,
Janus



>> 2011-08-16  Janus Weil<janus@gcc.gnu.org>
>>
>>        PR fortran/50070
>>        * resolve.c (resolve_fl_variable): Reject non-constant character
>> lengths
>>        in COMMON variables.
>>
>>
>> 2011-08-16  Janus Weil<janus@gcc.gnu.org>
>>
>>        PR fortran/50070
>>        * gfortran.dg/common_13.f90: New.
>
>
diff mbox

Patch

Index: gcc/fortran/resolve.c
===================================================================
--- gcc/fortran/resolve.c	(revision 177779)
+++ gcc/fortran/resolve.c	(working copy)
@@ -10169,15 +10169,22 @@  resolve_fl_variable (gfc_symbol *sym, int mp_flag)
 
       if (!gfc_is_constant_expr (e)
 	  && !(e->expr_type == EXPR_VARIABLE
-	       && e->symtree->n.sym->attr.flavor == FL_PARAMETER)
-	  && sym->ns->proc_name
-	  && (sym->ns->proc_name->attr.flavor == FL_MODULE
-	      || sym->ns->proc_name->attr.is_main_program)
-	  && !sym->attr.use_assoc)
+	       && e->symtree->n.sym->attr.flavor == FL_PARAMETER))
 	{
-	  gfc_error ("'%s' at %L must have constant character length "
-		     "in this context", sym->name, &sym->declared_at);
-	  return FAILURE;
+	  if (!sym->attr.use_assoc && sym->ns->proc_name
+	      && (sym->ns->proc_name->attr.flavor == FL_MODULE
+		  || sym->ns->proc_name->attr.is_main_program))
+	    {
+	      gfc_error ("'%s' at %L must have constant character length "
+			"in this context", sym->name, &sym->declared_at);
+	      return FAILURE;
+	    }
+	  if (sym->attr.in_common)
+	    {
+	      gfc_error ("COMMON variable '%s' at %L must have constant "
+			 "character length", sym->name, &sym->declared_at);
+	      return FAILURE;
+	    }
 	}
     }