]> granicus.if.org Git - clang/commitdiff
Permit keywords in module names in #pragma clang module *.
authorRichard Smith <richard-llvm@metafoo.co.uk>
Fri, 5 May 2017 22:34:07 +0000 (22:34 +0000)
committerRichard Smith <richard-llvm@metafoo.co.uk>
Fri, 5 May 2017 22:34:07 +0000 (22:34 +0000)
This is necessary to be able to build a libc++ module from preprocessed source
(due to the submodule std.new).

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@302312 91177308-0d34-0410-b5e6-96231b3b80d8

lib/Lex/Pragma.cpp
test/Preprocessor/pragma_module.c

index 51da2baac9ec912372951b81a8e07b71d266ed9d..99d56182c1bb90f552065ce8d28efe51512d79da 100644 (file)
@@ -1307,7 +1307,7 @@ static bool LexModuleName(
         &ModuleName) {
   while (true) {
     PP.LexUnexpandedToken(Tok);
-    if (Tok.isNot(tok::identifier)) {
+    if (Tok.isAnnotation() || !Tok.getIdentifierInfo()) {
       PP.Diag(Tok.getLocation(), diag::err_pp_expected_module_name)
         << ModuleName.empty();
       return true;
index 3763ca333c1abbd9cb70dd9b945ee2f3f3477e0a..90aa9481fb13c52c96026d43df74d6ff700e6d19 100644 (file)
@@ -1,13 +1,14 @@
 // RUN: rm -rf %t
 // RUN: mkdir %t
-// RUN: echo 'module foo { module a {} module b {} } module bar {}' > %t/module.map
-// RUN: %clang -cc1 -E -fmodules %s -verify -fmodule-name=foo -fmodule-map-file=%t/module.map
-// RUN: %clang -cc1 -E -fmodules %s -verify -fmodule-name=foo -fmodule-map-file=%t/module.map -fmodules-local-submodule-visibility -DLOCAL_VIS
+// RUN: echo 'module foo { module a {} module b {} } module bar {} module if {}' > %t/module.map
+// RUN: %clang -cc1 -fmodules -fmodule-name=if -x c %t/module.map -emit-module -o %t/if.pcm
+// RUN: %clang -cc1 -E -fmodules %s -fmodule-file=%t/if.pcm -verify -fmodule-name=foo -fmodule-map-file=%t/module.map
+// RUN: %clang -cc1 -E -fmodules %s -fmodule-file=%t/if.pcm -verify -fmodule-name=foo -fmodule-map-file=%t/module.map -fmodules-local-submodule-visibility -DLOCAL_VIS
 
 // Just checking the syntax here; the semantics are tested elsewhere.
 #pragma clang module import // expected-error {{expected module name}}
 #pragma clang module import ! // expected-error {{expected module name}}
-#pragma clang module import if // expected-error {{expected module name}}
+#pragma clang module import if // ok
 #pragma clang module import foo ? bar // expected-warning {{extra tokens at end of #pragma}}
 #pragma clang module import foo. // expected-error {{expected identifier after '.' in module name}}
 #pragma clang module import foo.bar.baz.quux // expected-error {{no submodule named 'bar' in module 'foo'}}