[PATCH] D136953: [C++20] Diagnose invalid and reserved module names

Corentin Jabot via Phabricator via cfe-commits cfe-commits at lists.llvm.org
Fri Oct 28 11:49:52 PDT 2022


cor3ntin added inline comments.


================
Comment at: clang/lib/Sema/SemaModule.cpp:241-248
+  // C++2b [module.unit]p1: ... The identifiers module and import shall not
+  // appear as identifiers in a module-name or module-partition. All
+  // module-names either beginning with an identifier consisting of std
+  // followed by zero or more digits or containing a reserved identifier
+  // ([lex.name]) are reserved and shall not be specified in a
+  // module-declaration; no diagnostic is required.
+  bool IsFirstComponent = true;
----------------
Did you consider making this a function?
I think you could just check `Path[0]` for  reserved stdxxx syntax, and then all parts for reserved/import/module. Might simplify the code a bit.


================
Comment at: clang/test/Modules/reserved-names-2.cpp:6
+// is not the first part of the path.
+export module should_fail.std0;
+
----------------
should_fail? Did you mean the opposite?


CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D136953/new/

https://reviews.llvm.org/D136953



More information about the cfe-commits mailing list