From: Jakub Jelinek Date: Mon, 21 Oct 2019 11:37:41 +0000 (+0200) Subject: backport: re PR lto/91572 (lto1: error: type variant has different ‘TREE_TYPE’ since... X-Git-Tag: releases/gcc-9.3.0~523 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=d8681a0f44e5d58a3cff3bddb870c1795bac28ec;p=thirdparty%2Fgcc.git backport: re PR lto/91572 (lto1: error: type variant has different ‘TREE_TYPE’ since r269862) Backported from mainline 2019-09-01 Jakub Jelinek PR lto/91572 * tree.c (find_decls_types_in_node): Also walk TREE_PURPOSE of GIMPLE_ASM TREE_LIST operands. * g++.dg/lto/pr91572_0.C: New test. From-SVN: r277245 --- diff --git a/gcc/ChangeLog b/gcc/ChangeLog index 7242fd804a16..3316996183b9 100644 --- a/gcc/ChangeLog +++ b/gcc/ChangeLog @@ -12,6 +12,12 @@ * match.pd (X / C1 op C2): Don't call unsigned_type_for on range_check_type result. + 2019-09-01 Jakub Jelinek + + PR lto/91572 + * tree.c (find_decls_types_in_node): Also walk TREE_PURPOSE of + GIMPLE_ASM TREE_LIST operands. + 2019-08-29 Jakub Jelinek PR tree-optimization/91351 diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog index 6b55e4372313..57e95b2b1aa1 100644 --- a/gcc/testsuite/ChangeLog +++ b/gcc/testsuite/ChangeLog @@ -1,6 +1,11 @@ 2019-10-21 Jakub Jelinek Backported from mainline + 2019-09-01 Jakub Jelinek + + PR lto/91572 + * g++.dg/lto/pr91572_0.C: New test. + 2019-08-29 Jakub Jelinek PR tree-optimization/91351 diff --git a/gcc/testsuite/g++.dg/lto/pr91572_0.C b/gcc/testsuite/g++.dg/lto/pr91572_0.C new file mode 100644 index 000000000000..95a7e9fabf51 --- /dev/null +++ b/gcc/testsuite/g++.dg/lto/pr91572_0.C @@ -0,0 +1,12 @@ +// PR lto/91572 +// { dg-lto-do link } +// { dg-lto-options { { -O -fPIC -flto } } } +// { dg-require-effective-target shared } +// { dg-require-effective-target fpic } +// { dg-extra-ld-options "-shared" } + +void foo (char); +namespace N { + class A { A (); }; + A::A () { asm ("" : : "g" (0)); } +} diff --git a/gcc/tree.c b/gcc/tree.c index 36ccdae37935..b20781ce00b0 100644 --- a/gcc/tree.c +++ b/gcc/tree.c @@ -6107,6 +6107,13 @@ find_decls_types_in_node (struct cgraph_node *n, struct free_lang_data_d *fld) { tree arg = gimple_op (stmt, i); find_decls_types (arg, fld); + /* find_decls_types doesn't walk TREE_PURPOSE of TREE_LISTs, + which we need for asm stmts. */ + if (arg + && TREE_CODE (arg) == TREE_LIST + && TREE_PURPOSE (arg) + && gimple_code (stmt) == GIMPLE_ASM) + find_decls_types (TREE_PURPOSE (arg), fld); } } }