diff options
author | Jason Merrill <jason@redhat.com> | 2024-08-30 16:02:10 -0400 |
---|---|---|
committer | Jason Merrill <jason@redhat.com> | 2024-09-03 17:59:18 -0400 |
commit | 3775f71c8909b3531fe002138814fa2504ec2e8b (patch) | |
tree | 41129409f0a838cd0f8774d6f28cb5d3cd320834 /gcc/cp/parser.cc | |
parent | 1fad396dd467326251572811b703e788e62a2588 (diff) | |
download | gcc-3775f71c8909b3531fe002138814fa2504ec2e8b.zip gcc-3775f71c8909b3531fe002138814fa2504ec2e8b.tar.gz gcc-3775f71c8909b3531fe002138814fa2504ec2e8b.tar.bz2 |
c++: support C++11 attributes in C++98
I don't see any reason why we can't allow the [[]] attribute syntax in C++98
mode with a pedwarn just like many other C++11 features. In fact, we
already do support it in some places in the grammar, but not in places that
check cp_nth_tokens_can_be_std_attribute_p.
Let's also follow the C front-end's lead in only warning about them when
-pedantic.
It still isn't necessary for this function to guard against Objective-C
message passing syntax; we handle that with tentative parsing in
cp_parser_statement, and we don't call this function in that context anyway.
gcc/cp/ChangeLog:
* parser.cc (cp_nth_tokens_can_be_std_attribute_p): Don't check
cxx_dialect.
* error.cc (maybe_warn_cpp0x): Only complain about C++11 attributes
if pedantic.
gcc/testsuite/ChangeLog:
* g++.dg/cpp0x/gen-attrs-1.C: Also run in C++98 mode.
* g++.dg/cpp0x/gen-attrs-11.C: Likewise.
* g++.dg/cpp0x/gen-attrs-13.C: Likewise.
* g++.dg/cpp0x/gen-attrs-15.C: Likewise.
* g++.dg/cpp0x/gen-attrs-75.C: Don't expect C++98 warning after
__extension__.
Diffstat (limited to 'gcc/cp/parser.cc')
-rw-r--r-- | gcc/cp/parser.cc | 9 |
1 files changed, 4 insertions, 5 deletions
diff --git a/gcc/cp/parser.cc b/gcc/cp/parser.cc index edfa5a4..64122d9 100644 --- a/gcc/cp/parser.cc +++ b/gcc/cp/parser.cc @@ -29924,11 +29924,10 @@ cp_nth_tokens_can_be_std_attribute_p (cp_parser *parser, size_t n) { cp_token *token = cp_lexer_peek_nth_token (parser->lexer, n); - return (cxx_dialect >= cxx11 - && ((token->type == CPP_KEYWORD && token->keyword == RID_ALIGNAS) - || (token->type == CPP_OPEN_SQUARE - && (token = cp_lexer_peek_nth_token (parser->lexer, n + 1)) - && token->type == CPP_OPEN_SQUARE))); + return ((token->type == CPP_KEYWORD && token->keyword == RID_ALIGNAS) + || (token->type == CPP_OPEN_SQUARE + && (token = cp_lexer_peek_nth_token (parser->lexer, n + 1)) + && token->type == CPP_OPEN_SQUARE)); } /* Return TRUE iff the next Nth tokens in the stream are possibly the |