aboutsummaryrefslogtreecommitdiff
path: root/gcc/cp
diff options
context:
space:
mode:
authorManuel López-Ibáñez <manu@gcc.gnu.org>2007-03-15 22:45:17 +0000
committerManuel López-Ibáñez <manu@gcc.gnu.org>2007-03-15 22:45:17 +0000
commit2ce88bea6d9c7d451c9f2f5eda2f91de7884da65 (patch)
tree9ad6ddd1ac48e6d49a9f4b8b3b4912f4dbe71d00 /gcc/cp
parent9b439fe168ff6dacb3aa606f43a2103b68b89ded (diff)
downloadgcc-2ce88bea6d9c7d451c9f2f5eda2f91de7884da65.zip
gcc-2ce88bea6d9c7d451c9f2f5eda2f91de7884da65.tar.gz
gcc-2ce88bea6d9c7d451c9f2f5eda2f91de7884da65.tar.bz2
re PR c++/30891 (poor diagnostic with namespace in the function scope)
2007-03-15 Manuel Lopez-Ibanez <manu@gcc.gnu.org> PR c++/30891 cp/ * parser.c (cp_parser_statement): If 'namespace' is found, this only can be a namespace alias definition, so parse it now. (cp_parser_namespace_alias_definition): if we find an open brace instead of '=', then this is actually a misplaced namespace definition. testsuite/ * g++.dg/parse/namespace-definition.C: New. From-SVN: r122962
Diffstat (limited to 'gcc/cp')
-rw-r--r--gcc/cp/ChangeLog9
-rw-r--r--gcc/cp/parser.c15
2 files changed, 24 insertions, 0 deletions
diff --git a/gcc/cp/ChangeLog b/gcc/cp/ChangeLog
index f48aa6b..730c59e 100644
--- a/gcc/cp/ChangeLog
+++ b/gcc/cp/ChangeLog
@@ -1,5 +1,14 @@
2007-03-15 Manuel Lopez-Ibanez <manu@gcc.gnu.org>
+ PR c++/30891
+ * parser.c (cp_parser_statement): If 'namespace' is found, this
+ only can be a namespace alias definition, so parse it now.
+ (cp_parser_namespace_alias_definition): if we find an open brace
+ instead of '=', then this is actually a misplaced namespace
+ definition.
+
+2007-03-15 Manuel Lopez-Ibanez <manu@gcc.gnu.org>
+
PR c++/24924
* decl.c (cxx_init_decl_processing): Move command-line options
processing to c-opts.c.
diff --git a/gcc/cp/parser.c b/gcc/cp/parser.c
index 54c7668..e123047 100644
--- a/gcc/cp/parser.c
+++ b/gcc/cp/parser.c
@@ -6373,6 +6373,11 @@ cp_parser_statement (cp_parser* parser, tree in_statement_expr,
statement = cp_parser_try_block (parser);
break;
+ case RID_NAMESPACE:
+ /* This must be a namespace alias definition. */
+ cp_parser_declaration_statement (parser);
+ return;
+
default:
/* It might be a keyword like `int' that can start a
declaration-statement. */
@@ -11040,6 +11045,16 @@ cp_parser_namespace_alias_definition (cp_parser* parser)
if (identifier == error_mark_node)
return;
/* Look for the `=' token. */
+ if (!cp_parser_uncommitted_to_tentative_parse_p (parser)
+ && cp_lexer_next_token_is (parser->lexer, CPP_OPEN_BRACE))
+ {
+ error ("%<namespace%> definition is not allowed here");
+ /* Skip the definition. */
+ cp_lexer_consume_token (parser->lexer);
+ cp_parser_skip_to_closing_brace (parser);
+ cp_lexer_consume_token (parser->lexer);
+ return;
+ }
cp_parser_require (parser, CPP_EQ, "`='");
/* Look for the qualified-namespace-specifier. */
namespace_specifier