From 281a8e8b083e4bfd7635c02b991a833c140aa4cb Mon Sep 17 00:00:00 2001 From: hubicka Date: Tue, 19 Jun 2018 15:56:27 +0000 Subject: [PATCH] * tree.c (find_decls_types_r): Remove all non-VAR_DECLs from blocks. * g++.dg/lto/pr84805_0.C: Update template. * g++.dg/lto/pr84805_1.C: Update template. git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@261748 138bc75d-0d04-0410-961f-82ee72b054a4 --- gcc/ChangeLog | 5 +++++ gcc/testsuite/ChangeLog | 5 +++++ gcc/testsuite/g++.dg/lto/pr84805_0.C | 10 +++++----- gcc/testsuite/g++.dg/lto/pr84805_1.C | 4 ++-- gcc/tree.c | 25 ++++++++++++++++++++----- 5 files changed, 37 insertions(+), 12 deletions(-) diff --git a/gcc/ChangeLog b/gcc/ChangeLog index c4a48f068c7..4d59d2d1ee0 100644 --- a/gcc/ChangeLog +++ b/gcc/ChangeLog @@ -1,3 +1,8 @@ +2018-06-19 Jan Hubicka + + * tree.c (find_decls_types_r): Remove all non-VAR_DECLs from + blocks. + 2018-06-19 Martin Liska * config/i386/i386.c (ix86_can_inline_p): Do not use diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog index ca846009c6f..8aa3c65e200 100644 --- a/gcc/testsuite/ChangeLog +++ b/gcc/testsuite/ChangeLog @@ -1,3 +1,8 @@ +2018-06-19 Jan Hubicka + + * g++.dg/lto/pr84805_0.C: Update template. + * g++.dg/lto/pr84805_1.C: Update template. + 2018-06-19 Eric Botcazou * gnat.dg/aggr24.adb: New test. diff --git a/gcc/testsuite/g++.dg/lto/pr84805_0.C b/gcc/testsuite/g++.dg/lto/pr84805_0.C index eda0333fbb8..c9e00add79f 100644 --- a/gcc/testsuite/g++.dg/lto/pr84805_0.C +++ b/gcc/testsuite/g++.dg/lto/pr84805_0.C @@ -23,7 +23,7 @@ template < typename _Tp, _Lock_policy, bool = is_array< _Tp >::value, bool = is_void::value > class __shared_ptr_access {}; template < typename _Tp, _Lock_policy _Lp > -class __shared_ptr : __shared_ptr_access< _Tp, _Lp > { // { dg-lto-warning "7: type 'struct __shared_ptr' violates the C\\+\\+ One Definition Rule" } +class __shared_ptr : __shared_ptr_access< _Tp, _Lp > { using element_type = _Tp; element_type *_M_ptr; __shared_count< _Lp > _M_refcount; @@ -90,7 +90,7 @@ class ExtNameBuff; class ExtSheetBuffer; class ExcelToSc; class XclImpColRowSettings; -struct RootData { // { dg-lto-warning "8: type 'struct RootData' violates the C\\+\\+ One Definition Rule" } +struct RootData { BiffTyp eDateiTyp; ExtSheetBuffer *pExtSheetBuff; SharedFormulaBuffer *pShrfmlaBuff; @@ -105,7 +105,7 @@ class ScExtDocOptions; class XclFontPropSetHelper; class XclChPropSetHelper; class XclTracer; -struct XclRootData { // { dg-lto-warning "8: type 'struct XclRootData' violates the C\\+\\+ One Definition Rule" } +struct XclRootData { typedef std::shared_ptr< ScEditEngineDefaulter > ScEEDefaulterRef; typedef std::shared_ptr< ScHeaderEditEngine > ScHeaderEERef; typedef std::shared_ptr< EditEngine > EditEngineRef; @@ -141,12 +141,12 @@ struct XclRootData { // { dg-lto-warning "8: type 'struct XclRootData' violates RootDataRef mxRD; virtual ~XclRootData(); }; -class XclRoot { // { dg-lto-warning "7: type 'struct XclRoot' violates the C\\+\\+ One Definition Rule" } +class XclRoot { public: virtual ~XclRoot(); XclRootData &mrData; }; -class XclImpRoot : XclRoot {}; // { dg-lto-warning "7: type 'struct XclImpRoot' violates the C\\+\\+ One Definition Rule" } +class XclImpRoot : XclRoot {}; class XclImpColRowSettings : XclImpRoot {}; void lcl_ExportExcelBiff() { XclRootData aExpData(); diff --git a/gcc/testsuite/g++.dg/lto/pr84805_1.C b/gcc/testsuite/g++.dg/lto/pr84805_1.C index 2d8a45c001a..b1310b7c77c 100644 --- a/gcc/testsuite/g++.dg/lto/pr84805_1.C +++ b/gcc/testsuite/g++.dg/lto/pr84805_1.C @@ -1,9 +1,9 @@ -class XclRoot { +class XclRoot { // { dg-lto-warning "7: type 'struct XclRoot' violates the C\\+\\+ One Definition Rule" } public: virtual ~XclRoot(); }; class XclImpRoot : XclRoot {}; -struct RootData { +struct RootData { // { dg-lto-warning "8: type 'struct RootData' violates the C\\+\\+ One Definition Rule" } XclImpRoot pIR; }; class ExcRoot { diff --git a/gcc/tree.c b/gcc/tree.c index 889d88c50b4..3f75f7f9bfb 100644 --- a/gcc/tree.c +++ b/gcc/tree.c @@ -5173,7 +5173,10 @@ free_lang_data_in_type (tree type) /* Drop TYPE_DECLs in TYPE_NAME in favor of the identifier in the TYPE_DECL if the type doesn't have linkage. */ if (! type_with_linkage_p (type)) - TYPE_NAME (type) = TYPE_IDENTIFIER (type); + { + TYPE_NAME (type) = TYPE_IDENTIFIER (type); + TYPE_STUB_DECL (type) = NULL; + } } @@ -5556,10 +5559,22 @@ find_decls_types_r (tree *tp, int *ws, void *data) } else if (TREE_CODE (t) == BLOCK) { - tree tem; - for (tem = BLOCK_VARS (t); tem; tem = TREE_CHAIN (tem)) - fld_worklist_push (tem, fld); - for (tem = BLOCK_SUBBLOCKS (t); tem; tem = BLOCK_CHAIN (tem)) + for (tree *tem = &BLOCK_VARS (t); *tem; ) + { + if (TREE_CODE (*tem) != VAR_DECL + || !auto_var_in_fn_p (*tem, DECL_CONTEXT (*tem))) + { + gcc_assert (TREE_CODE (*tem) != RESULT_DECL + && TREE_CODE (*tem) != PARM_DECL); + *tem = TREE_CHAIN (*tem); + } + else + { + fld_worklist_push (*tem, fld); + tem = &TREE_CHAIN (*tem); + } + } + for (tree tem = BLOCK_SUBBLOCKS (t); tem; tem = BLOCK_CHAIN (tem)) fld_worklist_push (tem, fld); fld_worklist_push (BLOCK_ABSTRACT_ORIGIN (t), fld); } -- 2.11.4.GIT