Skip to content

Allow maybe_unused in pre-C++17 / pre-C23 modes #170408

@ahatanak

Description

@ahatanak

[[maybe_unused]] is helpful for suppressing warnings about declarations that may or may not be referenced. However, clang currently accepts it only in c++17 (or c23 for C) and later. Users who target older standards often rely on inconvenient workarounds, such as wrapping code in #pragma clang diagnostic push/pop to silence warnings.

It would be useful if clang accepted a spelling like __attribute__((maybe_unused)) for earlier language modes.

Metadata

Metadata

Assignees

No one assigned

    Labels

    clang:frontendLanguage frontend issues, e.g. anything involving "Sema"questionA question, not bug report. Check out https://llvm.org/docs/GettingInvolved.html instead!

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions