This is the mail archive of the gcc-patches@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: [C++ PATCH] Fix attribute parsing for bitfields


On 09/28/2017 11:47 AM, Jakub Jelinek wrote:

I don't see the first half of 1) related to second half thereof, the
DECL_BIT_FIELD_REPRESENTATIVE is unrelated to the parsing bug, and a needed
precondition of 2).

That's very conscientious of you.


As I said on IRC, I hope [[/__attribute__/alignas early is rare enough that
the tentative parsing shouldn't be a big deal, if it is, we could add some
cheaper function that allows us to skip over attributes (return a peek
offset after the attributes given a starting peek offset).
I agree.

--- gcc/cp/parser.c.jj	2017-09-22 20:51:48.181537880 +0200
+++ gcc/cp/parser.c	2017-09-27 17:50:15.082792676 +0200
@@ -23443,35 +23443,64 @@ cp_parser_member_declaration (cp_parser*

  	  /* Peek at the next token.  */
  	  token = cp_lexer_peek_token (parser->lexer);
+ if (cp_next_tokens_can_be_attribute_p (parser)
+	      || (token->type == CPP_NAME
+		  && cp_nth_tokens_can_be_attribute_p (parser, 2)
+		  && (named_bitfld = true)))
+	    {

Please insert a comment describing why we're doing the lookahead and our supposition that it is rare, so the simplicity of a tentative parse is worth the expense. Also, as I mentioned before, the other alternative is to let the non-bitfield declarator parsing get an unnamed decl and then look for the ':'. But that's a more complicated change we decided not to do.

the mid-condition assignment is ugly, but probably the least ugly.

ok for trunk.

nathan
--
Nathan Sidwell


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]