[Bug fortran/51308] PARAMETER attribute conflicts with SAVE attribute
sgk at troutmask dot apl.washington.edu
gcc-bugzilla@gcc.gnu.org
Sun Nov 27 22:14:00 GMT 2011
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=51308
--- Comment #2 from Steve Kargl <sgk at troutmask dot apl.washington.edu> 2011-11-27 21:56:30 UTC ---
On Sat, Nov 26, 2011 at 07:21:29PM +0000, kargl at gcc dot gnu.org wrote:
> The problem comes about because of gen_special_c_interop_ptr() in
> symbol.c has the following lines:
>
> /* Set up the symbol's important fields. Save attr required so we can
> initialize the ptr to NULL. */
> tmp_sym->attr.save = SAVE_EXPLICIT;
>
> I think that we should be setting
>
> tmp_sym->attr.flavor = FL_PARAMETER;
>
> or something equivalent rather than the save attribute.
>
attr.flavor was actually set further down in the file. The
following patch appears to work, but it ceratinly feels to
be a kludge.
Index: symbol.c
===================================================================
--- symbol.c (revision 181731)
+++ symbol.c (working copy)
@@ -742,7 +742,8 @@ check_conflict (symbol_attribute *attr,
conf2 (asynchronous);
conf2 (threadprivate);
conf2 (value);
- conf2 (is_bind_c);
+ if (!(name && (strcmp(name, "c_null_ptr") == 0 || strcmp(name,
"c_null_funptr") == 0)))
+ conf2 (is_bind_c);
conf2 (codimension);
conf2 (result);
break;
@@ -3765,7 +3766,11 @@ gen_special_c_interop_ptr (int ptr_id, c
/* Set up the symbol's important fields. Save attr required so we can
initialize the ptr to NULL. */
- tmp_sym->attr.save = SAVE_EXPLICIT;
+ tmp_sym->attr.save = SAVE_IMPLICIT;
+ /* Must declare c_null_ptr and c_null_funptr as having the
+ PARAMETER attribute so they can be used in init expressions. */
+ tmp_sym->attr.flavor = FL_PARAMETER;
+
tmp_sym->ts.is_c_interop = 1;
tmp_sym->attr.is_c_interop = 1;
tmp_sym->ts.is_iso_c = 1;
@@ -3777,6 +3782,7 @@ gen_special_c_interop_ptr (int ptr_id, c
tmp_sym->ts.u.derived = get_iso_c_binding_dt (ISOCBINDING_PTR);
else
tmp_sym->ts.u.derived = get_iso_c_binding_dt (ISOCBINDING_FUNPTR);
+
if (tmp_sym->ts.u.derived == NULL)
{
/* This can occur if the user forgot to declare c_ptr or
@@ -3817,9 +3823,6 @@ gen_special_c_interop_ptr (int ptr_id, c
c->expr = gfc_get_expr ();
c->expr->expr_type = EXPR_NULL;
c->expr->ts.is_iso_c = 1;
- /* Must declare c_null_ptr and c_null_funptr as having the
- PARAMETER attribute so they can be used in init expressions. */
- tmp_sym->attr.flavor = FL_PARAMETER;
return SUCCESS;
}
More information about the Gcc-bugs
mailing list