This is the mail archive of the mailing list for the GCC project.

Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

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 <>
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))
       /* 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 "" }

Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]