<html><head>
<meta http-equiv="content-type" content="text/html; charset=UTF-8"><style>
ins {background-color:#A0FFA0}
del {background-color:#FFA0A0}
strong { color: #2020ff }
#hidedel:checked ~ * del, #hidedel:checked ~ * del * { display:none; visibility:hidden }
</style> 
<title>P2109R0: US084: Disallow "export import foo" outside of module interface</title>
  </head><body>
ISO/IEC JTC1 SC22 WG21 P2109R0<br>
    Nathan Sidwell<br>
    Target audience: CWG, Plenary
2020-02-13

<h1>P2109R0: US084: Disallow "export import foo" outside of module interface</h1>

<p>This paper resolves NB Comment US084:</p>
<blockquote><tt>export import foo;</tt> should not be allowed outside of module
  interface purview.</blockquote>

<p>Both US033 and p1857 alter grammar and/or semantics of import
  declarations.  The changes here presume both US033 and p1857 are
  accepted. p1857 introduced a problem with exported
  module-import-declarations.  They ceased to be a thing.  This
  wording also addresses that.</p>

<h2>Wording:</h2>

<p>Change [module.interface] para 1 (10.2)</p>

<blockquote><em>export-declaration</em> :<br>
&nbsp;&nbsp;&nbsp;&nbsp;<tt>export</tt> <em>declaration</em><br>
&nbsp;&nbsp;&nbsp;&nbsp;<tt>export</tt> <tt>{</tt> <em>declaration-seq<sub>opt</sub></em> <tt>}</tt><br>
&nbsp;&nbsp;&nbsp;&nbsp;<ins><em>export-keyword</em> <em>module-import-declaration</em></ins>
</blockquote>
<blockquote>
An <em>export-declaration</em> shall appear only at namespace scope and only
in the purview of a module interface unit. An <em>export-declaration</em> shall
not appear directly or indirectly within an unnamed namespace or a
<em>private-module-fragment</em>. An <em>export-declaration</em> has
the declarative effects of its <em>declaration</em><ins>,</ins> <del>or</del>
<del>its</del> <em>declaration-seq</em> (if any)<ins>, or <em>module-import-declaration</em></ins>. An <em>export-declaration</em>
does not establish a scope and its <em>declaration</em>
or <em>declaration-seq</em> shall not contain
an <em>export-declaration</em> <ins>or <em>module-import-declaration</em></ins>.
</blockquote>

<p>Para 2:</p>
<blockquote>A declaration is <em>exported</em> if it is<br>
&mdash; a namespace-scope declaration declared within
  an <em>export-declaration</em>, or<br>
&mdash; a <em>module-import-declaration</em> <del>declared with the export
keyword (10.3)</del><ins>within an <em>export-declaration</em></ins>, or<br>
&mdash; a <em>namespace-definition</em> that contains an exported
declaration, or<br>
&mdash; a declaration within a header unit (10.3) that introduces at
least one name.</blockquote>

<p>Para 3:</p>
<blockquote>An exported declaration <ins>that is not
  a <em>module-import-declaration</em></ins> shall declare at least
  one name. If the declaration is not within a header unit, it shall
  not declare a name with internal linkage.</blockquote>
 
<p>Change [module.import] para 1 (10.3), as already modified by us033 & p1857</p>
<blockquote>
<em>module-import-declaration</em>:<br>
&nbsp;&nbsp;&nbsp;&nbsp;<del><em>export-keyword<sub>opt</sub></em></del> <em>import-keyword</em> <em>module-name</em> <em>attribute-specifier-seq<sub>opt</sub></em> <tt>;</tt><br>
&nbsp;&nbsp;&nbsp;&nbsp;<del><em>export-keyword<sub>opt</sub></em></del> <em>import-keyword</em> <em>module-partition</em> <em>attribute-specifier-seq<sub>opt</sub></em> <tt>;</tt><br>
&nbsp;&nbsp;&nbsp;&nbsp;<del><em>export-keyword<sub>opt</sub></em></del> <em>import-keyword</em> <em>header-name</em> <em>attribute-specifier-seq<sub>opt</sub></em> <tt>;</tt><br>
</blockquote>
<blockquote>A <em>module-import-declaration</em> shall only appear at
  global namespace scope. In a module unit,
  all <em>module-import-declaration</em>s<ins>
  and <em>export-declarations</em>
  exporting <em>module-import-declaration</em>s,</ins> shall precede
  all other <em>declaration</em>s in the <em>declaration-seq</em> of
  the <em>translation-unit</em> and of
  the <em>private-module-fragment</em> (if any). The
  optional <em>attribute-specifier-seq</em> appertains to the
  module-import-declaration.</blockquote>

</body></html>
