aboutsummaryrefslogtreecommitdiff
path: root/gcc/builtins.c
diff options
context:
space:
mode:
authorJoseph Myers <joseph@codesourcery.com>2019-11-20 00:13:51 +0000
committerJoseph Myers <jsm28@gcc.gnu.org>2019-11-20 00:13:51 +0000
commit8c5b727acc19d3ee415e0d0e5ba84af7d1843dab (patch)
treebe38735de6e9b5ab9675dee975c68972c0dea825 /gcc/builtins.c
parent0c6ce0ae553a9a73bf4eb27d16ee751167806f8d (diff)
downloadgcc-8c5b727acc19d3ee415e0d0e5ba84af7d1843dab.zip
gcc-8c5b727acc19d3ee415e0d0e5ba84af7d1843dab.tar.gz
gcc-8c5b727acc19d3ee415e0d0e5ba84af7d1843dab.tar.bz2
Add more pedwarns for [[]] C attributes on types.
The standard [[]] attributes currently defined in C2x are all not valid on types not being defined at the time. Use on such types results in a warning from attribs.c about attributes appertaining to types (the warning that I think is bogus in general for both C and C++, applying as it does to all [[]] attributes including gnu:: ones that are perfectly meaningful on types not being defined and work fine when __attribute__ syntax is used instead). If that warning is removed (as I intend to do in a subsequent patch), warnings may or may not result from the attribute handlers, depending on whether those particular attribute handlers consider the attributes meaningful in such a context. In C, however, the rules about where each [[]] attribute is valid are constraints, so a pedwarn, not a warning, is required. Because some handlers are shared between standard and gnu:: attributes, there can be cases that are valid for the GNU attribute variant but not for the standard one. So in general it is not correct to rely on the attribute handlers to give all required pedwarns (although in some cases, a pedwarn in the attribute handler is in appropriate way of diagnosing an invalid use); they not have the information about whether the attribute was a gnu:: one and can legitimately accept a wider range of uses for the gnu:: attributes. This patch ensures appropriate diagnostics for invalid uses of C2x standard attributes on types, and so helps pave the way for the subsequent removal of the bogus check in attribs.c, by adding a check run in the front end before calling decl_attributes; this check removes the attributes from the list after calling pedwarn to avoid subsequent duplicate warnings. Bootstrapped with no regressions for x86_64-pc-linux-gnu. gcc/c: * c-decl.c (c_warn_type_attributes): New function. (groktypename, grokdeclarator, finish_declspecs): Call c_warn_type_attributes before applying attributes to types. * c-tree.h (c_warn_type_attributes): Declare. gcc/testsuite: * gcc.dg/c2x-attr-deprecated-2.c, gcc.dg/c2x-attr-fallthrough-2.c, gcc.dg/c2x-attr-maybe_unused-2.c: Expect errors for invalid uses of standard attributes on types. Add more tests of invalid uses on types. From-SVN: r278471
Diffstat (limited to 'gcc/builtins.c')
0 files changed, 0 insertions, 0 deletions