Skip to content

Commit d487dc7

Browse files
burblebeetkoeppe
authored andcommitted
CWG2667 Named module imports do not import macros
1 parent dbfffcc commit d487dc7

File tree

2 files changed

+19
-0
lines changed

2 files changed

+19
-0
lines changed

source/modules.tex

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -512,6 +512,13 @@
512512
\end{footnote}
513513
These rules can in turn lead to the importation of yet more
514514
translation units.
515+
\begin{note}
516+
Such indirect importation does not make macros available,
517+
because a translation unit is
518+
a sequence of tokens in translation phase 7\iref{lex.phases}.
519+
Macros can be made available by directly importing header units
520+
as described in \ref{cpp.import}.
521+
\end{note}
515522

516523
\pnum
517524
A module implementation unit shall not be exported.

source/preprocessor.tex

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -929,6 +929,18 @@
929929
int a = Y; // OK, active macro definitions \#2 and \#4 are valid redefinitions
930930
int c = Z; // error: active macro definitions \#3 and \#5 are not valid redefinitions of \tcode{Z}
931931
\end{codeblocktu}
932+
933+
\begin{codeblocktu}{Module unit \tcode{f}}
934+
export module f;
935+
export import "a.h";
936+
937+
int a = Y; // OK
938+
\end{codeblocktu}
939+
940+
\begin{codeblocktu}{Translation unit \tcode{\#1}}
941+
import f;
942+
int x = Y; // error: \tcode{Y} is neither a defined macro nor a declared name
943+
\end{codeblocktu}
932944
\end{example}
933945
\indextext{macro!import|)}
934946

0 commit comments

Comments
 (0)