re PR c++/78637 (ICE on invalid C++ code on x86_64-linux-gnu (internal compiler error...
authorPaolo Carlini <paolo.carlini@oracle.com>
Sun, 11 Dec 2016 18:15:31 +0000 (18:15 +0000)
committerPaolo Carlini <paolo@gcc.gnu.org>
Sun, 11 Dec 2016 18:15:31 +0000 (18:15 +0000)
/cp
2016-12-11  Paolo Carlini  <paolo.carlini@oracle.com>

PR c++/78637
* parser.c (cp_parser_namespace_definition): Increment
nested_definition_count only if push_namespace succeeds.

/testsuite
2016-12-11  Paolo Carlini  <paolo.carlini@oracle.com>

PR c++/78637
* g++.dg/parse/namespace14.C: New.

From-SVN: r243529

gcc/cp/ChangeLog
gcc/cp/parser.c
gcc/testsuite/ChangeLog
gcc/testsuite/g++.dg/parse/namespace14.C [new file with mode: 0644]

index 4b203b2a79408df4703434b6bc707f5fb3bd96d4..56803bf77484bbdffe5a76a4e9bc0ff4d75d9073 100644 (file)
@@ -1,3 +1,9 @@
+2016-12-11  Paolo Carlini  <paolo.carlini@oracle.com>
+
+       PR c++/78637
+       * parser.c (cp_parser_namespace_definition): Increment
+       nested_definition_count only if push_namespace succeeds.
+
 2016-12-08  Nathan Sidwell  <nathan@acm.org>
 
        PR c++/78551
index 70e5fb33f7c93b9fa2a5319c2dc8fb7ed95676e6..8ed75c70daa6c5af263d844ffdb12ad211f57d2d 100644 (file)
@@ -18184,8 +18184,8 @@ cp_parser_namespace_definition (cp_parser* parser)
               cp_parser_error (parser, "nested identifier required");
               break;
             }
-          ++nested_definition_count;
-          push_namespace (identifier);
+         if (push_namespace (identifier))
+           ++nested_definition_count;
         }
     }
 
index 9bd73899c97907d5666e66167f6fdcacd0717324..8603a02aa8beb8ae0f58a20cf106a0879c882553 100644 (file)
@@ -1,3 +1,8 @@
+2016-12-11  Paolo Carlini  <paolo.carlini@oracle.com>
+
+       PR c++/78637
+       * g++.dg/parse/namespace14.C: New.
+
 2016-12-10  Jakub Jelinek  <jakub@redhat.com>
 
        PR tree-optimization/78720
diff --git a/gcc/testsuite/g++.dg/parse/namespace14.C b/gcc/testsuite/g++.dg/parse/namespace14.C
new file mode 100644 (file)
index 0000000..a6fa69b
--- /dev/null
@@ -0,0 +1,6 @@
+// PR c++/78637
+
+namespace X {
+class Y;
+}
+namespace X::Y z;  // { dg-error "namespace|expected|type" }