[PATCH] D45403: Make [[maybe_unused]] work with static data members
S. B. Tam via Phabricator via cfe-commits
cfe-commits at lists.llvm.org
Sat Apr 7 04:23:14 PDT 2018
cpplearner added inline comments.
================
Comment at: test/CXX/dcl.dcl/dcl.attr/dcl.attr.unused/p2.cpp:5
int I [[maybe_unused]];
- static int SI [[maybe_unused]]; // expected-warning {{'maybe_unused' attribute only applies to variables, functions, methods, types, enumerations, enumerators, labels, and non-static data members}}
+ static int SI [[maybe_unused]];
};
----------------
lebedev.ri wrote:
> As the code comment noted, http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2017/n4659.pdf, page 199:
> ```
> 2 The attribute may be applied to the declaration of a class, a typedef-name, a variable, a **non-static** data
> member, a function, an enumeration, or an enumerator.
> ```
That section says that [[maybe_unused]] can be applied to a non-static data member, which doesn't mean it can't be applied to a static data member.
And I'm arguing that since a static data member is a variable, [dcl.attr.unused]p2 actually allows [[maybe_unused]] to be applied to a static data member.
Repository:
rC Clang
https://reviews.llvm.org/D45403
More information about the cfe-commits
mailing list