+2016-09-29 Steven G. Kargl <kargl@gcc.gnu.org>
+
+ Backport from trunk
+ PR fortran/71067
+ * decl.c (match_data_constant): On error, set 'result' to NULL.
+
+ PR fortran/77260
+ * gcc/fortran/trans-decl.c (generate_local_decl): Suppress warning
+ for unused variable if symbol is entry point.
+
2016-09-29 Steven G. Kargl <kargl@gcc.gnu.org>
Backport from trunk
{
gfc_error ("Symbol %qs must be a PARAMETER in DATA statement at %C",
name);
+ *result = NULL;
return MATCH_ERROR;
}
else if (dt_sym && dt_sym->attr.flavor == FL_DERIVED)
}
else if (!sym->attr.use_assoc)
{
- gfc_warning (OPT_Wunused_variable,
- "Unused variable %qs declared at %L",
- sym->name, &sym->declared_at);
+ /* Corner case: the symbol may be an entry point. At this point,
+ it may appear to be an unused variable. Suppress warning. */
+ bool enter = false;
+ gfc_entry_list *el;
+
+ for (el = sym->ns->entries; el; el=el->next)
+ if (strcmp(sym->name, el->sym->name) == 0)
+ enter = true;
+
+ if (!enter)
+ gfc_warning (OPT_Wunused_variable,
+ "Unused variable %qs declared at %L",
+ sym->name, &sym->declared_at);
if (sym->backend_decl != NULL_TREE)
TREE_NO_WARNING(sym->backend_decl) = 1;
}
+2016-09-29 Steven G. Kargl <kargl@gcc.gnu.org>
+
+ Backport from trunk
+ PR fortran/71067
+ * gfortran.dg/pr71067_1.f90: New test.
+ * gfortran.dg/pr71067_2.f90: Ditto.
+
+ PR fortran/77260
+ * gfortran.dg/pr77260_1.f90: New test.
+ * gfortran.dg/pr77260_2.f90: Ditto.
+
2016-09-29 Steven G. Kargl <kargl@gcc.gnu.org>
Louis Krupp <lkrupp@gcc.gnu.org>
--- /dev/null
+program p
+ integer :: i = 0
+ integer :: z(2)
+ data z /2*i/ ! { dg-error "must be a PARAMETER in DATA" }
+end
--- /dev/null
+! { dg-do compile }
+program p
+ integer :: a(2), b(2), c(2)
+ data a /2*b1'/ ! { dg-error "must be a PARAMETER in DATA" }
+ data b /2*o1' ! { dg-error "must be a PARAMETER in DATA" }
+ data c /2*z1 ! { dg-error "must be a PARAMETER in DATA" }
+end
--- /dev/null
+! { dg-do compile }
+! { dg-options "-Wall" }
+module foo
+
+ implicit none
+
+ private
+ public f1,f2
+
+ contains
+
+ integer function f1()
+ integer f2
+ f1=5
+ entry f2
+ f2=8
+ end function
+end module
+
+program test
+ use foo
+ implicit none
+ print *,f2()
+end program
+! { dg-final { cleanup-modules "foo" } }
--- /dev/null
+! { dg-do compile }
+! { dg-options "-Wall" }
+module foo
+
+ implicit none
+
+ private
+ public f1,f2
+
+ contains
+
+ integer function f1()
+ integer f2
+ integer f3 ! { dg-warning "Unused variable" }
+ f1=5
+ entry f2
+ f2=8
+ end function
+end module
+
+program test
+ use foo
+ implicit none
+ print *,f2()
+end program
+! { dg-final { cleanup-modules "foo" } }