vtab->attr.save = SAVE_IMPLICIT;
vtab->attr.vtab = 1;
vtab->attr.access = ACCESS_PUBLIC;
+ vtab->attr.artificial = 1;
gfc_set_sym_referenced (vtab);
free (name);
name = xasprintf ("__vtype_%s", tname);
goto cleanup;
c->attr.proc_pointer = 1;
c->attr.access = ACCESS_PRIVATE;
+ c->attr.artificial = 1;
c->tb = XCNEW (gfc_typebound_proc);
c->tb->ppc = 1;
if (derived->attr.unlimited_polymorphic
goto cleanup;
c->attr.proc_pointer = 1;
c->attr.access = ACCESS_PRIVATE;
+ c->attr.artificial = 1;
c->tb = XCNEW (gfc_typebound_proc);
c->tb->ppc = 1;
if (derived->attr.unlimited_polymorphic || derived->attr.abstract
goto cleanup;
c->attr.proc_pointer = 1;
c->attr.access = ACCESS_PRIVATE;
+ c->attr.artificial = 1;
c->tb = XCNEW (gfc_typebound_proc);
c->tb->ppc = 1;
#endif
}
+
+/* Helper function for checking of variables declared in a BLOCK DATA program
+ unit. */
+
+static void
+check_block_data_decls (gfc_symbol * sym)
+{
+ if (warn_unused_variable
+ && sym->attr.flavor == FL_VARIABLE
+ && !sym->attr.in_common
+ && !sym->attr.artificial)
+ {
+ gfc_warning (OPT_Wunused_variable,
+ "Symbol %qs at %L is declared in a BLOCK DATA "
+ "program unit but is not in a COMMON block",
+ sym->name, &sym->declared_at);
+ }
+}
+
+
/* Translates a BLOCK DATA program unit. This means emitting the
commons contained therein plus their initializations. We also emit
a globally visible symbol to make sure that each BLOCK DATA program
/* Process the DATA statements. */
gfc_trans_common (ns);
+ /* Check for variables declared in BLOCK DATA but not used in COMMON. */
+ gfc_traverse_ns (ns, check_block_data_decls);
+
/* Create a global symbol with the mane of the block data. This is to
generate linker errors if the same name is used twice. It is never
really used. */
--- /dev/null
+! { dg-do compile }
+! { dg-additional-options "-Wunused-variable" }
+!
+! PR fortran/58857
+
+BLOCK DATA valid
+ integer :: i
+ integer :: n ! { dg-warning "not in a COMMON block" }
+ class(*) :: zz ! { dg-warning "not in a COMMON block" }
+ pointer :: zz
+ common /com/ i, r
+END BLOCK DATA valid