aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorPaolo Carlini <paolo.carlini@oracle.com>2016-05-27 19:19:23 +0000
committerPaolo Carlini <paolo@gcc.gnu.org>2016-05-27 19:19:23 +0000
commit8008c4d2bec3e5f54c149e08b62380f62641a965 (patch)
tree7477cadbff321ea450085460b0be3337e0e5b309
parent9a01befbca8a8d3ad2576e9774ba2f93efd71663 (diff)
downloadgcc-8008c4d2bec3e5f54c149e08b62380f62641a965.zip
gcc-8008c4d2bec3e5f54c149e08b62380f62641a965.tar.gz
gcc-8008c4d2bec3e5f54c149e08b62380f62641a965.tar.bz2
re PR c++/60385 (confused by earlier errors, bailing out)
/cp 2016-05-27 Paolo Carlini <paolo.carlini@oracle.com> PR c++/60385 * name-lookup.c (push_namespace): Return bool, false when pushdecl fails. * name-lookup.h (push_namespace): Adjust declaration. * parser.c (cp_parser_namespace_definition): Check push_namespace return value. /testsuite 2016-05-27 Paolo Carlini <paolo.carlini@oracle.com> PR c++/60385 * g++.dg/parse/namespace13.C: New. From-SVN: r236835
-rw-r--r--gcc/cp/ChangeLog9
-rw-r--r--gcc/cp/name-lookup.c12
-rw-r--r--gcc/cp/name-lookup.h2
-rw-r--r--gcc/cp/parser.c7
-rw-r--r--gcc/testsuite/ChangeLog5
-rw-r--r--gcc/testsuite/g++.dg/parse/namespace13.C11
6 files changed, 39 insertions, 7 deletions
diff --git a/gcc/cp/ChangeLog b/gcc/cp/ChangeLog
index 6c07df1..cdc2f5a 100644
--- a/gcc/cp/ChangeLog
+++ b/gcc/cp/ChangeLog
@@ -1,3 +1,12 @@
+2016-05-27 Paolo Carlini <paolo.carlini@oracle.com>
+
+ PR c++/60385
+ * name-lookup.c (push_namespace): Return bool, false when pushdecl
+ fails.
+ * name-lookup.h (push_namespace): Adjust declaration.
+ * parser.c (cp_parser_namespace_definition): Check push_namespace
+ return value.
+
2016-05-27 Ville Voutilainen <ville.voutilainen@gmail.com>
PR c++/69855
diff --git a/gcc/cp/name-lookup.c b/gcc/cp/name-lookup.c
index 568c75e..1173370 100644
--- a/gcc/cp/name-lookup.c
+++ b/gcc/cp/name-lookup.c
@@ -3701,9 +3701,10 @@ handle_namespace_attrs (tree ns, tree attributes)
}
/* Push into the scope of the NAME namespace. If NAME is NULL_TREE, then we
- select a name that is unique to this compilation unit. */
+ select a name that is unique to this compilation unit. Returns FALSE if
+ pushdecl fails, TRUE otherwise. */
-void
+bool
push_namespace (tree name)
{
tree d = NULL_TREE;
@@ -3777,7 +3778,11 @@ push_namespace (tree name)
TREE_PUBLIC (d) = 0;
else
TREE_PUBLIC (d) = 1;
- pushdecl (d);
+ if (pushdecl (d) == error_mark_node)
+ {
+ timevar_cond_stop (TV_NAME_LOOKUP, subtime);
+ return false;
+ }
if (anon)
{
/* Clear DECL_NAME for the benefit of debugging back ends. */
@@ -3795,6 +3800,7 @@ push_namespace (tree name)
current_namespace = d;
timevar_cond_stop (TV_NAME_LOOKUP, subtime);
+ return true;
}
/* Pop from the scope of the current namespace. */
diff --git a/gcc/cp/name-lookup.h b/gcc/cp/name-lookup.h
index 2f8447a..2cb129c 100644
--- a/gcc/cp/name-lookup.h
+++ b/gcc/cp/name-lookup.h
@@ -312,7 +312,7 @@ extern tree push_inner_scope (tree);
extern void pop_inner_scope (tree, tree);
extern void push_binding_level (cp_binding_level *);
-extern void push_namespace (tree);
+extern bool push_namespace (tree);
extern void pop_namespace (void);
extern void push_nested_namespace (tree);
extern void pop_nested_namespace (tree);
diff --git a/gcc/cp/parser.c b/gcc/cp/parser.c
index 546aada..2a46d6f 100644
--- a/gcc/cp/parser.c
+++ b/gcc/cp/parser.c
@@ -17549,7 +17549,7 @@ cp_parser_namespace_definition (cp_parser* parser)
}
/* Start the namespace. */
- push_namespace (identifier);
+ bool ok = push_namespace (identifier);
/* Parse any nested namespace definition. */
if (cp_lexer_next_token_is (parser->lexer, CPP_SCOPE))
@@ -17582,7 +17582,7 @@ cp_parser_namespace_definition (cp_parser* parser)
/* "inline namespace" is equivalent to a stub namespace definition
followed by a strong using directive. */
- if (is_inline)
+ if (is_inline && ok)
{
tree name_space = current_namespace;
/* Set up namespace association. */
@@ -17610,7 +17610,8 @@ cp_parser_namespace_definition (cp_parser* parser)
pop_namespace ();
/* Finish the namespace. */
- pop_namespace ();
+ if (ok)
+ pop_namespace ();
/* Look for the final `}'. */
cp_parser_require (parser, CPP_CLOSE_BRACE, RT_CLOSE_BRACE);
}
diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog
index 5ded2d4..6920681 100644
--- a/gcc/testsuite/ChangeLog
+++ b/gcc/testsuite/ChangeLog
@@ -1,3 +1,8 @@
+2016-05-27 Paolo Carlini <paolo.carlini@oracle.com>
+
+ PR c++/60385
+ * g++.dg/parse/namespace13.C: New.
+
2016-05-26 Jeff Law <law@redhat.com>
* gcc.dg/tree-ssa/pr21417.c: Update expected output.
diff --git a/gcc/testsuite/g++.dg/parse/namespace13.C b/gcc/testsuite/g++.dg/parse/namespace13.C
new file mode 100644
index 0000000..5a05384
--- /dev/null
+++ b/gcc/testsuite/g++.dg/parse/namespace13.C
@@ -0,0 +1,11 @@
+// PR c++/60385
+
+float foo4(); // { dg-message "previous declaration" }
+
+namespace foo4 // { dg-error "redeclared" }
+{
+ struct bar6
+ {
+ friend wchar_t bar1();
+ };
+}