[PATCH] Fix obj-c++ PRs 23611 and 23615

Ulrich Weigand uweigand@de.ibm.com
Thu Oct 6 23:18:00 GMT 2005


Hello,

several obj-c++ test cases fail with the GNU runtime due to incorrect
redeclaration of standard library functions like sscanf (e.g. missing
throw clause).  This is PRs 23611 and 23615.

The following patch fixes this by removing those library function
prototypes from the test cases and adding the appropriate includes
otherwise.  (The patch removes all such prototypes in the test suite,
even those that currently don't cause an error.)

Tested on s390-ibm-linux, fixes encode-[45].mm and method-19.mm FAILs.

OK for mainline?

Bye,
Ulrich


ChangeLog:

	PR testsuite/23611, PR testsuite/23615
	* obj-c++.dg/bitfield-3.mm: Include standard headers instead of
	writing prototypes of library functions by hand.
	* obj-c++.dg/bitfield-4.mm: Likewise.
	* obj-c++.dg/const-str-4.mm: Likewise.
	* obj-c++.dg/encode-4.mm: Likewise.
	* obj-c++.dg/encode-5.mm: Likewise.
	* obj-c++.dg/encode-6.mm: Likewise.
	* obj-c++.dg/gnu-runtime-3.mm: Likewise.
	* obj-c++.dg/method-10.mm: Likewise.
	* obj-c++.dg/method-17.mm: Likewise.
	* obj-c++.dg/method-19.mm: Likewise.
	* obj-c++.dg/try-catch-2.mm: Likewise.


Index: gcc/testsuite/obj-c++.dg/bitfield-3.mm
===================================================================
RCS file: /cvs/gcc/gcc/gcc/testsuite/obj-c++.dg/bitfield-3.mm,v
retrieving revision 1.1
diff -c -p -r1.1 bitfield-3.mm
*** gcc/testsuite/obj-c++.dg/bitfield-3.mm	24 May 2005 22:18:42 -0000	1.1
--- gcc/testsuite/obj-c++.dg/bitfield-3.mm	6 Oct 2005 23:02:06 -0000
***************
*** 6,15 ****
  
  typedef struct objc_object { struct objc_class *class_pointer; } *id;
  
! extern "C" {
!   extern void abort(void);
!   extern int strcmp(const char *, const char *);
! }
  
  #define CHECK_IF(expr) if(!(expr)) abort();
  
--- 6,13 ----
  
  typedef struct objc_object { struct objc_class *class_pointer; } *id;
  
! #include <stdlib.h>
! #include <string.h>
  
  #define CHECK_IF(expr) if(!(expr)) abort();
  
Index: gcc/testsuite/obj-c++.dg/bitfield-4.mm
===================================================================
RCS file: /cvs/gcc/gcc/gcc/testsuite/obj-c++.dg/bitfield-4.mm,v
retrieving revision 1.1
diff -c -p -r1.1 bitfield-4.mm
*** gcc/testsuite/obj-c++.dg/bitfield-4.mm	24 May 2005 22:18:42 -0000	1.1
--- gcc/testsuite/obj-c++.dg/bitfield-4.mm	6 Oct 2005 23:02:06 -0000
***************
*** 6,15 ****
  
  #include <objc/Object.h>
  
! extern "C" {
!   extern void abort(void);
!   extern int strcmp(const char *str1, const char *str2);
! }
  #define CHECK_IF(expr) if(!(expr)) abort()
  
  enum Enum { one, two, three, four };
--- 6,14 ----
  
  #include <objc/Object.h>
  
! #include <stdlib.h>
! #include <string.h>
! 
  #define CHECK_IF(expr) if(!(expr)) abort()
  
  enum Enum { one, two, three, four };
Index: gcc/testsuite/obj-c++.dg/const-str-4.mm
===================================================================
RCS file: /cvs/gcc/gcc/gcc/testsuite/obj-c++.dg/const-str-4.mm,v
retrieving revision 1.1
diff -c -p -r1.1 const-str-4.mm
*** gcc/testsuite/obj-c++.dg/const-str-4.mm	21 Jun 2005 21:13:46 -0000	1.1
--- gcc/testsuite/obj-c++.dg/const-str-4.mm	6 Oct 2005 23:02:06 -0000
***************
*** 3,9 ****
  /* { dg-options "-fnext-runtime -fconstant-string-class=MyString -lobjc" } */ 
  /* { dg-do run { target *-*-darwin* } } */
  
! extern "C" void abort(void);
  
  @interface MyString
  {
--- 3,9 ----
  /* { dg-options "-fnext-runtime -fconstant-string-class=MyString -lobjc" } */ 
  /* { dg-do run { target *-*-darwin* } } */
  
! #include <stdlib.h>
  
  @interface MyString
  {
Index: gcc/testsuite/obj-c++.dg/encode-4.mm
===================================================================
RCS file: /cvs/gcc/gcc/gcc/testsuite/obj-c++.dg/encode-4.mm,v
retrieving revision 1.1
diff -c -p -r1.1 encode-4.mm
*** gcc/testsuite/obj-c++.dg/encode-4.mm	24 May 2005 22:18:42 -0000	1.1
--- gcc/testsuite/obj-c++.dg/encode-4.mm	6 Oct 2005 23:02:06 -0000
***************
*** 31,40 ****
  #define CLASS_GETINSTANCEMETHOD class_get_instance_method
  #endif
  
! extern "C" {
!   extern int sscanf(const char *str, const char *format, ...);
!   extern void abort(void);
! }
  #define CHECK_IF(expr) if(!(expr)) abort()
  
  @interface Foo: Object
--- 31,39 ----
  #define CLASS_GETINSTANCEMETHOD class_get_instance_method
  #endif
  
! #include <stdio.h>
! #include <stdlib.h>
! 
  #define CHECK_IF(expr) if(!(expr)) abort()
  
  @interface Foo: Object
Index: gcc/testsuite/obj-c++.dg/encode-5.mm
===================================================================
RCS file: /cvs/gcc/gcc/gcc/testsuite/obj-c++.dg/encode-5.mm,v
retrieving revision 1.1
diff -c -p -r1.1 encode-5.mm
*** gcc/testsuite/obj-c++.dg/encode-5.mm	24 May 2005 22:18:42 -0000	1.1
--- gcc/testsuite/obj-c++.dg/encode-5.mm	6 Oct 2005 23:02:06 -0000
***************
*** 13,22 ****
  #include <objc/objc-api.h>
  #endif
  
! extern "C" {
!   extern int sscanf(const char *str, const char *format, ...);
!   extern void abort(void);
! }
  #define CHECK_IF(expr) if(!(expr)) abort()
  
  enum Enum {
--- 13,21 ----
  #include <objc/objc-api.h>
  #endif
  
! #include <stdio.h>
! #include <stdlib.h>
! 
  #define CHECK_IF(expr) if(!(expr)) abort()
  
  enum Enum {
Index: gcc/testsuite/obj-c++.dg/encode-6.mm
===================================================================
RCS file: /cvs/gcc/gcc/gcc/testsuite/obj-c++.dg/encode-6.mm,v
retrieving revision 1.1
diff -c -p -r1.1 encode-6.mm
*** gcc/testsuite/obj-c++.dg/encode-6.mm	24 May 2005 22:18:42 -0000	1.1
--- gcc/testsuite/obj-c++.dg/encode-6.mm	6 Oct 2005 23:02:06 -0000
***************
*** 12,21 ****
  #define OBJC_GETCLASS objc_get_class
  #endif
  
! extern "C" {
!   extern void abort(void);
!   extern int strcmp(const char *s1, const char *s2);
! }
  #define CHECK_IF(expr) if(!(expr)) abort()
  
  @class Int1, Int2;
--- 12,20 ----
  #define OBJC_GETCLASS objc_get_class
  #endif
  
! #include <stdlib.h>
! #include <string.h>
! 
  #define CHECK_IF(expr) if(!(expr)) abort()
  
  @class Int1, Int2;
Index: gcc/testsuite/obj-c++.dg/gnu-runtime-3.mm
===================================================================
RCS file: /cvs/gcc/gcc/gcc/testsuite/obj-c++.dg/gnu-runtime-3.mm,v
retrieving revision 1.2
diff -c -p -r1.2 gnu-runtime-3.mm
*** gcc/testsuite/obj-c++.dg/gnu-runtime-3.mm	31 Aug 2005 21:20:06 -0000	1.2
--- gcc/testsuite/obj-c++.dg/gnu-runtime-3.mm	6 Oct 2005 23:02:06 -0000
***************
*** 5,17 ****
  /* { 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
--- 5,17 ----
  /* { dg-options "-fgnu-runtime" } */
  
  #include <objc/Object.h>
+ #include <stdlib.h>
  
  @interface FooBar: Object
  - (void)boo;
  @end
  
  int called = 0;
  
  @implementation FooBar
  - (void)boo
Index: gcc/testsuite/obj-c++.dg/method-10.mm
===================================================================
RCS file: /cvs/gcc/gcc/gcc/testsuite/obj-c++.dg/method-10.mm,v
retrieving revision 1.1
diff -c -p -r1.1 method-10.mm
*** gcc/testsuite/obj-c++.dg/method-10.mm	24 May 2005 22:18:42 -0000	1.1
--- gcc/testsuite/obj-c++.dg/method-10.mm	6 Oct 2005 23:02:06 -0000
***************
*** 4,11 ****
  /* { dg-do run } */
  
  #include <objc/Object.h>
  
- extern "C" void abort(void);
  #define CHECK_IF(expr) if(!(expr)) abort()
  
  @interface Int1: Object
--- 4,11 ----
  /* { dg-do run } */
  
  #include <objc/Object.h>
+ #include <stdlib.h>
  
  #define CHECK_IF(expr) if(!(expr)) abort()
  
  @interface Int1: Object
Index: gcc/testsuite/obj-c++.dg/method-17.mm
===================================================================
RCS file: /cvs/gcc/gcc/gcc/testsuite/obj-c++.dg/method-17.mm,v
retrieving revision 1.1
diff -c -p -r1.1 method-17.mm
*** gcc/testsuite/obj-c++.dg/method-17.mm	24 May 2005 22:18:42 -0000	1.1
--- gcc/testsuite/obj-c++.dg/method-17.mm	6 Oct 2005 23:02:06 -0000
***************
*** 5,11 ****
  /* { dg-do run } */
  
  #include <objc/Object.h>
! extern "C" void abort(void);
  #define CHECK_IF(expr) if(!(expr)) abort()
  
  static double d = 4.5920234e2;
--- 5,12 ----
  /* { dg-do run } */
  
  #include <objc/Object.h>
! #include <stdlib.h>
! 
  #define CHECK_IF(expr) if(!(expr)) abort()
  
  static double d = 4.5920234e2;
Index: gcc/testsuite/obj-c++.dg/method-19.mm
===================================================================
RCS file: /cvs/gcc/gcc/gcc/testsuite/obj-c++.dg/method-19.mm,v
retrieving revision 1.1
diff -c -p -r1.1 method-19.mm
*** gcc/testsuite/obj-c++.dg/method-19.mm	24 May 2005 22:18:42 -0000	1.1
--- gcc/testsuite/obj-c++.dg/method-19.mm	6 Oct 2005 23:02:06 -0000
***************
*** 14,23 ****
  #define OBJC_GETCLASS objc_get_class
  #endif
  
! extern "C" {
!   extern void abort(void);
!   extern int strcmp(const char *, const char *);
! }
  #define CHECK_IF(expr) if(!(expr)) abort()
  
  @protocol Proto
--- 14,22 ----
  #define OBJC_GETCLASS objc_get_class
  #endif
  
! #include <stdlib.h>
! #include <string.h>
! 
  #define CHECK_IF(expr) if(!(expr)) abort()
  
  @protocol Proto
Index: gcc/testsuite/obj-c++.dg/try-catch-2.mm
===================================================================
RCS file: /cvs/gcc/gcc/gcc/testsuite/obj-c++.dg/try-catch-2.mm,v
retrieving revision 1.2
diff -c -p -r1.2 try-catch-2.mm
*** gcc/testsuite/obj-c++.dg/try-catch-2.mm	26 May 2005 01:53:56 -0000	1.2
--- gcc/testsuite/obj-c++.dg/try-catch-2.mm	6 Oct 2005 23:02:06 -0000
***************
*** 7,19 ****
  
  #include <objc/Object.h>
  #include <stdio.h>
  
  /* The following is not required in actual user code; we include it
     here to check that the compiler generates an internal definition of
     _setjmp that is consistent with what <setjmp.h> provides.  */
  #include <setjmp.h>
  
- extern "C" void abort(void);
  #define CHECK_IF(expr) if(!(expr)) abort()
  
  @interface Frob: Object
--- 7,19 ----
  
  #include <objc/Object.h>
  #include <stdio.h>
+ #include <stdlib.h>
  
  /* The following is not required in actual user code; we include it
     here to check that the compiler generates an internal definition of
     _setjmp that is consistent with what <setjmp.h> provides.  */
  #include <setjmp.h>
  
  #define CHECK_IF(expr) if(!(expr)) abort()
  
  @interface Frob: Object
-- 
  Dr. Ulrich Weigand
  Linux on zSeries Development
  Ulrich.Weigand@de.ibm.com



More information about the Gcc-patches mailing list