OSDN Git Service

2005-08-31 Andrew Pinski <pinskia@physics.uc.edu>
authorpinskia <pinskia@138bc75d-0d04-0410-961f-82ee72b054a4>
Wed, 31 Aug 2005 13:46:06 +0000 (13:46 +0000)
committerpinskia <pinskia@138bc75d-0d04-0410-961f-82ee72b054a4>
Wed, 31 Aug 2005 13:46:06 +0000 (13:46 +0000)
        PR obj-c++/23640
        * decl2.c (cp_finish_file): If this is obj-c++ and we need a static
        init, call generate_ctor_or_dtor_function.

2005-08-31  Andrew Pinski  <pinskia@physics.uc.edu>

        PR obj-c++/23640
        * obj-c++.dg/gnu-runtime-3.mm: New test.

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

gcc/cp/ChangeLog
gcc/cp/decl2.c
gcc/testsuite/ChangeLog
gcc/testsuite/obj-c++.dg/gnu-runtime-3.mm [new file with mode: 0644]

index aa8ce89..d16d5f6 100644 (file)
@@ -1,3 +1,9 @@
+2005-08-31  Andrew Pinski  <pinskia@physics.uc.edu>
+
+       PR obj-c++/23640
+       * decl2.c (cp_finish_file): If this is obj-c++ and we need a static
+       init, call generate_ctor_or_dtor_function.
+
 2005-08-31  Volker Reichelt  <reichelt@igpm.rwth-aachen.de>
 
        PR c++/13377
index b08bac8..3821ab0 100644 (file)
@@ -3078,8 +3078,9 @@ cp_finish_file (void)
                        /*data=*/&locus);
   else
     {
-
-      if (static_ctors)
+      /* If we have a ctor or this is obj-c++ and we need a static init,
+         call generate_ctor_or_dtor_function.  */
+      if (static_ctors || (c_dialect_objc () && objc_static_init_needed_p ()))
        generate_ctor_or_dtor_function (/*constructor_p=*/true,
                                        DEFAULT_INIT_PRIORITY, &locus);
       if (static_dtors)
index 5fbdb9e..9c34189 100644 (file)
@@ -1,3 +1,8 @@
+2005-08-31  Andrew Pinski  <pinskia@physics.uc.edu>
+
+       PR obj-c++/23640
+       * obj-c++.dg/gnu-runtime-3.mm: New test.
+
 2005-08-31  Volker Reichelt  <reichelt@igpm.rwth-aachen.de>
 
        PR c++/13377
diff --git a/gcc/testsuite/obj-c++.dg/gnu-runtime-3.mm b/gcc/testsuite/obj-c++.dg/gnu-runtime-3.mm
new file mode 100644 (file)
index 0000000..04671eb
--- /dev/null
@@ -0,0 +1,31 @@
+/* Test that compiling for the GNU runtime works (regardless of
+   the system runtime used).  */
+/* Author: Ziemowit Laski <zlaski@apple.com>  */
+/* { dg-do run } */
+/* { dg-options "-fgnu-runtime" } */
+
+#include <objc/Object.h>
+
+@interface FooBar: Object
+- (void)boo;
+@end
+
+int called = 0;
+extern "C" void abort ();
+
+@implementation FooBar
+- (void)boo
+{
+  called ++;
+}
+@end
+
+int main ()
+{
+  id fooBarInst = [[FooBar alloc] init];
+  [fooBarInst boo];
+  if (called != 1)
+    abort ();
+  return 0;
+}
+