[Java PATCH] Generate declarations in jvgenmain.c

2014-10-06 Thread Marek Polacek
Java testsuite breaks with -std=gnu11 as a default and/or with 
-Wimplicit-function-declaration on, since the jvgenmain.c program
that generates a C file containing 'main' function which calls either
'JvRunMainName' or 'JvRunMain' does not generate forward declarations
for these functions.  The fix is obvious IMHO.

Bootstrapped/regtested on x86_64-linux, ok for trunk?

2014-10-06  Marek Polacek  

* jvgenmain.c: Generate forward declarations for JvRunMain{,Name}.

diff --git gcc/gcc/java/jvgenmain.c gcc/gcc/java/jvgenmain.c
index 5b14258..a786d31 100644
--- gcc/gcc/java/jvgenmain.c
+++ gcc/gcc/java/jvgenmain.c
@@ -127,6 +127,8 @@ main (int argc, char **argv)
   /* At this point every element of ARGV from 1 to LAST_ARG is a `-D'
  option.  Process them appropriately.  */
   fprintf (stream, "extern const char **_Jv_Compiler_Properties;\n");
+  fprintf (stream, "extern void JvRunMain ();\n");
+  fprintf (stream, "extern void JvRunMainName ();\n");
   fprintf (stream, "static const char *props[] =\n{\n");
   for (i = 1; i < last_arg; ++i)
 {

Marek


[Java PATCH] Generate declarations in jvgenmain.c

2014-10-07 Thread Marek Polacek
[CCing java-patches now]

Java testsuite breaks with -std=gnu11 as a default and/or with 
-Wimplicit-function-declaration on, since the jvgenmain.c program
that generates a C file containing 'main' function which calls either
'JvRunMainName' or 'JvRunMain' does not generate forward declarations
for these functions.  The following patch generates such a declaration
depending on whether -findirect-dispatch is given.

Bootstrapped/regtested on x86_64-linux, ok for trunk?

2014-10-07  Marek Polacek  

* jvgenmain.c (main): Provide declaration for JvRunMain{,Name}.

diff --git gcc/java/jvgenmain.c gcc/java/jvgenmain.c
index 5b14258..82e468d 100644
--- gcc/java/jvgenmain.c
+++ gcc/java/jvgenmain.c
@@ -127,6 +127,10 @@ main (int argc, char **argv)
   /* At this point every element of ARGV from 1 to LAST_ARG is a `-D'
  option.  Process them appropriately.  */
   fprintf (stream, "extern const char **_Jv_Compiler_Properties;\n");
+  if (indirect)
+fprintf (stream, "extern void JvRunMainName ();\n");
+  else
+fprintf (stream, "extern void JvRunMain ();\n");
   fprintf (stream, "static const char *props[] =\n{\n");
   for (i = 1; i < last_arg; ++i)
 {

Marek


Re: [Java PATCH] Generate declarations in jvgenmain.c

2014-10-06 Thread Mark Wielaard
On Mon, Oct 06, 2014 at 11:54:00AM +0200, Marek Polacek wrote:
> Java testsuite breaks with -std=gnu11 as a default and/or with 
> -Wimplicit-function-declaration on, since the jvgenmain.c program
> that generates a C file containing 'main' function which calls either
> 'JvRunMainName' or 'JvRunMain' does not generate forward declarations
> for these functions.  The fix is obvious IMHO.
> 
> Bootstrapped/regtested on x86_64-linux, ok for trunk?

I cannot approve (java) patches, but it does look ok to me.
With one nitpick. JvRunMain is only used when -findirect-dispatch
is given, and otherwise JvRunMainName is used. So you could output
only the actually used forward declaration by checking if (indirect).

If no java maintainer responds, try CCing java-patc...@gcc.gnu.org
to draw their attention.

Cheers,

Mark


Re: [Java PATCH] Generate declarations in jvgenmain.c

2014-10-07 Thread Andrew Haley
On 06/10/14 22:00, Mark Wielaard wrote:
> If no java maintainer responds, try CCing java-patc...@gcc.gnu.org
> to draw their attention.

Please.  I can't see the patch here.

Andrew.



Re: [Java PATCH] Generate declarations in jvgenmain.c

2014-10-07 Thread Marek Polacek
On Mon, Oct 06, 2014 at 11:00:48PM +0200, Mark Wielaard wrote:
> On Mon, Oct 06, 2014 at 11:54:00AM +0200, Marek Polacek wrote:
> > Java testsuite breaks with -std=gnu11 as a default and/or with 
> > -Wimplicit-function-declaration on, since the jvgenmain.c program
> > that generates a C file containing 'main' function which calls either
> > 'JvRunMainName' or 'JvRunMain' does not generate forward declarations
> > for these functions.  The fix is obvious IMHO.
> > 
> > Bootstrapped/regtested on x86_64-linux, ok for trunk?
> 
> I cannot approve (java) patches, but it does look ok to me.
> With one nitpick. JvRunMain is only used when -findirect-dispatch
> is given, and otherwise JvRunMainName is used. So you could output
> only the actually used forward declaration by checking if (indirect).

Yeah, that will be better.
 
> If no java maintainer responds, try CCing java-patc...@gcc.gnu.org
> to draw their attention.

Done (separate mail).  Thanks.

Marek


Re: [Java PATCH] Generate declarations in jvgenmain.c

2014-10-07 Thread Andrew Haley
On 10/07/2014 09:31 AM, Marek Polacek wrote:
> Bootstrapped/regtested on x86_64-linux, ok for trunk?

OK, thanks.

Andrew.



Re: [Java PATCH] Generate declarations in jvgenmain.c

2014-10-07 Thread Tom Tromey
> "Marek" == Marek Polacek  writes:

Marek> [CCing java-patches now]
Marek> Java testsuite breaks with -std=gnu11 as a default and/or with 
Marek> -Wimplicit-function-declaration on

I don't recall how one gets warnings when compiling this generated code,
but if it is generally possible then I think this:

Marek> +  if (indirect)
Marek> +fprintf (stream, "extern void JvRunMainName ();\n");
Marek> +  else
Marek> +fprintf (stream, "extern void JvRunMain ();\n");

... will fail with -Wstrict-prototypes, since in C those should
read "(void)" rather than "()".

If it's not possible then no big deal.

Tom


Re: [Java PATCH] Generate declarations in jvgenmain.c

2014-10-07 Thread Marek Polacek
On Tue, Oct 07, 2014 at 10:03:26AM -0600, Tom Tromey wrote:
> > "Marek" == Marek Polacek  writes:
> 
> Marek> [CCing java-patches now]
> Marek> Java testsuite breaks with -std=gnu11 as a default and/or with 
> Marek> -Wimplicit-function-declaration on
> 
> I don't recall how one gets warnings when compiling this generated code,
> but if it is generally possible then I think this:

I'm not sure I understand, but this piece of code gets compiled when
running the libjava testsuite.  And when the warning triggers, we get
many fails.
 
> Marek> +  if (indirect)
> Marek> +fprintf (stream, "extern void JvRunMainName ();\n");
> Marek> +  else
> Marek> +fprintf (stream, "extern void JvRunMain ();\n");
> 
> ... will fail with -Wstrict-prototypes, since in C those should
> read "(void)" rather than "()".
> 
> If it's not possible then no big deal.

I saw declarations of JvRunMain{,Name} with no parameters and with
some parameters.  So I decided to make it prototype-less function
declaration for now.  I think we don't have to worry about
-Wstrict-prototypes for now.

Marek


Re: [Java PATCH] Generate declarations in jvgenmain.c

2014-10-07 Thread Tom Tromey
Marek> I saw declarations of JvRunMain{,Name} with no parameters and with
Marek> some parameters.

Oh yeah, duh.

Marek>  So I decided to make it prototype-less function
Marek> declaration for now.  I think we don't have to worry about
Marek> -Wstrict-prototypes for now.

Thanks for looking.

Tom