Skip to content

[BUG] Modules support #269

Closed
Closed
@JohelEGP

Description

@JohelEGP

Describe the bug
A clear and concise description of what the bug is.

  1. export module a; doesn't work in -pure-cpp2 mode.
  2. #include "cpp2util.h" should be inserted in the GMF.
    Additional work might also be necessary.
    1. CPP2_USE_MODULES shouldn't be defined while preprocessing it, as imports can't come from an #include.
    2. With regards to the #ifdef CPP2_USE_MODULES,
      its #ifdef __cpp_modules branch of should happen after the GMF, and
      its #else branch in the GMF.
  3. No declaration can be exported. It's not part of the grammar, and as such can't happen in the generated code.
    I suppose one can also run into an issue due to the lack of support for inline, similar to Fix duplicate symbol of cpp2::args() function #268.

To Reproduce
Steps to reproduce the behavior:

  1. Sample code - distilled down to minimal essentials please
    1. https://godbolt.org/z/7bP99nr4q
    2. https://godbolt.org/z/1f4Tr4bxM
    3. https://godbolt.org/z/rY6WG38nx
  2. Command lines including which C++ compiler you are using
    1. Happens at the cppfront level.
    2. TBD
    3. Happens at the cppfront level.
  3. Expected result - what you expected to happen
    1. Cpp2 supports exporting modules.
    2. The functionality provided by the generated #include "cpp2util.h" also works in module units.
    3. Declarations can be exported.
  4. Actual result/error
    1. example.cpp2(1,1): error: pure-cpp2 switch disables Cpp1 syntax
      
    2. error: declaration of 'operator new' in module main follows declaration in the global module
      
    3. example.cpp2(2,13): error: missing semicolon at end of declaration (at 'namespace')
      example.cpp2(2,1): error: unexpected text at end of Cpp2 code section (at 'ns')
      example.cpp2(2,0): error: parse failed for section starting here
      

Additional context
Add any other context about the problem here.

Metadata

Metadata

Assignees

No one assigned

    Labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions