mirror of
git://gcc.gnu.org/git/gcc.git
synced 2025-04-16 13:01:21 +08:00
Properly use TYPE_MAIN_VARIANT in warn_types_mismatch.
2019-11-28 Martin Liska <mliska@suse.cz> PR lto/92609 * ipa-devirt.c (warn_types_mismatch): Use TYPE_MAIN_VARIANT consistently. 2019-11-28 Martin Liska <mliska@suse.cz> PR lto/92609 * g++.dg/lto/pr92609_0.C: New test. * g++.dg/lto/pr92609_1.C: New test. From-SVN: r278819
This commit is contained in:
parent
3a95e31b34
commit
2fb2966c19
@ -1,3 +1,9 @@
|
||||
2019-11-28 Martin Liska <mliska@suse.cz>
|
||||
|
||||
PR lto/92609
|
||||
* ipa-devirt.c (warn_types_mismatch): Use TYPE_MAIN_VARIANT
|
||||
consistently.
|
||||
|
||||
2019-11-28 Jan Hubicka <hubicka@ucw.cz>
|
||||
|
||||
* ipa-inline.c (want_early_inline_function_p): Remove leftover optimize
|
||||
|
@ -986,21 +986,24 @@ warn_types_mismatch (tree t1, tree t2, location_t loc1, location_t loc2)
|
||||
|
||||
/* It is a quite common bug to reference anonymous namespace type in
|
||||
non-anonymous namespace class. */
|
||||
if ((type_with_linkage_p (TYPE_MAIN_VARIANT (t1))
|
||||
&& type_in_anonymous_namespace_p (TYPE_MAIN_VARIANT (t1)))
|
||||
|| (type_with_linkage_p (TYPE_MAIN_VARIANT (t2))
|
||||
&& type_in_anonymous_namespace_p (TYPE_MAIN_VARIANT (t2))))
|
||||
tree mt1 = TYPE_MAIN_VARIANT (t1);
|
||||
tree mt2 = TYPE_MAIN_VARIANT (t2);
|
||||
if ((type_with_linkage_p (mt1)
|
||||
&& type_in_anonymous_namespace_p (mt1))
|
||||
|| (type_with_linkage_p (mt2)
|
||||
&& type_in_anonymous_namespace_p (mt2)))
|
||||
{
|
||||
if (!type_with_linkage_p (TYPE_MAIN_VARIANT (t1))
|
||||
|| !type_in_anonymous_namespace_p (TYPE_MAIN_VARIANT (t1)))
|
||||
if (!type_with_linkage_p (mt1)
|
||||
|| !type_in_anonymous_namespace_p (mt1))
|
||||
{
|
||||
std::swap (t1, t2);
|
||||
std::swap (mt1, mt2);
|
||||
std::swap (loc_t1, loc_t2);
|
||||
}
|
||||
gcc_assert (TYPE_NAME (t1)
|
||||
&& TREE_CODE (TYPE_NAME (t1)) == TYPE_DECL);
|
||||
tree n1 = TYPE_NAME (t1);
|
||||
tree n2 = TYPE_NAME (t2) ? TYPE_NAME (t2) : NULL;
|
||||
gcc_assert (TYPE_NAME (mt1)
|
||||
&& TREE_CODE (TYPE_NAME (mt1)) == TYPE_DECL);
|
||||
tree n1 = TYPE_NAME (mt1);
|
||||
tree n2 = TYPE_NAME (mt2) ? TYPE_NAME (mt2) : NULL;
|
||||
|
||||
if (TREE_CODE (n1) == TYPE_DECL)
|
||||
n1 = DECL_NAME (n1);
|
||||
@ -1023,8 +1026,6 @@ warn_types_mismatch (tree t1, tree t2, location_t loc1, location_t loc2)
|
||||
"the incompatible type defined in another translation unit");
|
||||
return;
|
||||
}
|
||||
tree mt1 = TYPE_MAIN_VARIANT (t1);
|
||||
tree mt2 = TYPE_MAIN_VARIANT (t2);
|
||||
/* If types have mangled ODR names and they are different, it is most
|
||||
informative to output those.
|
||||
This also covers types defined in different namespaces. */
|
||||
|
@ -1,3 +1,9 @@
|
||||
2019-11-28 Martin Liska <mliska@suse.cz>
|
||||
|
||||
PR lto/92609
|
||||
* g++.dg/lto/pr92609_0.C: New test.
|
||||
* g++.dg/lto/pr92609_1.C: New test.
|
||||
|
||||
2019-11-28 Iain Sandoe <iain@sandoe.co.uk>
|
||||
|
||||
* gcc.target/i386/pr32219-2.c: Adjust scan-assembler entries
|
||||
|
88
gcc/testsuite/g++.dg/lto/pr92609_0.C
Normal file
88
gcc/testsuite/g++.dg/lto/pr92609_0.C
Normal file
@ -0,0 +1,88 @@
|
||||
// PR lto/92609
|
||||
// { dg-lto-do link }
|
||||
// { dg-lto-options { { -fPIC -flto } } }
|
||||
// { dg-require-effective-target shared }
|
||||
// { dg-require-effective-target fpic }
|
||||
// { dg-extra-ld-options "-shared" }
|
||||
|
||||
namespace std {
|
||||
inline namespace __cxx11 {}
|
||||
template < typename _Default > struct __detector { using type = _Default; };
|
||||
template < typename _Default, template < typename > class >
|
||||
using __detected_or = __detector< _Default >;
|
||||
template < typename _Default, template < typename > class _Op >
|
||||
using __detected_or_t = typename __detected_or< _Default, _Op >::type;
|
||||
template < typename > class allocator;
|
||||
template < class > struct char_traits;
|
||||
namespace __cxx11 {
|
||||
template < typename _CharT, typename = char_traits< _CharT >,
|
||||
typename = allocator< _CharT > >
|
||||
class basic_string;
|
||||
}
|
||||
struct __allocator_traits_base {
|
||||
template < typename _Tp > using __pointer = typename _Tp::pointer;
|
||||
};
|
||||
struct allocator_traits : __allocator_traits_base {
|
||||
using pointer = __detected_or_t< char *, __pointer >;
|
||||
};
|
||||
} // std
|
||||
struct rebind {
|
||||
typedef std::allocator_traits other;
|
||||
};
|
||||
namespace std {
|
||||
namespace __cxx11 {
|
||||
template < typename, typename, typename > class basic_string {
|
||||
struct _Alloc_hider {
|
||||
rebind::other::pointer _M_p;
|
||||
} _M_dataplus;
|
||||
unsigned long _M_string_length;
|
||||
enum { _S_local_capacity = 15 };
|
||||
union {
|
||||
char _M_local_buf[_S_local_capacity + 1];
|
||||
unsigned long _M_allocated_capacity;
|
||||
};
|
||||
};
|
||||
} // __cxx11
|
||||
template < typename _Tp > class __uniq_ptr_impl {
|
||||
template < typename _Up > struct _Ptr { using type = _Up *; };
|
||||
|
||||
public:
|
||||
using pointer = typename _Ptr< _Tp >::type;
|
||||
};
|
||||
template < typename _Tp > class unique_ptr {
|
||||
public:
|
||||
using pointer = typename __uniq_ptr_impl< _Tp >::pointer;
|
||||
unique_ptr(pointer);
|
||||
};
|
||||
} // std
|
||||
class wxRefCounter;
|
||||
class wxObject {
|
||||
virtual wxRefCounter CreateRefData();
|
||||
wxRefCounter *m_refData;
|
||||
};
|
||||
class wxGDIObject : wxObject {};
|
||||
class wxFontBase : wxGDIObject {};
|
||||
class wxFont : wxFontBase {};
|
||||
class VisualTool {
|
||||
protected:
|
||||
VisualTool(int *, int *);
|
||||
};
|
||||
class OpenGLText;
|
||||
class VisualToolCross : VisualTool {
|
||||
std::unique_ptr< OpenGLText > gl_text;
|
||||
VisualToolCross();
|
||||
};
|
||||
class OpenGLText { // { dg-lto-warning "7: type 'struct OpenGLText' violates the C\\+\\+ One Definition Rule" }
|
||||
float r, g, b, a;
|
||||
int fontSize;
|
||||
bool fontBold;
|
||||
bool fontItalics;
|
||||
std::basic_string< char > fontFace;
|
||||
wxFont font;
|
||||
int glyphs;
|
||||
};
|
||||
int VisualToolCross_parent;
|
||||
int VisualToolCross_context;
|
||||
VisualToolCross::VisualToolCross()
|
||||
: VisualTool(&VisualToolCross_parent, &VisualToolCross_context),
|
||||
gl_text(0) {}
|
58
gcc/testsuite/g++.dg/lto/pr92609_1.C
Normal file
58
gcc/testsuite/g++.dg/lto/pr92609_1.C
Normal file
@ -0,0 +1,58 @@
|
||||
namespace std {
|
||||
inline namespace __cxx11 {}
|
||||
template < typename _Default > struct __detector { using type = _Default; };
|
||||
template < typename _Default, template < typename > class >
|
||||
using __detected_or = __detector< _Default >;
|
||||
template < typename _Default, template < typename > class _Op >
|
||||
using __detected_or_t = typename __detected_or< _Default, _Op >::type;
|
||||
template < typename > class allocator;
|
||||
template < class > struct char_traits;
|
||||
namespace __cxx11 {
|
||||
template < typename _CharT, typename = char_traits< _CharT >,
|
||||
typename = allocator< _CharT > >
|
||||
class basic_string;
|
||||
}
|
||||
struct __allocator_traits_base {
|
||||
template < typename _Tp > using __pointer = typename _Tp::pointer;
|
||||
};
|
||||
struct allocator_traits : __allocator_traits_base {
|
||||
using pointer = __detected_or_t< char *, __pointer >;
|
||||
};
|
||||
namespace __cxx11 {
|
||||
template < typename, typename, typename > class basic_string {
|
||||
struct _Alloc_hider {
|
||||
allocator_traits::pointer _M_p;
|
||||
} _M_dataplus;
|
||||
unsigned long _M_string_length;
|
||||
enum { _S_local_capacity = 15 };
|
||||
union {
|
||||
char _M_local_buf[_S_local_capacity + 1];
|
||||
unsigned long _M_allocated_capacity;
|
||||
};
|
||||
};
|
||||
} // __cxx11
|
||||
} // std
|
||||
class wxRefCounter;
|
||||
class wxObject {
|
||||
virtual int GetClassInfo();
|
||||
wxRefCounter *m_refData;
|
||||
};
|
||||
class wxGDIObject : wxObject {};
|
||||
class wxFontBase : wxGDIObject {};
|
||||
class wxFont : wxFontBase {};
|
||||
template < class > class map {};
|
||||
namespace {
|
||||
struct OpenGLTextGlyph;
|
||||
}
|
||||
typedef map< OpenGLTextGlyph > glyphMap;
|
||||
class OpenGLText {
|
||||
float r, g, b, a;
|
||||
int fontSize;
|
||||
bool fontBold;
|
||||
bool fontItalics;
|
||||
std::basic_string< char > fontFace;
|
||||
wxFont font;
|
||||
glyphMap glyphs;
|
||||
OpenGLText();
|
||||
};
|
||||
OpenGLText::OpenGLText() {}
|
Loading…
x
Reference in New Issue
Block a user