aboutsummaryrefslogtreecommitdiff
path: root/gcc
diff options
context:
space:
mode:
Diffstat (limited to 'gcc')
-rw-r--r--gcc/cp/ChangeLog13
-rw-r--r--gcc/cp/parser.c42
-rw-r--r--gcc/testsuite/ChangeLog4
-rw-r--r--gcc/testsuite/g++.dg/cpp0x/auto1.C8
4 files changed, 65 insertions, 2 deletions
diff --git a/gcc/cp/ChangeLog b/gcc/cp/ChangeLog
index 6fa1204..6f61262 100644
--- a/gcc/cp/ChangeLog
+++ b/gcc/cp/ChangeLog
@@ -1,3 +1,16 @@
+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.
diff --git a/gcc/cp/parser.c b/gcc/cp/parser.c
index 5f7ddcf..817a062 100644
--- a/gcc/cp/parser.c
+++ b/gcc/cp/parser.c
@@ -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,13 +8136,33 @@ 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:
case RID_MUTABLE:
/* Consume the token. */
cp_lexer_consume_token (parser->lexer);
- cp_parser_set_storage_class (parser, decl_specs, token->keyword);
+ cp_parser_set_storage_class (parser, decl_specs, token->keyword);
break;
case RID_THREAD:
/* Consume the token. */
@@ -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:
@@ -10775,6 +10802,17 @@ cp_parser_simple_type_specifier (cp_parser* parser,
case RID_VOID:
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. */
diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog
index 01a4e6f..05b49db 100644
--- a/gcc/testsuite/ChangeLog
+++ b/gcc/testsuite/ChangeLog
@@ -1,3 +1,7 @@
+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
diff --git a/gcc/testsuite/g++.dg/cpp0x/auto1.C b/gcc/testsuite/g++.dg/cpp0x/auto1.C
new file mode 100644
index 0000000..9e274b6
--- /dev/null
+++ b/gcc/testsuite/g++.dg/cpp0x/auto1.C
@@ -0,0 +1,8 @@
+// { 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" }
+}