Skip to content

Template arguments can't be used in attributes #67154

@abrachet

Description

@abrachet
constexpr int constexpr_var = 101;
[[gnu::constructor(constexpr_var)]] void a() {}

template <int TemplateArg>
[[gnu::constructor(TemplateArg)]] void b() {}

template void b<101>();

This code compiles fine with gcc, and clang can successfully compile a but errors on b with "'constructor' attribute requires an integer constant".

Note clang doesn't error on the instantiation of b but rather on the template definition. so even if the template void b<101>(); line is removed clang still gives an error.

Metadata

Metadata

Assignees

No one assigned

    Labels

    clang:frontendLanguage frontend issues, e.g. anything involving "Sema"good first issuehttps://github.com/llvm/llvm-project/contribute

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions