]> git.ipfire.org Git - thirdparty/gcc.git/commitdiff
re PR c++/25492 (friend class nested in derived class problem)
authorMark Mitchell <mark@codesourcery.com>
Wed, 4 Jan 2006 01:04:51 +0000 (01:04 +0000)
committerMark Mitchell <mmitchel@gcc.gnu.org>
Wed, 4 Jan 2006 01:04:51 +0000 (01:04 +0000)
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.
PR c++/25492
* g++.dg/lookup/friend9.C: New test.
PR c++/25625
* g++.dg/template/repo5.C: New test.

From-SVN: r109307

gcc/cp/ChangeLog
gcc/cp/name-lookup.c
gcc/cp/repo.c
gcc/testsuite/ChangeLog
gcc/testsuite/g++.dg/lookup/friend9.C [new file with mode: 0644]
gcc/testsuite/g++.dg/template/repo5.C [new file with mode: 0644]

index 4c0381220dfa7f69c33f36c7770eb5b69ef844c1..9102cbc1bd3725c91dbc4582a135073bc3e6be95 100644 (file)
@@ -1,3 +1,15 @@
+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-02  Mark Mitchell  <mark@codesourcery.com>
 
        PR c++/25635
index dcd20f7e713e39bd4ae22c10f86b7ef25c549e99..ec662e6566af1aefbc6cefd2f3ac76f90e5756aa 100644 (file)
@@ -2669,7 +2669,13 @@ push_class_level_binding (tree name, tree x)
              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 d2fae3e0a17ce847879a5a5a7e173cdcac9ea5de..ad01010c363142417925cb28b5a67dbb11a4db00 100644 (file)
@@ -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 9d4355caa65c472814696850805358e968faac78..e02c3c7a5104debeed5be6b3804c4adf5fe3e394 100644 (file)
@@ -1,3 +1,11 @@
+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.
+
 2006-01-03  Steven G. Kargl  <kargls@comcast.net>
 
        PR fortran/25101
diff --git a/gcc/testsuite/g++.dg/lookup/friend9.C b/gcc/testsuite/g++.dg/lookup/friend9.C
new file mode 100644 (file)
index 0000000..caf685c
--- /dev/null
@@ -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;
+
+}
diff --git a/gcc/testsuite/g++.dg/template/repo5.C b/gcc/testsuite/g++.dg/template/repo5.C
new file mode 100644 (file)
index 0000000..5b76f43
--- /dev/null
@@ -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 () {}