This is the mail archive of the
gcc-patches@gcc.gnu.org
mailing list for the GCC project.
C++ PATCH for c++/43069 (ice-on-invalid with explicit namespace qualification)
- From: Jason Merrill <jason at redhat dot com>
- To: gcc-patches List <gcc-patches at gcc dot gnu dot org>
- Date: Wed, 17 Feb 2010 17:40:13 -0500
- Subject: C++ PATCH for c++/43069 (ice-on-invalid with explicit namespace qualification)
set_decl_namespace was assuming that the old declaration was something
like the new one, which may not be the case for invalid code.
Tested x86_64-pc-linux-gnu, applied to trunk.
commit aeb7d445a7624e5987d331dc41250b1321119546
Author: Jason Merrill <jason@redhat.com>
Date: Wed Feb 17 15:53:45 2010 -0500
PR c++/43069
* name-lookup.c (set_decl_namespace): Don't copy DECL_CONTEXT if the
decl we looked up doesn't match.
diff --git a/gcc/cp/name-lookup.c b/gcc/cp/name-lookup.c
index 1f595c0..7b43d30 100644
--- a/gcc/cp/name-lookup.c
+++ b/gcc/cp/name-lookup.c
@@ -3102,7 +3102,8 @@ set_decl_namespace (tree decl, tree scope, bool friendp)
if (!is_overloaded_fn (decl))
{
/* We might have found OLD in an inline namespace inside SCOPE. */
- DECL_CONTEXT (decl) = DECL_CONTEXT (old);
+ if (TREE_CODE (decl) == TREE_CODE (old))
+ DECL_CONTEXT (decl) = DECL_CONTEXT (old);
/* Don't compare non-function decls with decls_match here, since
it can't check for the correct constness at this
point. pushdecl will find those errors later. */
diff --git a/gcc/testsuite/g++.dg/parse/namespace11.C b/gcc/testsuite/g++.dg/parse/namespace11.C
new file mode 100644
index 0000000..7fa73b6
--- /dev/null
+++ b/gcc/testsuite/g++.dg/parse/namespace11.C
@@ -0,0 +1,7 @@
+// PR c++/43069
+
+namespace std {
+ template < typename >
+ void swap ();
+}
+template std::swap // { dg-error "" }