Skip to content

[clang] _Pragma("clang diagnostic ignored \"-Wconstant-evaluated\"") with push+pop sometimes doesn't work when there are macros involved #107715

Open
@MitalAshok

Description

@MitalAshok

Minimised to https://godbolt.org/z/96d8bnsKa:

#define _LIBCPP_DIAGNOSTIC_POP _Pragma("clang diagnostic pop")

#define A                                                        \
  (_Pragma("clang diagnostic push")                              \
   _Pragma("clang diagnostic ignored \"-Wconstant-evaluated\"")  \
   __builtin_is_constant_evaluated()                             \
   _LIBCPP_DIAGNOSTIC_POP)

#define echo(...) __VA_ARGS__

static_assert(echo(A), "");
<source>:11:20: warning: '__builtin_is_constant_evaluated' will always evaluate to 'true' in a manifestly constant-evaluated expression [-Wconstant-evaluated]
   11 | static_assert(echo(A), "");
      |                    ^
<source>:6:4: note: expanded from macro 'A'
    6 |    __builtin_is_constant_evaluated()                             \
      |    ^

Metadata

Metadata

Assignees

No one assigned

    Labels

    clang:diagnosticsNew/improved warning or error message in Clang, but not in clang-tidy or static analyzerconfirmedVerified by a second party

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions