Commit c175aa77 by Richard Sandiford Committed by Richard Sandiford

Check for TYPE_DECL in get_odr_name_for_type

Make get_odr_name_for_type check for TYPE_DECL in the way that
its caller warn_types_mismatch previously did.

2019-12-10  Richard Sandiford  <richard.sandiford@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.

From-SVN: r279159
parent 8cf23a6f
2019-12-10 Richard Sandiford <richard.sandiford@arm.com>
* 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.
2019-12-10 Jakub Jelinek <jakub@redhat.com> 2019-12-10 Jakub Jelinek <jakub@redhat.com>
* config/i386/i386.c (IX86_LEA_PRIORITY): Fix comment typos. * config/i386/i386.c (IX86_LEA_PRIORITY): Fix comment typos.
...@@ -1042,7 +1042,7 @@ warn_types_mismatch (tree t1, tree t2, location_t loc1, location_t loc2) ...@@ -1042,7 +1042,7 @@ warn_types_mismatch (tree t1, tree t2, location_t loc1, location_t loc2)
{ {
const int opts = DMGL_PARAMS | DMGL_ANSI | DMGL_TYPES; const int opts = DMGL_PARAMS | DMGL_ANSI | DMGL_TYPES;
char *name1 = xstrdup (cplus_demangle (odr1, opts)); 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)) if (name1 && name2 && strcmp (name1, name2))
{ {
inform (loc_t1, inform (loc_t1,
......
...@@ -256,6 +256,7 @@ get_odr_name_for_type (tree type) ...@@ -256,6 +256,7 @@ get_odr_name_for_type (tree type)
{ {
tree type_name = TYPE_NAME (type); tree type_name = TYPE_NAME (type);
if (type_name == NULL_TREE if (type_name == NULL_TREE
|| TREE_CODE (type_name) != TYPE_DECL
|| !DECL_ASSEMBLER_NAME_SET_P (type_name)) || !DECL_ASSEMBLER_NAME_SET_P (type_name))
return NULL; return NULL;
......
2019-12-10 Richard Sandiford <richard.sandiford@arm.com>
* gcc.dg/lto/tag-1_0.c, gcc.dg/lto/tag-1_1.c: New test.
2019-12-10 Jakub Jelinek <jakub@redhat.com> 2019-12-10 Jakub Jelinek <jakub@redhat.com>
* gcc.target/i386/avx512f-vmovntpd-2.c: Ensure res is 64-byte aligned. * gcc.target/i386/avx512f-vmovntpd-2.c: Ensure res is 64-byte aligned.
......
/* { dg-lto-do link } */
/* { dg-lto-options { { -Wodr -flto } } } */
struct foo { int x; };
struct foo a = {};
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; }
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment