llvm / llvm/llvm-project

P2615 (Meaningful exports) is not fully implemented: Diagnostic required

Open
#160,016 2 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

accepts-invalid clang:modules
Dominant language
LLVM
Stars
40.5k
Forks
18.7k
PR merge metrics
PR metrics pending

Description

Test code ([CE](https://godbolt.org/z/Yov6xcKq7)):

```cpp
export module M;
export template struct S {};

// ❌ - Clang/MSVC/EDG: OK
// ✅ - GCC:
// - error: declaration of partial specialization in unbraced
// export-declaration
// - note: a specialization is always exported alongside its
// primary template
export template struct S {};

// ❌ - Clang/MSVC/EDG: OK
// ✅ - GCC: error: explicit instantiations are not permitted here
export template struct S;

// ❌ - Clang/MSVC/EDG: OK
// ✅ - GCC:
// - error: explicit specializations are not permitted here
// - note: a specialization is always exported alongside its
// primary template
export template <> struct S {};
```

[P2615R1](https://www.open-std.org/jtc1/sc22/wg21/docs/papers/2022/p2615r1.html) forbids applying `export` directly to partial specializations and explicit instantiations/specializations, as doing so is meaningless. (These declarations are allowed to appear within an `export` block for convenience.) The code above should be diagnosed accordingly.

Related: #147135.

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start with the Compiler Explorer test code in the issue and read P2615R1, focusing on the rules for export declarations involving partial specializations, explicit instantiations, and explicit specializations. Compare the current diagnostics with the three examples; done means each directly exported declaration is diagnosed as required, while declarations inside an export block remain permitted.

Written by the indexing model from the issue text.

Assessment

Tech stack
cpp
Domain
compilers
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
42/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.