Skip to content

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

@ckwastra

Description

@ckwastra

Test code (CE):

export module M;
export template <class> 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 <class T> struct S<T *> {};

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

// ❌ - 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<void> {};

P2615R1 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.

Metadata

Metadata

Assignees

No one assigned

    Labels

    clang:modulesC++20 modules and Clang Header Modules

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions