This is the mail archive of the
gcc-patches@gcc.gnu.org
mailing list for the GCC project.
Re: [C++ patch] report better diagnostic for static following '[' in parameter declaration
- From: Marek Polacek <polacek at redhat dot com>
- To: Prathamesh Kulkarni <prathamesh dot kulkarni at linaro dot org>
- Cc: gcc Patches <gcc-patches at gcc dot gnu dot org>
- Date: Fri, 29 Jan 2016 00:33:08 +0100
- Subject: Re: [C++ patch] report better diagnostic for static following '[' in parameter declaration
- Authentication-results: sourceware.org; auth=none
- References: <CAAgBjMndUJru9TjbUm_DQzGvdJkH1Zhq-pq2-RnWJn=Kz+gVVw at mail dot gmail dot com>
On Fri, Jan 29, 2016 at 04:46:56AM +0530, Prathamesh Kulkarni wrote:
> @@ -19016,10 +19017,22 @@ cp_parser_direct_declarator (cp_parser* parser,
> cp_lexer_consume_token (parser->lexer);
> /* Peek at the next token. */
> token = cp_lexer_peek_token (parser->lexer);
> +
> + /* If static keyword immediately follows [, report error. */
> + if (cp_lexer_next_token_is_keyword (parser->lexer, RID_STATIC)
> + && current_binding_level->kind == sk_function_parms)
> + {
> + error_at (token->location,
> + "static array size is a C99 feature,"
> + "not permitted in C++");
> + bounds = error_mark_node;
> + }
> +
I think this isn't sufficient as-is; if we're changing the diagnostics here,
we should also handle e.g. void f(int a[const 10]); where clang++ says
g.C:1:13: error: qualifier in array size is a C99 feature, not permitted in C++
And also e.g.
void f(int a[const static 10]);
void f(int a[static const 10]);
and similar.
Marek