diff mbox

Silence merge warnings on artiical types

Message ID 20150330030257.GA71352@kam.mff.cuni.cz
State New
Headers show

Commit Message

Jan Hubicka March 30, 2015, 3:02 a.m. UTC
Hi,
when compiling C++ program that define different number of virtual method
in different classes, we output warnings about their virtual tables
being of different type. THese warnings looks ugly and we are able
to diagnose the situation in more sensible way.

This patch simply silences all warnings on artificial decls.

Bootstrapped/regtested x86_64-linux OK?
Honza

	* lto-symtab.c (lto_symtab_merge_decls_2): Silence warnings on
	artificial decls.

Comments

Richard Biener March 30, 2015, 8:30 a.m. UTC | #1
On Mon, 30 Mar 2015, Jan Hubicka wrote:

> Hi,
> when compiling C++ program that define different number of virtual method
> in different classes, we output warnings about their virtual tables
> being of different type. THese warnings looks ugly and we are able
> to diagnose the situation in more sensible way.
> 
> This patch simply silences all warnings on artificial decls.
> 
> Bootstrapped/regtested x86_64-linux OK?

Hum...  but do ODR warnings cover all other cases here?  Well,
the warnings won't be useful to users I suppose.

Thus, ok.

Thanks,
Richard.

> Honza
> 
> 	* lto-symtab.c (lto_symtab_merge_decls_2): Silence warnings on
> 	artificial decls.
> Index: lto/lto-symtab.c
> ===================================================================
> --- lto/lto-symtab.c	(revision 221757)
> +++ lto/lto-symtab.c	(working copy)
> @@ -473,7 +473,8 @@ lto_symtab_merge_decls_2 (symtab_node *f
>      if (TREE_PUBLIC (e->decl))
>        {
>  	if (!lto_symtab_merge (prevailing, e)
> -	    && !diagnosed_p)
> +	    && !diagnosed_p
> +	    && !DECL_ARTIFICIAL (e->decl))
>  	  mismatches.safe_push (e->decl);
>        }
>    if (mismatches.is_empty ())
> 
>
Jan Hubicka March 30, 2015, 8:48 a.m. UTC | #2
> On Mon, 30 Mar 2015, Jan Hubicka wrote:
> 
> > Hi,
> > when compiling C++ program that define different number of virtual method
> > in different classes, we output warnings about their virtual tables
> > being of different type. THese warnings looks ugly and we are able
> > to diagnose the situation in more sensible way.
> > 
> > This patch simply silences all warnings on artificial decls.
> > 
> > Bootstrapped/regtested x86_64-linux OK?
> 
> Hum...  but do ODR warnings cover all other cases here?  Well,

For C++ vtables and typeinfos it should. I am not at all sure what
other kinds of artifical & public declarations we produce.

> the warnings won't be useful to users I suppose.

yep, that was the main motivation.
Perhaps for development purposes we could drop a message into .cgraph dump (and
eventaully break it into .merge dump)

Honza
> 
> Thus, ok.
> 
> Thanks,
> Richard.
> 
> > Honza
> > 
> > 	* lto-symtab.c (lto_symtab_merge_decls_2): Silence warnings on
> > 	artificial decls.
> > Index: lto/lto-symtab.c
> > ===================================================================
> > --- lto/lto-symtab.c	(revision 221757)
> > +++ lto/lto-symtab.c	(working copy)
> > @@ -473,7 +473,8 @@ lto_symtab_merge_decls_2 (symtab_node *f
> >      if (TREE_PUBLIC (e->decl))
> >        {
> >  	if (!lto_symtab_merge (prevailing, e)
> > -	    && !diagnosed_p)
> > +	    && !diagnosed_p
> > +	    && !DECL_ARTIFICIAL (e->decl))
> >  	  mismatches.safe_push (e->decl);
> >        }
> >    if (mismatches.is_empty ())
> > 
> > 
> 
> -- 
> Richard Biener <rguenther@suse.de>
> SUSE LINUX GmbH, GF: Felix Imendoerffer, Jane Smithard, Jennifer Guild,
> Dilip Upmanyu, Graham Norton HRB 21284 (AG Nuernberg)
Ilya Verbin March 30, 2015, 3:36 p.m. UTC | #3
On Mon, Mar 30, 2015 at 05:02:57 +0200, Jan Hubicka wrote:
> 	* lto-symtab.c (lto_symtab_merge_decls_2): Silence warnings on
> 	artificial decls.

Shouldn't this patch fix libgomp.c++/target-3.C in an offloading-enabled
configuration?  It still fails...

libgomp/testsuite/libgomp.c++/../libgomp.c/target-2.c:27:13: warning: type 'struct .omp_data_s.7' violates one definition rule [-Wodr]
     #pragma omp parallel for reduction(+:s)
             ^
     #pragma omp parallel for reduction(+:s)
             ^
   double b[3 * x], c[3 * x], d[3 * x], e[3 * x];
                 ^
   double b[3 * x], c[3 * x], d[3 * x], e[3 * x];
                 ^

  -- Ilya
Jan Hubicka March 30, 2015, 5:06 p.m. UTC | #4
> On Mon, Mar 30, 2015 at 05:02:57 +0200, Jan Hubicka wrote:
> > 	* lto-symtab.c (lto_symtab_merge_decls_2): Silence warnings on
> > 	artificial decls.
> 
> Shouldn't this patch fix libgomp.c++/target-3.C in an offloading-enabled
> configuration?  It still fails...
> 
> libgomp/testsuite/libgomp.c++/../libgomp.c/target-2.c:27:13: warning: type 'struct .omp_data_s.7' violates one definition rule [-Wodr]
>      #pragma omp parallel for reduction(+:s)
>              ^
>      #pragma omp parallel for reduction(+:s)
>              ^
>    double b[3 * x], c[3 * x], d[3 * x], e[3 * x];
>                  ^
>    double b[3 * x], c[3 * x], d[3 * x], e[3 * x];
>                  ^

No, that is an different warning.  Why those types are different? Is this a full warning output?

Honza
> 
>   -- Ilya
Ilya Verbin March 30, 2015, 5:10 p.m. UTC | #5
On Mon, Mar 30, 2015 at 19:06:39 +0200, Jan Hubicka wrote:
> > On Mon, Mar 30, 2015 at 05:02:57 +0200, Jan Hubicka wrote:
> > > 	* lto-symtab.c (lto_symtab_merge_decls_2): Silence warnings on
> > > 	artificial decls.
> > 
> > Shouldn't this patch fix libgomp.c++/target-3.C in an offloading-enabled
> > configuration?  It still fails...
> > 
> > libgomp/testsuite/libgomp.c++/../libgomp.c/target-2.c:27:13: warning: type 'struct .omp_data_s.7' violates one definition rule [-Wodr]
> >      #pragma omp parallel for reduction(+:s)
> >              ^
> >      #pragma omp parallel for reduction(+:s)
> >              ^
> >    double b[3 * x], c[3 * x], d[3 * x], e[3 * x];
> >                  ^
> >    double b[3 * x], c[3 * x], d[3 * x], e[3 * x];
> >                  ^
> 
> No, that is an different warning.  Why those types are different? Is this a full warning output?

Here is full output:

spawn -ignore SIGHUP /gcc_build_host/gcc/xgcc -B/gcc_build_host/gcc/ /gcc/libgomp/testsuite/libgomp.c++/target-3.C -B/gcc_build_host/x86_64-pc-linux-gnu/./libgomp/ -B/gcc_build_host/x86_64-pc-linux-gnu/./libgomp/.libs -I/gcc_build_host/x86_64-pc-linux-gnu/./libgomp -I/gcc/libgomp/testsuite/../../include -I/gcc/libgomp/testsuite/.. -fmessage-length=0 -fno-diagnostics-show-caret -fdiagnostics-color=never -B/gcc_install/usr/local//libexec/gcc/x86_64-pc-linux-gnu/5.0.0 -B/gcc_install/usr/local//gcc -B/gcc_install/usr/local//bin -fopenmp -nostdinc++ -I/gcc_build_host/x86_64-pc-linux-gnu/libstdc++-v3/include/x86_64-pc-linux-gnu -I/gcc_build_host/x86_64-pc-linux-gnu/libstdc++-v3/include -I/gcc/libstdc++-v3/libsupc++ -I/gcc/libstdc++-v3/include/backward -I/gcc/libstdc++-v3/testsuite/util -B/gcc_build_host/x86_64-pc-linux-gnu/./libgomp/../libstdc++-v3/src/.libs -L/gcc_build_host/x86_64-pc-linux-gnu/./libgomp/.libs -L/gcc_build_host/x86_64-pc-linux-gnu/./libgomp/../libstdc++-v3/src/.libs -lstdc++ -lm -o ./target-3.exe
/gcc/libgomp/testsuite/libgomp.c++/../libgomp.c/target-2.c:27:13: warning: type 'struct .omp_data_s.7' violates one definition rule [-Wodr]
     #pragma omp parallel for reduction(+:s)
             ^
/gcc/libgomp/testsuite/libgomp.c++/../libgomp.c/target-2.c:27:13: note: a different type is defined in another translation unit
     #pragma omp parallel for reduction(+:s)
             ^
/gcc/libgomp/testsuite/libgomp.c++/../libgomp.c/target-2.c:22:17: note: the first difference of corresponding definitions is field 'b.0'
   double b[3 * x], c[3 * x], d[3 * x], e[3 * x];
                 ^
/gcc/libgomp/testsuite/libgomp.c++/../libgomp.c/target-2.c:22:17: note: a field of same name but different type is defined in another translation unit
   double b[3 * x], c[3 * x], d[3 * x], e[3 * x];
                 ^
lto1: note: array types have different bounds
/gcc/libgomp/testsuite/libgomp.c++/../libgomp.c/target-2.c:42:13: warning: type 'struct .omp_data_s.20' violates one definition rule [-Wodr]
     #pragma omp parallel for reduction(+:s)
             ^
/gcc/libgomp/testsuite/libgomp.c++/../libgomp.c/target-2.c:42:13: note: a different type is defined in another translation unit
/gcc/libgomp/testsuite/libgomp.c++/../libgomp.c/target-2.c:37:17: note: the first difference of corresponding definitions is field 'b.14'
   double b[3 * x], c[3 * x], d[3 * x], e[3 * x];
                 ^
/gcc/libgomp/testsuite/libgomp.c++/../libgomp.c/target-2.c:37:17: note: a field of same name but different type is defined in another translation unit
   double b[3 * x], c[3 * x], d[3 * x], e[3 * x];
                 ^
lto1: note: array types have different bounds
/gcc/libgomp/testsuite/libgomp.c++/../libgomp.c/target-2.c:60:10: warning: type 'struct .omp_data_s.38' violates one definition rule [-Wodr]
  #pragma omp parallel for reduction(+:s)
          ^
/gcc/libgomp/testsuite/libgomp.c++/../libgomp.c/target-2.c:60:10: note: a different type is defined in another translation unit
/gcc/libgomp/testsuite/libgomp.c++/../libgomp.c/target-2.c:52:17: note: the first difference of corresponding definitions is field 'b.27'
   double b[3 * x], c[3 * x], d[3 * x], e[3 * x];
                 ^
/gcc/libgomp/testsuite/libgomp.c++/../libgomp.c/target-2.c:52:17: note: a field of same name but different type is defined in another translation unit
   double b[3 * x], c[3 * x], d[3 * x], e[3 * x];
                 ^
lto1: note: array types have different bounds
output is:
/gcc/libgomp/testsuite/libgomp.c++/../libgomp.c/target-2.c:27:13: warning: type 'struct .omp_data_s.7' violates one definition rule [-Wodr]
     #pragma omp parallel for reduction(+:s)
             ^
/gcc/libgomp/testsuite/libgomp.c++/../libgomp.c/target-2.c:27:13: note: a different type is defined in another translation unit
     #pragma omp parallel for reduction(+:s)
             ^
/gcc/libgomp/testsuite/libgomp.c++/../libgomp.c/target-2.c:22:17: note: the first difference of corresponding definitions is field 'b.0'
   double b[3 * x], c[3 * x], d[3 * x], e[3 * x];
                 ^
/gcc/libgomp/testsuite/libgomp.c++/../libgomp.c/target-2.c:22:17: note: a field of same name but different type is defined in another translation unit
   double b[3 * x], c[3 * x], d[3 * x], e[3 * x];
                 ^
lto1: note: array types have different bounds
/gcc/libgomp/testsuite/libgomp.c++/../libgomp.c/target-2.c:42:13: warning: type 'struct .omp_data_s.20' violates one definition rule [-Wodr]
     #pragma omp parallel for reduction(+:s)
             ^
/gcc/libgomp/testsuite/libgomp.c++/../libgomp.c/target-2.c:42:13: note: a different type is defined in another translation unit
/gcc/libgomp/testsuite/libgomp.c++/../libgomp.c/target-2.c:37:17: note: the first difference of corresponding definitions is field 'b.14'
   double b[3 * x], c[3 * x], d[3 * x], e[3 * x];
                 ^
/gcc/libgomp/testsuite/libgomp.c++/../libgomp.c/target-2.c:37:17: note: a field of same name but different type is defined in another translation unit
   double b[3 * x], c[3 * x], d[3 * x], e[3 * x];
                 ^
lto1: note: array types have different bounds
/gcc/libgomp/testsuite/libgomp.c++/../libgomp.c/target-2.c:60:10: warning: type 'struct .omp_data_s.38' violates one definition rule [-Wodr]
  #pragma omp parallel for reduction(+:s)
          ^
/gcc/libgomp/testsuite/libgomp.c++/../libgomp.c/target-2.c:60:10: note: a different type is defined in another translation unit
/gcc/libgomp/testsuite/libgomp.c++/../libgomp.c/target-2.c:52:17: note: the first difference of corresponding definitions is field 'b.27'
   double b[3 * x], c[3 * x], d[3 * x], e[3 * x];
                 ^
/gcc/libgomp/testsuite/libgomp.c++/../libgomp.c/target-2.c:52:17: note: a field of same name but different type is defined in another translation unit
   double b[3 * x], c[3 * x], d[3 * x], e[3 * x];
                 ^
lto1: note: array types have different bounds

FAIL: libgomp.c++/target-3.C (test for excess errors)
Excess errors:
/gcc/libgomp/testsuite/libgomp.c++/../libgomp.c/target-2.c:27:13: warning: type 'struct .omp_data_s.7' violates one definition rule [-Wodr]
     #pragma omp parallel for reduction(+:s)
             ^
     #pragma omp parallel for reduction(+:s)
             ^
   double b[3 * x], c[3 * x], d[3 * x], e[3 * x];
                 ^
   double b[3 * x], c[3 * x], d[3 * x], e[3 * x];
                 ^
/gcc/libgomp/testsuite/libgomp.c++/../libgomp.c/target-2.c:42:13: warning: type 'struct .omp_data_s.20' violates one definition rule [-Wodr]
     #pragma omp parallel for reduction(+:s)
             ^
   double b[3 * x], c[3 * x], d[3 * x], e[3 * x];
                 ^
   double b[3 * x], c[3 * x], d[3 * x], e[3 * x];
                 ^
/gcc/libgomp/testsuite/libgomp.c++/../libgomp.c/target-2.c:60:10: warning: type 'struct .omp_data_s.38' violates one definition rule [-Wodr]
  #pragma omp parallel for reduction(+:s)
          ^
   double b[3 * x], c[3 * x], d[3 * x], e[3 * x];
                 ^
   double b[3 * x], c[3 * x], d[3 * x], e[3 * x];
                 ^

  -- Ilya
Jakub Jelinek March 30, 2015, 5:21 p.m. UTC | #6
On Mon, Mar 30, 2015 at 07:06:39PM +0200, Jan Hubicka wrote:
> > On Mon, Mar 30, 2015 at 05:02:57 +0200, Jan Hubicka wrote:
> > > 	* lto-symtab.c (lto_symtab_merge_decls_2): Silence warnings on
> > > 	artificial decls.
> > 
> > Shouldn't this patch fix libgomp.c++/target-3.C in an offloading-enabled
> > configuration?  It still fails...
> > 
> > libgomp/testsuite/libgomp.c++/../libgomp.c/target-2.c:27:13: warning: type 'struct .omp_data_s.7' violates one definition rule [-Wodr]
> >      #pragma omp parallel for reduction(+:s)
> >              ^
> >      #pragma omp parallel for reduction(+:s)
> >              ^
> >    double b[3 * x], c[3 * x], d[3 * x], e[3 * x];
> >                  ^
> >    double b[3 * x], c[3 * x], d[3 * x], e[3 * x];
> >                  ^
> 
> No, that is an different warning.  Why those types are different? Is this a full warning output?

.omp_data_s.7 is a name of a really unnamed struct (DECL_NAMELESS) and also
DECL_ARTIFICIAL, contains compiler generated fields and should never be
checked for ODR violations.

I wonder if you have any DECL_ARTIFICIAL structs you want to warn on, if
yes, then at least ignore DECL_NAMELESS ones.

	Jakub
Jan Hubicka March 30, 2015, 5:23 p.m. UTC | #7
> On Mon, Mar 30, 2015 at 07:06:39PM +0200, Jan Hubicka wrote:
> > > On Mon, Mar 30, 2015 at 05:02:57 +0200, Jan Hubicka wrote:
> > > > 	* lto-symtab.c (lto_symtab_merge_decls_2): Silence warnings on
> > > > 	artificial decls.
> > > 
> > > Shouldn't this patch fix libgomp.c++/target-3.C in an offloading-enabled
> > > configuration?  It still fails...
> > > 
> > > libgomp/testsuite/libgomp.c++/../libgomp.c/target-2.c:27:13: warning: type 'struct .omp_data_s.7' violates one definition rule [-Wodr]
> > >      #pragma omp parallel for reduction(+:s)
> > >              ^
> > >      #pragma omp parallel for reduction(+:s)
> > >              ^
> > >    double b[3 * x], c[3 * x], d[3 * x], e[3 * x];
> > >                  ^
> > >    double b[3 * x], c[3 * x], d[3 * x], e[3 * x];
> > >                  ^
> > 
> > No, that is an different warning.  Why those types are different? Is this a full warning output?
> 
> .omp_data_s.7 is a name of a really unnamed struct (DECL_NAMELESS) and also
> DECL_ARTIFICIAL, contains compiler generated fields and should never be
> checked for ODR violations.
> 
> I wonder if you have any DECL_ARTIFICIAL structs you want to warn on, if
> yes, then at least ignore DECL_NAMELESS ones.

Jason probably knows better, but I think only real C++ types comply the One Defintion
Type and should be merged. Anything we create artifically in compiler is probably
not covered by this.

Honza
> 
> 	Jakub
Jason Merrill March 30, 2015, 5:53 p.m. UTC | #8
On 03/30/2015 01:23 PM, Jan Hubicka wrote:
> Jason probably knows better, but I think only real C++ types comply the One Defintion
> Type and should be merged. Anything we create artifically in compiler is probably
> not covered by this.

Agreed, compiler internals are outside the scope of the language.  :)

Jason
diff mbox

Patch

Index: lto/lto-symtab.c
===================================================================
--- lto/lto-symtab.c	(revision 221757)
+++ lto/lto-symtab.c	(working copy)
@@ -473,7 +473,8 @@  lto_symtab_merge_decls_2 (symtab_node *f
     if (TREE_PUBLIC (e->decl))
       {
 	if (!lto_symtab_merge (prevailing, e)
-	    && !diagnosed_p)
+	    && !diagnosed_p
+	    && !DECL_ARTIFICIAL (e->decl))
 	  mismatches.safe_push (e->decl);
       }
   if (mismatches.is_empty ())