> > > > 2019-12-09 Richard Sandiford <richard.sandif...@arm.com> > > > > gcc/ > > * ipa-utils.h (get_odr_name_for_type): Check for a TYPE_DECL. > > * ipa-devirt.c (warn_types_mismatch): Don't call xstrdup for the > > second demangled name. > > > > gcc/testsuite/ > > * gcc.dg/lto/tag-1_0.c, gcc.dg/lto/tag-1_1.c: New test.
OK, thanks Honza > > > > Index: gcc/ipa-utils.h > > =================================================================== > > --- gcc/ipa-utils.h 2019-12-09 12:23:47.000000000 +0000 > > +++ gcc/ipa-utils.h 2019-12-09 12:23:48.326292463 +0000 > > @@ -256,6 +256,7 @@ get_odr_name_for_type (tree type) > > { > > tree type_name = TYPE_NAME (type); > > if (type_name == NULL_TREE > > + || TREE_CODE (type_name) != TYPE_DECL > > || !DECL_ASSEMBLER_NAME_SET_P (type_name)) > > return NULL; > > Index: gcc/ipa-devirt.c > > =================================================================== > > --- gcc/ipa-devirt.c 2019-12-09 12:23:47.000000000 +0000 > > +++ gcc/ipa-devirt.c 2019-12-09 12:23:48.326292463 +0000 > > @@ -1042,7 +1042,7 @@ warn_types_mismatch (tree t1, tree t2, l > > { > > const int opts = DMGL_PARAMS | DMGL_ANSI | DMGL_TYPES; > > char *name1 = xstrdup (cplus_demangle (odr1, opts)); > > - char *name2 = xstrdup (cplus_demangle (odr2, opts)); > > + char *name2 = cplus_demangle (odr2, opts); > > if (name1 && name2 && strcmp (name1, name2)) > > { > > inform (loc_t1, > > Index: gcc/testsuite/gcc.dg/lto/tag-1_0.c > > =================================================================== > > --- /dev/null 2019-09-17 11:41:18.176664108 +0100 > > +++ gcc/testsuite/gcc.dg/lto/tag-1_0.c 2019-12-09 12:23:48.326292463 > > +0000 > > @@ -0,0 +1,5 @@ > > +/* { dg-lto-do link } */ > > +/* { dg-lto-options { { -Wodr -flto } } } */ > > + > > +struct foo { int x; }; > > +struct foo a = {}; > > Index: gcc/testsuite/gcc.dg/lto/tag-1_1.c > > =================================================================== > > --- /dev/null 2019-09-17 11:41:18.176664108 +0100 > > +++ gcc/testsuite/gcc.dg/lto/tag-1_1.c 2019-12-09 12:23:48.326292463 > > +0000 > > @@ -0,0 +1,6 @@ > > +struct foo { short x; }; > > + > > +extern struct foo a; /* { dg-lto-warning {type of 'a' does not match > > original declaration} } */ > > +struct foo *ptr = &a; > > + > > +int main () { return 0; } > > >