Commit 4dbc8575 by Douglas Gregor Committed by Doug Gregor

parser.c (cp_lexer_next_token_is_decl_specifier_keyword): Note that auto is…

parser.c (cp_lexer_next_token_is_decl_specifier_keyword): Note that auto is either a storage class or a simple type specifier...

2008-03-01  Douglas Gregor  <doug.gregor@gmail.com>

	* parser.c (cp_lexer_next_token_is_decl_specifier_keyword): Note
	that auto is either a storage class or a simple type specifier,
	depending on the dialect.
	(cp_parser_decl_specifier_seq): Complain about `auto' as a storage
	specifier in C++98 mode, error in C++0x mode (since we don't
	support auto as a type specifier, yet).
	(cp_parser_storage_class_specifier_opt): Don't treat `auto' as a
	storage specifier in C++0x mode.
	(cp_parser_simple_type_specifier): Parse `auto' as a
	simple-type-specifier, but error because we don't support it yet.

2008-03-01  Douglas Gregor  <doug.gregor@gmail.com>

	* g++.dg/cpp0x/auto1.C: New.

From-SVN: r132806
parent fafcb222
2008-03-01 Douglas Gregor <doug.gregor@gmail.com>
* parser.c (cp_lexer_next_token_is_decl_specifier_keyword): Note
that auto is either a storage class or a simple type specifier,
depending on the dialect.
(cp_parser_decl_specifier_seq): Complain about `auto' as a storage
specifier in C++98 mode, error in C++0x mode (since we don't
support auto as a type specifier, yet).
(cp_parser_storage_class_specifier_opt): Don't treat `auto' as a
storage specifier in C++0x mode.
(cp_parser_simple_type_specifier): Parse `auto' as a
simple-type-specifier, but error because we don't support it yet.
2008-02-29 Manuel Lopez-Ibanez <manu@gcc.gnu.org>
* parser.c (cp_parser_nonclass_name): New.
......
......@@ -539,8 +539,10 @@ cp_lexer_next_token_is_decl_specifier_keyword (cp_lexer *lexer)
token = cp_lexer_peek_token (lexer);
switch (token->keyword)
{
/* Storage classes. */
/* auto specifier: storage-class-specifier in C++,
simple-type-specifier in C++0x. */
case RID_AUTO:
/* Storage classes. */
case RID_REGISTER:
case RID_STATIC:
case RID_EXTERN:
......@@ -8134,6 +8136,26 @@ cp_parser_decl_specifier_seq (cp_parser* parser,
GNU Extension:
thread */
case RID_AUTO:
/* Consume the token. */
cp_lexer_consume_token (parser->lexer);
if (cxx_dialect == cxx98)
{
/* Complain about `auto' as a storage specifier, if
we're complaining about C++0x compatibility. */
warning
(OPT_Wc__0x_compat,
"%<auto%> will change meaning in C++0x; please remove it");
/* Set the storage class anyway. */
cp_parser_set_storage_class (parser, decl_specs, RID_AUTO);
}
else
/* We do not yet support the use of `auto' as a
type-specifier. */
error ("C++0x %<auto%> specifier not supported");
break;
case RID_REGISTER:
case RID_STATIC:
case RID_EXTERN:
......@@ -8266,6 +8288,10 @@ cp_parser_storage_class_specifier_opt (cp_parser* parser)
switch (cp_lexer_peek_token (parser->lexer)->keyword)
{
case RID_AUTO:
if (cxx_dialect != cxx98)
return NULL_TREE;
/* Fall through for C++98. */
case RID_REGISTER:
case RID_STATIC:
case RID_EXTERN:
......@@ -10705,6 +10731,7 @@ cp_parser_type_specifier (cp_parser* parser,
C++0x Extension:
simple-type-specifier:
auto
decltype ( expression )
GNU Extension:
......@@ -10776,6 +10803,17 @@ cp_parser_simple_type_specifier (cp_parser* parser,
type = void_type_node;
break;
case RID_AUTO:
if (cxx_dialect != cxx98)
{
/* Consume the token. */
cp_lexer_consume_token (parser->lexer);
/* We do not yet support the use of `auto' as a
type-specifier. */
error ("C++0x %<auto%> specifier not supported");
}
break;
case RID_DECLTYPE:
/* Parse the `decltype' type. */
type = cp_parser_decltype (parser);
......
2008-03-01 Douglas Gregor <doug.gregor@gmail.com>
* g++.dg/cpp0x/auto1.C: New.
2008-03-01 Francois-Xavier Coudert <fxcoudert@gcc.gnu.org>
PR fortran/34770
// { dg-options "-std=c++98 -Wc++0x-compat" }
// Test warning for use of auto in C++98 mode with C++0x
// compatibility warnings
void f()
{
auto int x = 5; // { dg-warning "will change meaning" }
}
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment