aboutsummaryrefslogtreecommitdiff
path: root/libcpp/init.c
diff options
context:
space:
mode:
Diffstat (limited to 'libcpp/init.c')
-rw-r--r--libcpp/init.c23
1 files changed, 23 insertions, 0 deletions
diff --git a/libcpp/init.c b/libcpp/init.c
index 76882bc..fc82658 100644
--- a/libcpp/init.c
+++ b/libcpp/init.c
@@ -843,4 +843,27 @@ post_options (cpp_reader *pfile)
CPP_OPTION (pfile, trigraphs) = 0;
CPP_OPTION (pfile, warn_trigraphs) = 0;
}
+
+ if (CPP_OPTION (pfile, module_directives))
+ {
+ /* These unspellable tokens have a leading space. */
+ const char *const inits[spec_nodes::M_HWM]
+ = {"export ", "module ", "import ", "__import"};
+
+ for (int ix = 0; ix != spec_nodes::M_HWM; ix++)
+ {
+ cpp_hashnode *node = cpp_lookup (pfile, UC (inits[ix]),
+ strlen (inits[ix]));
+
+ /* Token we pass to the compiler. */
+ pfile->spec_nodes.n_modules[ix][1] = node;
+
+ if (ix != spec_nodes::M__IMPORT)
+ /* Token we recognize when lexing, drop the trailing ' '. */
+ node = cpp_lookup (pfile, NODE_NAME (node), NODE_LEN (node) - 1);
+
+ node->flags |= NODE_MODULE;
+ pfile->spec_nodes.n_modules[ix][0] = node;
+ }
+ }
}