aboutsummaryrefslogtreecommitdiff
path: root/gcc
diff options
context:
space:
mode:
Diffstat (limited to 'gcc')
-rw-r--r--gcc/cp/ChangeLog6
-rw-r--r--gcc/cp/decl2.c5
-rw-r--r--gcc/testsuite/ChangeLog5
-rw-r--r--gcc/testsuite/obj-c++.dg/gnu-runtime-3.mm31
4 files changed, 45 insertions, 2 deletions
diff --git a/gcc/cp/ChangeLog b/gcc/cp/ChangeLog
index aa8ce89..d16d5f6 100644
--- a/gcc/cp/ChangeLog
+++ b/gcc/cp/ChangeLog
@@ -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
diff --git a/gcc/cp/decl2.c b/gcc/cp/decl2.c
index b08bac8..3821ab0 100644
--- a/gcc/cp/decl2.c
+++ b/gcc/cp/decl2.c
@@ -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)
diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog
index 5fbdb9e..9c34189 100644
--- a/gcc/testsuite/ChangeLog
+++ b/gcc/testsuite/ChangeLog
@@ -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
index 0000000..04671eb
--- /dev/null
+++ b/gcc/testsuite/obj-c++.dg/gnu-runtime-3.mm
@@ -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;
+}
+