This is the mail archive of the gcc-patches@gcc.gnu.org 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]

PR c++/25492, c++/25625


This patch fixes two more C++ front-end regressions.

* 25492: We got confused during unqualified name lookup.  A type
  binding in a base class should be hidden by a type binding in a
  derived class, but we failed to clear out the base class type
  binding.

* 25625: We need to instantiate static data members with constant
  initializers, even with -frepo, because their values are required.

Tested on x86_64-unknown-linux-gnu, applied on the mainline, 4.0, and
4.1 branches.
 
--
Mark Mitchell
CodeSourcery
mark@codesourcery.com
(650) 331-3385 x713

2006-01-03  Mark Mitchell  <mark@codesourcery.com>

	PR c++/25492
	* name-lookup.c (push_class_level_binding): When a derived class
	provides a type binding, eliminate any type binding from a base
	class. 

	PR c++/25625
	* repo.c (repo_emit_p): Always instantiate static data members
	initialized by constant expressions, so that there values are
	available.

2006-01-03  Mark Mitchell  <mark@codesourcery.com>

	PR c++/25492
	* g++.dg/lookup/friend9.C: New test.

	PR c++/25625
	* g++.dg/template/repo5.C: New test.

Index: gcc/cp/repo.c
===================================================================
--- gcc/cp/repo.c	(revision 109269)
+++ gcc/cp/repo.c	(working copy)
@@ -298,6 +298,12 @@ repo_emit_p (tree decl)
 	  && (!TYPE_LANG_SPECIFIC (type)
 	      || !CLASSTYPE_TEMPLATE_INSTANTIATION (type)))
 	return 2;
+      /* Static data members initialized by constant expressions must
+	 be processed where needed so that their definitions are
+	 available.  */
+      if (DECL_INITIALIZED_BY_CONSTANT_EXPRESSION_P (decl)
+	  && DECL_CLASS_SCOPE_P (decl))
+	return 2;
     }
   else if (!DECL_TEMPLATE_INSTANTIATION (decl))
     return 2;
Index: gcc/cp/name-lookup.c
===================================================================
--- gcc/cp/name-lookup.c	(revision 109269)
+++ gcc/cp/name-lookup.c	(working copy)
@@ -2669,7 +2669,13 @@ push_class_level_binding (tree name, tre
 	      INHERITED_VALUE_BINDING_P (binding) = 0;
 	    }
 	  else
-	    old_decl = bval;
+	    {
+	      old_decl = bval;
+	      /* Any inherited type declaration is hidden by the type
+		 declaration in the derived class.  */
+	      if (TREE_CODE (x) == TYPE_DECL && DECL_ARTIFICIAL (x))
+		binding->type = NULL_TREE;
+	    }
 	}
       else if (TREE_CODE (x) == OVERLOAD && is_overloaded_fn (bval))
 	old_decl = bval;
Index: gcc/testsuite/g++.dg/lookup/friend9.C
===================================================================
--- gcc/testsuite/g++.dg/lookup/friend9.C	(revision 0)
+++ gcc/testsuite/g++.dg/lookup/friend9.C	(revision 0)
@@ -0,0 +1,23 @@
+// PR c++/25492
+
+class Base {
+public:
+  class Nested {};
+};
+
+class Derived:public Base {
+public:
+  class Nested {
+  public:
+    void m();
+  };
+  class AnotherNested {
+    friend class Nested;
+    AnotherNested() {}
+  };
+};
+
+void Derived::Nested::m() {
+  Derived::AnotherNested instance;
+
+}
Index: gcc/testsuite/g++.dg/template/repo5.C
===================================================================
--- gcc/testsuite/g++.dg/template/repo5.C	(revision 0)
+++ gcc/testsuite/g++.dg/template/repo5.C	(revision 0)
@@ -0,0 +1,11 @@
+// PR c++/25625
+// { dg-options "-frepo" } 
+
+template< typename T, T N > struct integral_c {
+  static const T value = N;
+  typedef integral_c< T, value + 1 > next;
+};
+template< typename T, T N > T const integral_c< T, N >::value;
+integral_c<int,0> a;
+
+int main () {}


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