switch (m)
{
case MATCH_YES:
- if (gfc_current_ns->parent != NULL
+ if (gfc_current_ns->parent != NULL
&& gfc_find_symbol (name, gfc_current_ns->parent, 1, &sym))
{
gfc_error ("Type name %qs at %C is ambiguous", name);
return MATCH_ERROR;
}
- else if (!sym && gfc_current_ns->proc_name->ns->parent != NULL
+ else if (!sym
+ && gfc_current_ns->proc_name
+ && gfc_current_ns->proc_name->ns->parent
&& gfc_find_symbol (name,
gfc_current_ns->proc_name->ns->parent,
1, &sym))
if (sym == NULL)
{
- if (gfc_current_ns->proc_name->attr.if_source == IFSRC_IFBODY)
+ if (gfc_current_ns->proc_name
+ && gfc_current_ns->proc_name->attr.if_source == IFSRC_IFBODY)
{
gfc_error ("Cannot IMPORT %qs from host scoping unit "
"at %C - does not exist.", name);
--- /dev/null
+! { dg-do compile }
+!
+! Contributed by Steve Kargl <sgk@troutmask.apl.washington.edu>
+!
+program foo
+ implicit none
+ integer i
+ i = 42
+ if (i /= 42) stop 1
+ call bah
+ contains
+ subroutine bah ! { dg-error "is already defined at" }
+ i = 43
+ if (i /= 43) stop 2
+ end subroutine bah
+ subroutine bah ! { dg-error "is already defined at" }
+ ! import statement missing a comma
+ import none ! { dg-error "Unexpected IMPORT statement" }
+ i = 44 ! { dg-error "Unexpected assignment" }
+ end subroutine bah ! { dg-error "Expecting END PROGRAM" }
+end program foo