Patchwork [Darwin] Suppress build warnings about struct cl_decoded_option.

login
register
mail settings
Submitter IainS
Date Dec. 17, 2010, 10:22 a.m.
Message ID <4CD84427-D8DB-4992-8672-55F91A9FDD1E@sandoe-acoustics.co.uk>
Download mbox | patch
Permalink /patch/75858/
State New
Headers show

Comments

IainS - Dec. 17, 2010, 10:22 a.m.
The GCC_DRIVER_HOST_INITIALIZATION macro (used in gcc.c) takes  
arguments  like so.
(unsigned int *,struct cl_decoded_option **)

struct cl_decoded_option is not defined in the headers included by  
tm.h  - but the macro needs to be there.
this results in hundreds of build-time warnings.

The patch is a little icky -- but short of re-ordering all the headers  
in gcc.c (or including tm_p.h) it's a work-around.

Joseph, do you have any plans to alter how the host-specific init is  
done?

(if inclusion of tm_p.h in gcc.c would be acceptable this would also  
be much neater).

thoughts?
Iain

gcc:

	* config/darwin.h (GCC_DRIVER_HOST_INITIALIZATION):
	Wrap the external function declaration inside the macro.
	* config/darwin-driver.c :  Pre-declare darwin_driver_init ().


  		    struct cl_decoded_option **decoded_options)
Paolo Bonzini - Dec. 17, 2010, 10:55 a.m.
On 12/17/2010 11:22 AM, IainS wrote:
> Index: gcc/config/darwin.h
> ===================================================================
> --- gcc/config/darwin.h (revision 167881)
> +++ gcc/config/darwin.h (working copy)
> @@ -963,10 +968,10 @@ __enable_execute_stack (void *addr)
>
> #define TARGET_HAS_TARGETCM 1
>
> -extern void darwin_driver_init (unsigned int *decoded_options_count,
> - struct cl_decoded_option **decoded_options);

Can't you just add a "struct cl_decoded_option;" forward reference 
before the extern?

Paolo
Joseph S. Myers - Dec. 17, 2010, 12:41 p.m.
On Fri, 17 Dec 2010, Paolo Bonzini wrote:

> On 12/17/2010 11:22 AM, IainS wrote:
> > Index: gcc/config/darwin.h
> > ===================================================================
> > --- gcc/config/darwin.h (revision 167881)
> > +++ gcc/config/darwin.h (working copy)
> > @@ -963,10 +968,10 @@ __enable_execute_stack (void *addr)
> > 
> > #define TARGET_HAS_TARGETCM 1
> > 
> > -extern void darwin_driver_init (unsigned int *decoded_options_count,
> > - struct cl_decoded_option **decoded_options);
> 
> Can't you just add a "struct cl_decoded_option;" forward reference before the
> extern?

The place for such forward references is in coretypes.h, not random 
individual source files.  And indeed such a declaration is already there.  
So if the warnings are from files not including coretypes.h, the missing 
coretypes.h includes should be added (after config.h and system.h, before 
any other headers are included).  Or if the issue is that this declaration 
in coretypes.h is under "#ifndef USED_FOR_TARGET" and the warnings are 
building code for the target, then the prototype in darwin.h should also 
be conditioned on "#ifndef USED_FOR_TARGET".

Patch

Index: gcc/config/darwin.h
===================================================================
--- gcc/config/darwin.h	(revision 167881)
+++ gcc/config/darwin.h	(working copy)
@@ -963,10 +968,10 @@  __enable_execute_stack (void *addr)

  #define TARGET_HAS_TARGETCM 1

-extern void darwin_driver_init (unsigned int *decoded_options_count,
-				struct cl_decoded_option **decoded_options);
-#define GCC_DRIVER_HOST_INITIALIZATION \
-  darwin_driver_init (&decoded_options_count, &decoded_options)
+#define GCC_DRIVER_HOST_INITIALIZATION  do {					\
+ extern void darwin_driver_init (unsigned int *,struct  
cl_decoded_option **);	\
+ darwin_driver_init (&decoded_options_count, &decoded_options);			\
+} while (0)

  /* The Apple assembler and linker do not support constructor  
priorities.  */
  #undef SUPPORTS_INIT_PRIORITY
Index: gcc/config/darwin-driver.c
===================================================================
--- gcc/config/darwin-driver.c	(revision 167881)
+++ gcc/config/darwin-driver.c	(working copy)
@@ -149,6 +149,8 @@  darwin_default_min_version (unsigned int *decoded_
     not be called if there are no other inputs.  When native, also
     default the -mmacosx-version-min flag.  */

+extern void darwin_driver_init (unsigned int *,struct  
cl_decoded_option **);
+
  void
  darwin_driver_init (unsigned int *decoded_options_count,