https://gcc.gnu.org/bugzilla/show_bug.cgi?id=120845
Bug ID: 120845
Summary: C++20 module syntax
Product: gcc
Version: 15.1.1
Status: UNCONFIRMED
Severity: normal
Priority: P3
Component: c++
Assignee: unassigned at gcc dot gnu.org
Reporter: shyeyian at petalmail dot com
Target Milestone: ---
Codes below is not accepted in g++(15.1), while accepted in clang++(20.1) and
msvc(17):
```cpp
export module my_module
[[this_is_a_useless_attribute]];
```
g++ requires this attribute to be in same line as `my_module`, like
```cpp
export module my_module [[attribute_in_same_line]];
```
while clang++ and msvc does not have this requirement
According to
[cppreference](https://cppreference.com/w/cpp/language/modules.html), an
`export module` declaration has syntax below:
```
export(optional) module module-name module-partition (optional) attr
(optional) ;
```
It seems that module declaration is not demanded to be in one line. Maybe a
tiny change in AST will work :)
/*
As is known to all, no attributes is useful to modules currently. However
someone (like me) will write some additional module like this:
```cpp
export module my_module
[[cmake(./path/to/dir/CMakeLists.txt)]]
[[import_library(library.a)]];
```
and an external parser
```py
python_parse_and_cmake_and_integrate_install(module.cpp)
```
In this corner case we hope the module declaration (with attributes) can be
multi-lined.
*/
Thank you!