aboutsummaryrefslogtreecommitdiff
path: root/gcc/cp
diff options
context:
space:
mode:
authorNathan Sidwell <nathan@acm.org>2017-06-29 18:20:13 +0000
committerNathan Sidwell <nathan@gcc.gnu.org>2017-06-29 18:20:13 +0000
commitbe3b7dcf5c0f48ce72fe7a6f30db350e5c6872f3 (patch)
tree826f90271e7bf7bbe7d17c9e5d7c85d88c8576ae /gcc/cp
parent6044f5e327761e0030f3b792fe5e5f38ff9032e2 (diff)
downloadgcc-be3b7dcf5c0f48ce72fe7a6f30db350e5c6872f3.zip
gcc-be3b7dcf5c0f48ce72fe7a6f30db350e5c6872f3.tar.gz
gcc-be3b7dcf5c0f48ce72fe7a6f30db350e5c6872f3.tar.bz2
re PR c++/81247 (ICE on invalid C++ code with malformed namespace declaration: in do_push_nested_namespace, at cp/name-lookup.c:6002)
PR c++/81247 * parser.c (cp_parser_namespace_definition): Immediately close the namespace if there's no open-brace. * name-lookup.c (do_pushdecl): Reset OLD when pushing into new namespace. From-SVN: r249804
Diffstat (limited to 'gcc/cp')
-rw-r--r--gcc/cp/ChangeLog8
-rw-r--r--gcc/cp/name-lookup.c3
-rw-r--r--gcc/cp/parser.c13
3 files changed, 18 insertions, 6 deletions
diff --git a/gcc/cp/ChangeLog b/gcc/cp/ChangeLog
index 2c29f1e..17da1c5 100644
--- a/gcc/cp/ChangeLog
+++ b/gcc/cp/ChangeLog
@@ -1,3 +1,11 @@
+2017-06-29 Nathan Sidwell <nathan@acm.org>
+
+ PR c++/81247
+ * parser.c (cp_parser_namespace_definition): Immediately close the
+ namespace if there's no open-brace.
+ * name-lookup.c (do_pushdecl): Reset OLD when pushing into new
+ namespace.
+
2017-06-29 Jason Merrill <jason@redhat.com>
PR c++/81164 - ICE with invalid inherited constructor.
diff --git a/gcc/cp/name-lookup.c b/gcc/cp/name-lookup.c
index f15c811..4beab85 100644
--- a/gcc/cp/name-lookup.c
+++ b/gcc/cp/name-lookup.c
@@ -2422,6 +2422,9 @@ do_pushdecl (tree decl, bool is_friend)
{
ns = current_namespace;
slot = find_namespace_slot (ns, name, true);
+ /* Update OLD to reflect the namespace we're going to be
+ pushing into. */
+ old = MAYBE_STAT_DECL (*slot);
}
old = update_binding (level, binding, slot, old, decl, is_friend);
diff --git a/gcc/cp/parser.c b/gcc/cp/parser.c
index 31840d6..375cd0a 100644
--- a/gcc/cp/parser.c
+++ b/gcc/cp/parser.c
@@ -18397,13 +18397,14 @@ cp_parser_namespace_definition (cp_parser* parser)
warning (OPT_Wnamespaces, "namespace %qD entered", current_namespace);
/* Look for the `{' to validate starting the namespace. */
- cp_parser_require (parser, CPP_OPEN_BRACE, RT_OPEN_BRACE);
-
- /* Parse the body of the namespace. */
- cp_parser_namespace_body (parser);
+ if (cp_parser_require (parser, CPP_OPEN_BRACE, RT_OPEN_BRACE))
+ {
+ /* Parse the body of the namespace. */
+ cp_parser_namespace_body (parser);
- /* Look for the final `}'. */
- cp_parser_require (parser, CPP_CLOSE_BRACE, RT_CLOSE_BRACE);
+ /* Look for the final `}'. */
+ cp_parser_require (parser, CPP_CLOSE_BRACE, RT_CLOSE_BRACE);
+ }
if (has_visibility)
pop_visibility (1);