All of lore.kernel.org
 help / color / mirror / Atom feed
From: Luc Van Oostenryck <luc.vanoostenryck@gmail.com>
To: Lance Richardson <lrichard@redhat.com>
Cc: Linux-Sparse <linux-sparse@vger.kernel.org>
Subject: Re: [PATCH v4] sparse: add support for _Static_assert
Date: Thu, 4 May 2017 04:29:27 +0200	[thread overview]
Message-ID: <CAMHZB6Gjf5gX92yiGshRgCpCLM=xuxBkXyDQ=RQA=gx6bG3PpQ@mail.gmail.com> (raw)
In-Reply-To: <20170503235403.6i5za2wa526fmp6w@desk.local>

On Thu, May 4, 2017 at 1:54 AM, Luc Van Oostenryck
<luc.vanoostenryck@gmail.com> wrote:
> On Wed, May 03, 2017 at 12:55:18PM -0400, Lance Richardson wrote:
>> This patch introduces support for the C11 _Static_assert() construct.
>
> Great!
>
>> diff --git a/parse.c b/parse.c
> ...
>> index b52c6ab..f1b96cc 100644
>> --- a/parse.c
>> +++ b/parse.c
>> @@ -1864,13 +1872,21 @@ static struct token *declaration_list(struct token *token, struct symbol_list **
>>  static struct token *struct_declaration_list(struct token *token, struct symbol_list **list)
>>  {
>>       while (!match_op(token, '}')) {
>> -             if (!match_op(token, ';'))
>> -                     token = declaration_list(token, list);
>> -             if (!match_op(token, ';')) {
>> -                     sparse_error(token->pos, "expected ; at end of declaration");
>> -                     break;
>> +             struct symbol *keyword = NULL;
>> +
>> +             if (token_type(token) == TOKEN_IDENT)
>> +                     keyword = lookup_keyword(token->ident, NS_KEYWORD);
>> +             if (keyword && keyword->op == &static_assert_op)
>
> Is it possible to move this test in a helper? Something like
>         static int match_static_assert(struct token *token)
>         {
>                 struct symbol *keyword;
>                 if (token_type(token) != TOKEN_IDENT)
>                         return 0;
>                 keyword = lookup_keyword(token->ident, NS_KEYWORD);
>                 return keyword && keyword->op == &static_assert_op;
>         }
>
>> @@ -2389,6 +2436,10 @@ static struct token * statement_list(struct token *token, struct statement_list
>>                       }
>>                       stmt = alloc_statement(token->pos, STMT_DECLARATION);
>>                       token = external_declaration(token, &stmt->declaration);
>> +             } else if (token_type(token) == TOKEN_IDENT &&
>> +                        (keyword = lookup_keyword(token->ident, NS_KEYWORD)) &&
>> +                        keyword->op == &static_assert_op) {
>> +                     token = parse_static_assert(token, NULL);

There is another problem here. With a few more line of context, we have:
>> @@ -2389,6 +2436,10 @@ static struct token * statement_list(struct token *token, struct statement_list
>>                       }
>>                       stmt = alloc_statement(token->pos, STMT_DECLARATION);
>>                       token = external_declaration(token, &stmt->declaration);
>> +             } else if (token_type(token) == TOKEN_IDENT &&
>> +                        (keyword = lookup_keyword(token->ident, NS_KEYWORD)) &&
>> +                        keyword->op == &static_assert_op) {
>> +                     token = parse_static_assert(token, NULL);
>>                }
>>                add_statement(list, stmt);

but when the static assert matches 'stmt' is not initialized and still added
to the statement list (with sporadic crashes).

-- Luc

  reply	other threads:[~2017-05-04  2:29 UTC|newest]

Thread overview: 9+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2017-05-03 16:55 [PATCH v4] sparse: add support for _Static_assert Lance Richardson
2017-05-03 23:54 ` Luc Van Oostenryck
2017-05-04  2:29   ` Luc Van Oostenryck [this message]
2017-05-04 13:53     ` Lance Richardson
2017-05-04 14:58       ` Luc Van Oostenryck
2017-05-04 15:46         ` Lance Richardson
2017-05-04 16:29           ` Luc Van Oostenryck
2017-05-04  3:03 ` Christopher Li
2017-05-04 13:56   ` Lance Richardson

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to='CAMHZB6Gjf5gX92yiGshRgCpCLM=xuxBkXyDQ=RQA=gx6bG3PpQ@mail.gmail.com' \
    --to=luc.vanoostenryck@gmail.com \
    --cc=linux-sparse@vger.kernel.org \
    --cc=lrichard@redhat.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.