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

Erich Keane via Phabricator via cfe-commits cfe-commits at lists.llvm.org
Fri Oct 28 08:20:18 PDT 2022


erichkeane added inline comments.


================
Comment at: clang/lib/Sema/SemaModule.cpp:257
+    else if (PartName.startswith("std") &&
+             (PartName.size() == 3 || isDigit(PartName.drop_front(3)[0])))
+      Reason = /*reserved*/ 1;
----------------
aaron.ballman wrote:
> cor3ntin wrote:
> > 
> lol but my way is so much more complicated, so it must be more right... ;-)
Is this logic right?  By my reading of the standard, 

`export module stdFoo.bar` << fine
`export module std00Foo.bar` << fine

as neither  'consist of std followed by zero or more digits'.

This patch looks like it'll only allow the 1st, but not the 2nd.  


================
Comment at: clang/test/Modules/reserved-names.cpp:30
+
+export module should_fail.std0;  // expected-error {{'std0' is a reserved name for a module}} \
+                                    expected-error {{module declaration must occur at the start of the translation unit}}
----------------
SHOULD this fail?  

This is NOT a module name beginning with an identifier-consisting-of-std followed by 0 or more digits.

The 'containing' part applies to just the reserved identifiers.



Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D136953



More information about the cfe-commits mailing list