This is the mail archive of the
gcc-bugs@gcc.gnu.org
mailing list for the GCC project.
[Bug c++/79301] With -Werror=pedantic outside C++17 mode, __has_cpp_attribute(fallthrough) is nonzero but [[fallthrough]] fails
- From: "jakub at gcc dot gnu.org" <gcc-bugzilla at gcc dot gnu dot org>
- To: gcc-bugs at gcc dot gnu dot org
- Date: Fri, 10 Feb 2017 16:22:56 +0000
- Subject: [Bug c++/79301] With -Werror=pedantic outside C++17 mode, __has_cpp_attribute(fallthrough) is nonzero but [[fallthrough]] fails
- Auto-submitted: auto-generated
- References: <bug-79301-4@http.gcc.gnu.org/bugzilla/>
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=79301
--- Comment #8 from Jakub Jelinek <jakub at gcc dot gnu.org> ---
(In reply to Jason Merrill from comment #7)
> (In reply to Jakub Jelinek from comment #4)
> > That said, I think e.g. for maybe_unused or nodiscard attributes we don't
> > complain with -pedantic about those attributes used in C++14 code, so either
> > we should do that as well, or we shouldn't do that for fallthrough either.
> > Jason?
>
> We certainly don't want to both have __has_cpp_attribute(fallthrough)
> non-zero and also complain about its usage. My inclination would be to
> remove the diagnostic.
Also for deprecated attribute and C++11?
else if (is_attribute_p ("deprecated", attr_id))
{
if (cxx_dialect == cxx11)
pedwarn (token->location, OPT_Wpedantic,
"%<deprecated%> is a C++14 feature;"
" use %<gnu::deprecated%>");
TREE_PURPOSE (TREE_PURPOSE (attribute)) = get_identifier ("gnu");
}
/* C++17 fallthrough attribute is equivalent to GNU's. */
else if (is_attribute_p ("fallthrough", attr_id))
{
if (cxx_dialect < cxx1z)
pedwarn (token->location, OPT_Wpedantic,
"%<fallthrough%> is a C++17 feature;"
" use %<gnu::fallthrough%>");
TREE_PURPOSE (TREE_PURPOSE (attribute)) = get_identifier ("gnu");
}
Even for that one can test #if __has_cpp_attribute(deprecated) and
[[deprecated]] still won't work if -std=c++11 -pedantic-errors.