OSDN Git Service

PR c++/34238
authorjakub <jakub@138bc75d-0d04-0410-961f-82ee72b054a4>
Tue, 11 Dec 2007 08:22:10 +0000 (08:22 +0000)
committerjakub <jakub@138bc75d-0d04-0410-961f-82ee72b054a4>
Tue, 11 Dec 2007 08:22:10 +0000 (08:22 +0000)
* decl2.c (cp_write_global_declarations): Revert 2007-11-22 change.

* g++.dg/ext/visibility/anon7.C: Add xfail.
* g++.dg/ext/visibility/anon9.C: New test.
* g++.dg/ext/visibility/anon10.C: New test.

git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@130771 138bc75d-0d04-0410-961f-82ee72b054a4

gcc/cp/ChangeLog
gcc/cp/decl2.c
gcc/testsuite/ChangeLog
gcc/testsuite/g++.dg/ext/visibility/anon10.C [new file with mode: 0644]
gcc/testsuite/g++.dg/ext/visibility/anon7.C
gcc/testsuite/g++.dg/ext/visibility/anon9.C [new file with mode: 0644]

index f55b06a..f8df2b2 100644 (file)
@@ -1,5 +1,8 @@
 2007-12-11  Jakub Jelinek  <jakub@redhat.com>
 
 2007-12-11  Jakub Jelinek  <jakub@redhat.com>
 
+       PR c++/34238
+       * decl2.c (cp_write_global_declarations): Revert 2007-11-22 change.
+
        PR c++/34364
        * rtti.c (build_dynamic_cast): Call convert_from_reference even for
        dynamic_cast in a template.
        PR c++/34364
        * rtti.c (build_dynamic_cast): Call convert_from_reference even for
        dynamic_cast in a template.
index 37a21f7..97b3ee0 100644 (file)
@@ -3366,21 +3366,7 @@ cp_write_global_declarations (void)
          /* If this static data member is needed, provide it to the
             back end.  */
          if (DECL_NOT_REALLY_EXTERN (decl) && decl_needed_p (decl))
          /* If this static data member is needed, provide it to the
             back end.  */
          if (DECL_NOT_REALLY_EXTERN (decl) && decl_needed_p (decl))
-           {
-             /* Error on
-                namespace { struct A { static int i; }; }
-                int foo () { return A::i; }
-                without A::i definition (which can't be defined in
-                a different CU because of the anonymous namespace).
-                Don't do this if DECL_INITIAL is set, because for
-                namespace { struct A { static const int i = 4; } };
-                decl_needed_p won't reliably detect whether it was
-                really needed.  */
-             if (DECL_IN_AGGR_P (decl) && DECL_INITIAL (decl) == NULL_TREE)
-               error ("%Jstatic data member %qD used, but not defined",
-                      decl, decl);
-             DECL_EXTERNAL (decl) = 0;
-           }
+           DECL_EXTERNAL (decl) = 0;
        }
       if (VEC_length (tree, pending_statics) != 0
          && wrapup_global_declarations (VEC_address (tree, pending_statics),
        }
       if (VEC_length (tree, pending_statics) != 0
          && wrapup_global_declarations (VEC_address (tree, pending_statics),
index 663a059..e6c5b41 100644 (file)
@@ -1,5 +1,10 @@
 2007-12-11  Jakub Jelinek  <jakub@redhat.com>
 
 2007-12-11  Jakub Jelinek  <jakub@redhat.com>
 
+       PR c++/34238
+       * g++.dg/ext/visibility/anon7.C: Add xfail.
+       * g++.dg/ext/visibility/anon9.C: New test.
+       * g++.dg/ext/visibility/anon10.C: New test.
+
        PR c++/34364
        * g++.dg/rtti/dyncast2.C: New test.
 
        PR c++/34364
        * g++.dg/rtti/dyncast2.C: New test.
 
diff --git a/gcc/testsuite/g++.dg/ext/visibility/anon10.C b/gcc/testsuite/g++.dg/ext/visibility/anon10.C
new file mode 100644 (file)
index 0000000..8c79631
--- /dev/null
@@ -0,0 +1,44 @@
+// http://bugzilla.redhat.com/411871
+// { dg-do compile }
+
+extern "C" int printf (const char *, ...);
+
+struct E
+{
+  template <typename T> E (const volatile T&);
+  template <typename T> E (T&);
+  char x[64];
+};
+
+template<typename T> struct D
+{
+  static E foo (E, ...);
+  static int foo (T, int);
+};
+
+template<typename T, typename U> struct C
+{
+  static T ca;
+  static const int value = sizeof (D<U>::foo (ca, 0)) == sizeof (int);
+};
+
+struct A
+{
+  int a;
+};
+
+namespace
+{
+  struct B
+  {
+    int a;
+  };
+}
+
+int bar (void)
+{
+  C<A, int> a;
+  C<B, int> b;
+
+  return a.value + b.value;
+}
index 23a915b..0c42ea8 100644 (file)
@@ -5,7 +5,7 @@ namespace
 {
   struct A {
     static int bar ();
 {
   struct A {
     static int bar ();
-    static int i;              // { dg-error "used, but not defined" }
+    static int i;              // { dg-error "used, but not defined" "" { xfail *-*-* } }
     static int j;
     static int k;
     static int l;
     static int j;
     static int k;
     static int l;
diff --git a/gcc/testsuite/g++.dg/ext/visibility/anon9.C b/gcc/testsuite/g++.dg/ext/visibility/anon9.C
new file mode 100644 (file)
index 0000000..bb75225
--- /dev/null
@@ -0,0 +1,11 @@
+// PR c++/34238
+// { dg-do compile }
+
+namespace
+{
+  template <typename T = int> struct A
+  {
+    static const bool a = true;
+  };
+}
+struct A<> a;