<table border="1" cellspacing="0" cellpadding="8">
    <tr>
        <th>Issue</th>
        <td>
            <a href=https://github.com/llvm/llvm-project/issues/102558>102558</a>
        </td>
    </tr>

    <tr>
        <th>Summary</th>
        <td>
            [Flang] Compilation error when implicit none declared in module is valid in submodule
        </td>
    </tr>

    <tr>
      <th>Labels</th>
      <td>
            flang:frontend
      </td>
    </tr>

    <tr>
      <th>Assignees</th>
      <td>
      </td>
    </tr>

    <tr>
      <th>Reporter</th>
      <td>
          ohno-fj
      </td>
    </tr>
</table>

<pre>
    ```
Version of flang-new : 20.0.0(8dd065d5bc81b0c8ab57f365bb169a5d92928f25)/AArch64
```

When `implicit none` declared in `module` is valid in `submodule`, a compilation error occurs.

The following are the test program, Flang-new, Gfortran and ifort compilation/execution result.

sngg137h_212.f90:
```fortran
module m3
  implicit none
  interface
    module subroutine sub(k,s)
    implicit none
    interface
      subroutine s()
      end
    end interface
    procedure(s)::k
    end
  end interface
end

submodule(m3)smod
  common /cmn/ i
contains
 module procedure sub
  call k
  if (i/=1)print *,901
  call s
 if (i/=2)print *,902
  end
end

program main
  use m3
 common /cmn/ i
  interface
     subroutine k()
     end
 subroutine s()
     end
  end interface
  call sub(k,s)
  if (i/=2) print *,201
  print *,'pass'
end

subroutine k()
 common /cmn/ i
  i=1
end

subroutine s()
  common /cmn/ i
 i=2
end
```

```
$ flang-new sngg137h_212.f90
error: Semantic errors in sngg137h_212.f90
./sngg137h_212.f90:16:16: error: No explicit type declared for 'i'
    common /cmn/ i
 ^
$
```

```
$ gfortran sngg137h_212.f90; ./a.out
 pass
$
```

```
$ ifort -diag-disable=10448 sngg137h_212.f90; ./a.out
 pass
$
```



</pre>
<img width="1px" height="1px" alt="" src="http://email.email.llvm.org/o/eJysVs1u6zYTfRp6M7BBjX5MLbTwTT59u25atMuCIimZNxRpkFRy79sXkiXFjpUULQoEiklqzvCcGZ8xD0F3VqmK5N9I_rzjQzw7X7mzdfv2-65x8mdFCjr_0WdCT78rH7Sz4FpoDbfd3q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