diff options
Diffstat (limited to 'gcc/testsuite/g++.dg/lto')
26 files changed, 1267 insertions, 1 deletions
diff --git a/gcc/testsuite/g++.dg/lto/lto.exp b/gcc/testsuite/g++.dg/lto/lto.exp index 4d7d727b98..f165362227 100644 --- a/gcc/testsuite/g++.dg/lto/lto.exp +++ b/gcc/testsuite/g++.dg/lto/lto.exp @@ -1,4 +1,4 @@ -# Copyright (C) 2009-2014 Free Software Foundation, Inc. +# Copyright (C) 2009-2015 Free Software Foundation, Inc. # This program is free software; you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by diff --git a/gcc/testsuite/g++.dg/lto/pr54625-1_0.c b/gcc/testsuite/g++.dg/lto/pr54625-1_0.c index 5ab90dddde..48bbdf02de 100644 --- a/gcc/testsuite/g++.dg/lto/pr54625-1_0.c +++ b/gcc/testsuite/g++.dg/lto/pr54625-1_0.c @@ -3,6 +3,7 @@ float a; double sin (); +void speex_resampler_init_frac () { a = sin (0); diff --git a/gcc/testsuite/g++.dg/lto/pr54625-2_0.c b/gcc/testsuite/g++.dg/lto/pr54625-2_0.c index 6511ba5cc6..3e67d4f5b4 100644 --- a/gcc/testsuite/g++.dg/lto/pr54625-2_0.c +++ b/gcc/testsuite/g++.dg/lto/pr54625-2_0.c @@ -3,6 +3,7 @@ float a; double sin (); +void update_filter () { a = sin (0); diff --git a/gcc/testsuite/g++.dg/lto/pr63166_0.ii b/gcc/testsuite/g++.dg/lto/pr63166_0.ii new file mode 100644 index 0000000000..f8ef712086 --- /dev/null +++ b/gcc/testsuite/g++.dg/lto/pr63166_0.ii @@ -0,0 +1,37 @@ +// { dg-lto-do compile } +extern "C" +{ + extern long unsigned int strlen (__const char *__s); +} +class Cstring +{ +}; +class Foobar_Out +{ + virtual void put_to_buf (const char *str, long unsigned int msg_len); + void put_to_buf (const char *str) + { + put_to_buf (str, strlen (str)); + } + Foobar_Out & operator << (const char *str); + Foobar_Out & operator << (const Cstring & cstring); +}; + +class Foobar_Log:public Foobar_Out +{ + Foobar_Log (int channel); + virtual void put_to_buf (const char *str, long unsigned int msg_len); +}; +Foobar_Out & Foobar_Out::operator << (const char *str) +{ + put_to_buf (str); +} + +Foobar_Out & Foobar_Out::operator << (const Cstring & cstring) +{ + return *this; +} + +Foobar_Log::Foobar_Log (int ch) +{ +} diff --git a/gcc/testsuite/g++.dg/lto/pr63166_1.ii b/gcc/testsuite/g++.dg/lto/pr63166_1.ii new file mode 100644 index 0000000000..29438fe5ed --- /dev/null +++ b/gcc/testsuite/g++.dg/lto/pr63166_1.ii @@ -0,0 +1,108 @@ +class EIdent { }; +class Cstring { }; +template < class KEY, class VALUE, class HASHER > class HashMapIterator +{ +public: + virtual ~ HashMapIterator () { } +}; + +class ECell; +class ECell_ptr +{ + ECell *mp_element; +public: + ECell * operator -> () const + { + return (mp_element); + } +} +sicat_cmd_status; +class CellListIterator; +class ECellList +{ +public: + virtual CellListIterator * createIterator () const = 0; + virtual ECell_ptr Find (const EIdent & anIdent) = 0; +}; +class Foobar_Out +{ + virtual int get_channel () { } +public: + Foobar_Out & operator << (const char *str); + Foobar_Out & operator << (const Cstring & cstring); +}; + +class Foobar_Log:public Foobar_Out { }; +extern Foobar_Log Foobar_LOG; +template < class KEY > class BagIterator +{ +public: + inline const KEY & operator * () const; + inline int atEnd () const; +}; + +class EMaskView; +class ECell +{ +public: + virtual const EMaskView & getMaskView () const = 0; +}; +class FoobarDatabase +{ +public: + const Cstring & getName (const EIdent & id) const; + ECellList *getCellList (); +}; +inline FoobarDatabase & +DB () { } + +class EMaskView +{ +public: + inline BagIterator < EIdent > getCallerIterator () const; +}; +struct DBHashFunctions +{ +}; +class CellListIterator:public HashMapIterator < EIdent, ECell *, + DBHashFunctions > +{ +}; +class IdentSet +{ +public: + unsigned int getSize () const { } + int isEmpty () const { } +}; +class IdentSetIterator +{ +public: + IdentSetIterator (const IdentSet * p_source) { } + int atEnd () const { } + EIdent operator* () const { } +}; +void +validate () +{ + IdentSet complete_cell_ids; + IdentSet incomplete_cell_ids; + CellListIterator *p_cl_it = DB ().getCellList ()->createIterator (); + delete p_cl_it; + while (!incomplete_cell_ids.isEmpty ()) + { + if (incomplete_cell_ids.getSize () < complete_cell_ids.getSize ()) + { + IdentSetIterator complete_cell_it (&complete_cell_ids); + while (!complete_cell_it.atEnd ()) + { + BagIterator < EIdent > caller_it = + DB ().getCellList ()->Find (*complete_cell_it)-> + getMaskView ().getCallerIterator (); + while (!caller_it.atEnd ()) + { + Foobar_LOG << DB ().getName (*caller_it) << " "; + } + } + } + } +} diff --git a/gcc/testsuite/g++.dg/lto/pr63270.h b/gcc/testsuite/g++.dg/lto/pr63270.h new file mode 100644 index 0000000000..a0a0f58370 --- /dev/null +++ b/gcc/testsuite/g++.dg/lto/pr63270.h @@ -0,0 +1,68 @@ +typedef unsigned long uintptr_t; +namespace v8 { +class Extension; +namespace internal { +class A { +public: + A(int) {}; +}; +class B { +public: + B(int) {}; +}; +class Scanner; +class FuncNameInferrer; +template <typename Traits> class ParserBase : Traits { + class FunctionState; + bool parenthesized_function_; + typename Traits::Type::Scope *scope_; + FunctionState *function_state_; + v8::Extension *extension_; + FuncNameInferrer *fni_; + Scanner *scanner_; + uintptr_t stack_limit_; + bool stack_overflow_; + bool allow_lazy_; + bool allow_natives_syntax_; + bool allow_generators_; + bool allow_for_of_; + typename Traits::Type::Zone *zone_; +}; +class PreParserScope; +class F; +class PreParserTraits { +public: + struct Type { + typedef PreParserScope Scope; + typedef void Zone; + }; + +private: + F *pre_parser_; +}; +class F : ParserBase<PreParserTraits> {}; +class C { +public: + struct Type { + typedef v8::internal::FuncNameInferrer Scope; + typedef int Zone; + }; +}; +class G : ParserBase<C> { +public: + static int m_fn1(); + static int test(); + F reusable_preparser_; +}; +class D { +public: + D(int a) : function_(0), context_(0), nested_scope_chain_(0) { G::test(); } + B function_; + B context_; + A nested_scope_chain_; +}; +} +} + + + diff --git a/gcc/testsuite/g++.dg/lto/pr63270_0.C b/gcc/testsuite/g++.dg/lto/pr63270_0.C new file mode 100644 index 0000000000..924b238499 --- /dev/null +++ b/gcc/testsuite/g++.dg/lto/pr63270_0.C @@ -0,0 +1,9 @@ +// { dg-lto-do link } +// { dg-lto-options {{-flto -O2 -Wno-odr}} } + +#include "pr63270.h" + +int main() +{ + return 0; +} diff --git a/gcc/testsuite/g++.dg/lto/pr63270_1.C b/gcc/testsuite/g++.dg/lto/pr63270_1.C new file mode 100644 index 0000000000..a842e5cfcc --- /dev/null +++ b/gcc/testsuite/g++.dg/lto/pr63270_1.C @@ -0,0 +1,53 @@ +typedef unsigned long uintptr_t; +namespace v8 +{ + + int kPointerSize = 0; + + class Extension; + namespace internal + { + class Token; + class Scanner; + int kCodeOffset = 0; + int kOptimizedCodeMapOffset = 0; + int kScopeInfoOffset = 0; + + class FuncNameInferrer; + template < typename Traits > class ParserBase:Traits + { + class FunctionState; + bool parenthesized_function_; + typename Traits::Type::Scope * scope_; + FunctionState *function_state_; + v8::Extension * extension_; + FuncNameInferrer *fni_; + Scanner *scanner_; + uintptr_t stack_limit_; + bool stack_overflow_; + bool allow_lazy_; + bool allow_natives_syntax_; + bool allow_generators_; + bool allow_for_of_; + typename Traits::Type::Zone * zone_; + }; + class PreParserScope; + class PreParser; + class PreParserTraits + { + public:struct Type + { + typedef PreParserScope Scope; + typedef void Zone; + }; + PreParser *pre_parser_; + }; + class PreParser:ParserBase < PreParserTraits > + { + int ParseMemberWithNewPrefixesExpression ( bool * ); + }; + int PreParser::ParseMemberWithNewPrefixesExpression ( bool * ) + { + } + } +} diff --git a/gcc/testsuite/g++.dg/lto/pr63270_2.C b/gcc/testsuite/g++.dg/lto/pr63270_2.C new file mode 100644 index 0000000000..e45ae68602 --- /dev/null +++ b/gcc/testsuite/g++.dg/lto/pr63270_2.C @@ -0,0 +1,8 @@ +// { dg-options "-fno-lto" } + +#include "pr63270.h" + +int v8::internal::G::test() +{ + return 2; +} diff --git a/gcc/testsuite/g++.dg/lto/pr64043_0.C b/gcc/testsuite/g++.dg/lto/pr64043_0.C new file mode 100644 index 0000000000..9cc5596c35 --- /dev/null +++ b/gcc/testsuite/g++.dg/lto/pr64043_0.C @@ -0,0 +1,14 @@ +// { dg-lto-do link } +// { dg-lto-options { { -flto -std=c++11 } } } +// { dg-extra-ld-options "-r -nostdlib -O2" } +class Validator +{ +public: + virtual ~Validator (); +}; +class FooWriter +{ + Validator *validator; + ~FooWriter (); +}; +FooWriter::~FooWriter () { delete validator; } diff --git a/gcc/testsuite/g++.dg/lto/pr64076.H b/gcc/testsuite/g++.dg/lto/pr64076.H new file mode 100644 index 0000000000..6afe37acc9 --- /dev/null +++ b/gcc/testsuite/g++.dg/lto/pr64076.H @@ -0,0 +1,20 @@ +struct Base { + virtual void f() = 0; +}; + +struct X : public Base { }; +struct Y : public Base { }; +struct Z : public Base { }; +struct T : public Base { }; + +struct S : public X, public Y, public Z +#ifdef XXX +, public T +#endif +{ + void f() +#ifdef XXX + { } +#endif + ; +}; diff --git a/gcc/testsuite/g++.dg/lto/pr64076_0.C b/gcc/testsuite/g++.dg/lto/pr64076_0.C new file mode 100644 index 0000000000..fb9b060e32 --- /dev/null +++ b/gcc/testsuite/g++.dg/lto/pr64076_0.C @@ -0,0 +1,10 @@ +// { dg-lto-do link } + +#define XXX +#include "pr64076.H" + +int main() +{ + S s; + return 0; +} diff --git a/gcc/testsuite/g++.dg/lto/pr64076_1.C b/gcc/testsuite/g++.dg/lto/pr64076_1.C new file mode 100644 index 0000000000..4bd00817b1 --- /dev/null +++ b/gcc/testsuite/g++.dg/lto/pr64076_1.C @@ -0,0 +1,5 @@ +// { dg-options -fno-lto } + +#include "pr64076.H" + +void S::f() { } diff --git a/gcc/testsuite/g++.dg/lto/pr65193_0.C b/gcc/testsuite/g++.dg/lto/pr65193_0.C new file mode 100644 index 0000000000..d778fcabb7 --- /dev/null +++ b/gcc/testsuite/g++.dg/lto/pr65193_0.C @@ -0,0 +1,71 @@ +/* { dg-lto-do link } */ +/* { dg-require-effective-target fpic } */ +/* { dg-lto-options {{-fPIC -r -nostdlib -flto -O2 -g}} } */ + +void frexp (int, int *); +namespace std +{ + int ldexp (int, int); + struct A + { + }; + template <class T> T get_min_shift_value (); + template <class> struct min_shift_initializer + { + struct B + { + B () { get_min_shift_value<long double> (); } + } static const b; + static void + m_fn1 () + { + b; + } + }; + template <class T> + const typename min_shift_initializer<T>::B min_shift_initializer<T>::b; + template <class T> + inline T + get_min_shift_value () + { + using std::ldexp; + static T c = ldexp (0, 0); + min_shift_initializer<T>::m_fn1; + } + template <class T, class Policy> + void + float_next_imp (T p1, Policy p2) + { + using std::ldexp; + int d; + float_next (0, p2); + frexp (p1, &d); + } + template <class T, class Policy> + int + float_next (const T &p1, Policy &p2) + { + float_next_imp (p1, p2); + } + template <class T, class Policy> void float_prior_imp (T, Policy) + { + get_min_shift_value<T> (); + } + template <class T, class Policy> int float_prior (T, Policy) + { + float_prior_imp (static_cast<T> (0), 0); + } + template <class T, class U, class Policy> + void + nextafter (T p1, U p2, Policy p3) + { + p2 ? float_next (0, p3) : float_prior (p1, 0); + } + long double e; + int f; + void + nextafter () + { + nextafter (e, f, A ()); + } +} diff --git a/gcc/testsuite/g++.dg/lto/pr65276_0.C b/gcc/testsuite/g++.dg/lto/pr65276_0.C new file mode 100644 index 0000000000..c8e96999dc --- /dev/null +++ b/gcc/testsuite/g++.dg/lto/pr65276_0.C @@ -0,0 +1,61 @@ +// { dg-lto-do link } +// { dg-lto-options {{-flto -O0 -std=c++11}} } + +/* pr65276_0.C should get compiled with -O0, while the _1.C file + should get compiled with -O2, and the entire thing should be linked + with -O0. Test that we don't get an ICE. */ + +extern "C++" +{ + namespace std + { + class exception + { + public: + virtual ~ exception () noexcept; + }; + } +} +namespace std +{ + struct __cow_string + { + union + { + const char *_M_p; + char _M_bytes[sizeof (const char *)]; + }; + }; + class runtime_error:public exception + { + __cow_string _M_msg; + }; +} +namespace std +{ + class system_error:public std::runtime_error + { + }; + enum _Ios_Fmtflags + { + }; + inline constexpr _Ios_Fmtflags operator& (_Ios_Fmtflags __a, + _Ios_Fmtflags __b) + { + return _Ios_Fmtflags (); + } + enum _Ios_Openmode + { + }; + class ios_base + { + public: + class __attribute ((__abi_tag__ ("cxx11"))) failure:public system_error + { + }; + class Init + { + }; + }; + static ios_base::Init __ioinit; +} diff --git a/gcc/testsuite/g++.dg/lto/pr65276_1.C b/gcc/testsuite/g++.dg/lto/pr65276_1.C new file mode 100644 index 0000000000..ee49752f0f --- /dev/null +++ b/gcc/testsuite/g++.dg/lto/pr65276_1.C @@ -0,0 +1,34 @@ +// { dg-options "-O2" } +#pragma implementation +#pragma interface +extern "C++" +{ + namespace std + { + class exception + { + public: + virtual ~ exception () noexcept; + }; + } +} +namespace std +{ + struct __cow_string + { + union + { + const char *_M_p; + char _M_bytes[sizeof (const char *)]; + }; + }; + class runtime_error:public exception + { + __cow_string _M_msg; + }; +} + +int main() +{ + return 0; +} diff --git a/gcc/testsuite/g++.dg/lto/pr65302_0.C b/gcc/testsuite/g++.dg/lto/pr65302_0.C new file mode 100644 index 0000000000..2298afd9d9 --- /dev/null +++ b/gcc/testsuite/g++.dg/lto/pr65302_0.C @@ -0,0 +1,99 @@ +// { dg-lto-do link } +// { dg-lto-options { { -flto -O2 } } } +// { dg-extra-ld-options "-r -nostdlib -O0" } + +class CstringStorageReference { + public: + ~CstringStorageReference (); +}; +class Cstring { + CstringStorageReference m_stringRef; + public: + Cstring (const char *str, int l = 0); + unsigned int getLength () const; +}; +class ZEvent_Component { }; +class ZEvent_Data { }; +class ZEvent_Interrupt { }; +class ZEvent_Mouse { }; +class ZEvent_Key { }; +class ZEventHandler { + virtual void HandleEvent (const ZEvent_Component & event); + virtual void HandleEvent (const ZEvent_Mouse & event); + virtual void HandleEvent (const ZEvent_Key & event); + virtual void HandleEvent (const ZEvent_Interrupt & event); + virtual void HandleEvent (const ZEvent_Data & event); +}; +enum ZHorizontalAlignment { HA_Left }; +enum ZVerticalAlignment { VA_Baseline }; +struct ZDevicePointStruct { }; +struct ZDeviceRectangleStruct { }; +struct ZDeviceCircleStruct { }; +class ZOutputDevice; +class Foo; +class ZRubberBand { + public: + ZOutputDevice * getOutputDevice (); +}; +class ZRubberBand2P : public ZRubberBand { + virtual void Init (); + Foo *mp_graphicContext; + int m_textAscent; + int m_OkButtonWidth; + int m_OkButtonHeight; +}; +class ZColor { }; +class ZViewPort2D { }; +class ZCursor; +class ZPixmap; +class ZOutputDevice:public ZEventHandler { +public: + typedef ZHorizontalAlignment THorizontalAlignment; + typedef ZVerticalAlignment TVerticalAlignment; + virtual const char *MyName () const { return ""; } + virtual ~ ZOutputDevice (); + virtual Cstring getTitle () const; + virtual void setTitle (const Cstring &) { } + virtual void Init (); + virtual void shutdown (); + virtual void minimize (); + virtual void normalize (); + virtual void raiseToTop (); + virtual ZViewPort2D GetViewPort () const; + virtual void setBackgroundColor (const ZColor & color) = 0; + virtual void Clear () = 0; + virtual void Flush (int forced) = 0; + virtual void dismissCache () { } + virtual int GetDeviceWidth () const = 0; + virtual int GetDeviceHeight () const = 0; + virtual Foo *CreateGraphicContext () = 0; + virtual ZCursor *createCursor (const ZPixmap &, int, int) { return __null; } + virtual void DrawLine (const Foo & gc, int x1, int y1, int x2, int y2) = 0; + virtual void DrawLines (const Foo & gc, const ZDevicePointStruct * points, unsigned int count) = 0; + virtual void FillPolygon (const Foo & gc, const ZDevicePointStruct * points, unsigned int count) = 0; + virtual void DrawPoint (const Foo & gc, int x1, int y1) = 0; + virtual void DrawPoints (const Foo & gc, const ZDevicePointStruct * points, unsigned int count) = 0; + virtual void DrawRectangle (const Foo & gc, int x, int y, int width, int height) = 0; + virtual void DrawRectangles (const Foo & gc, const ZDeviceRectangleStruct * rectangles, unsigned int count) = 0; + virtual void FillRectangle (const Foo & gc, int x, int y, int width, int height) = 0; + virtual void FillRectangles (const Foo & gc, const ZDeviceRectangleStruct * rectangles, unsigned int count) = 0; + virtual void DrawCircle (const Foo & gc, int x, int y, int radius) = 0; + virtual void DrawCircles (const Foo & gc, const ZDeviceCircleStruct * circle, unsigned int count) = 0; + virtual void FillCircle (const Foo & gc, int x, int y, int radius) = 0; + virtual void FillCircles (const Foo & gc, const ZDeviceCircleStruct * circle, unsigned int count) = 0; + virtual void DrawString (const Foo & gc, int xx, int yy, const Cstring & theString, THorizontalAlignment horAlign = HA_Left, TVerticalAlignment verAlign = VA_Baseline) = 0; + virtual void getStringBounds (const Foo & gc, const Cstring & theString, int & width, int & height, int & ascent) const; +}; +template < class T > class EMaskContentVector +{ + signed m_freelist_idx:32; + EMaskContentVector (const EMaskContentVector < T > &, void *buf); +}; +template < class T > EMaskContentVector < + T >::EMaskContentVector (const EMaskContentVector < T > &elem, void *buf): +m_freelist_idx (-1) +{ +} +void ZRubberBand2P::Init () { + getOutputDevice ()->getStringBounds (*mp_graphicContext, Cstring ("Ok"), m_OkButtonWidth, m_OkButtonHeight, m_textAscent); +} diff --git a/gcc/testsuite/g++.dg/lto/pr65302_1.C b/gcc/testsuite/g++.dg/lto/pr65302_1.C new file mode 100644 index 0000000000..b2ccc2a90b --- /dev/null +++ b/gcc/testsuite/g++.dg/lto/pr65302_1.C @@ -0,0 +1,83 @@ +#pragma implementation +#pragma interface +class CstringStorageReference { + public: + ~CstringStorageReference (); +}; +class Cstring { + CstringStorageReference m_stringRef; + public: + Cstring (const char *str, int l = 0); + unsigned int getLength () const; +}; +inline unsigned int +Cstring::getLength () const { }; +class ZEvent_Component { }; +class ZEvent_Data { }; +class ZEvent_Interrupt { }; +class ZEvent_Mouse { }; +class ZEvent_Key { }; +class ZEventHandler +{ + virtual void HandleEvent (const ZEvent_Component & event); + virtual void HandleEvent (const ZEvent_Mouse & event); + virtual void HandleEvent (const ZEvent_Key & event); + virtual void HandleEvent (const ZEvent_Interrupt & event); + virtual void HandleEvent (const ZEvent_Data & event); +}; +class ZColor { }; +class ZViewPort2D { }; +enum ZVerticalAlignment { VA_Baseline }; +struct ZDevicePointStruct { }; +class ZCursor; +class ZPixmap; +class Foo; +class ZOutputDevice : public ZEventHandler { + public: + typedef ZVerticalAlignment TVerticalAlignment; + virtual const char *MyName () const { } + virtual ~ ZOutputDevice (); + virtual Cstring getTitle () const; + virtual void setTitle (const Cstring &) { } + virtual void Init (); + virtual void shutdown (); + virtual void minimize (); + virtual void normalize (); + virtual void raiseToTop (); + virtual ZViewPort2D GetViewPort () const; + virtual void setBackgroundColor (const ZColor & color) = 0; + virtual void Clear () = 0; + virtual void Flush (int forced) = 0; + virtual void dismissCache () { } + virtual int GetDeviceWidth () const = 0; + virtual int GetDeviceHeight () const = 0; + virtual Foo *CreateGraphicContext () = 0; + virtual ZCursor *createCursor (const ZPixmap &, int, int) { } + virtual void DrawLine (const Foo & gc, int x1, int y2) = 0; + virtual void DrawLines (const Foo & gc, const ZDevicePointStruct * points, + unsigned int count) = 0; +}; +class ZOutputDevicePS :public ZOutputDevice +{ + virtual void FillPolygon (const Foo & gc, unsigned int count); + virtual void DrawPoint (const Foo & gc, int x1, int y1); + virtual void DrawPoints (const Foo & gc, const ZDevicePointStruct * points, + unsigned int count); + virtual void DrawRectangle (const Foo & gc, int x, int height); + virtual void DrawRectangles (const Foo & gc, unsigned int count); + virtual void FillRectangle (const Foo & gc, int x, int height); + virtual void FillRectangles (const Foo & gc, unsigned int count); + virtual void DrawCircle (const Foo & gc, int x, int y, int radius); + virtual void DrawCircles (const Foo & gc, unsigned int count); + virtual void FillCircle (const Foo & gc, int x, int y, int radius); + virtual void FillCircles (const Foo & gc, unsigned int count); + virtual void DrawString (const Foo & gc, int xx, int yy, + TVerticalAlignment verAlign); + virtual void getStringBounds (const Foo & gc, const Cstring & theString, + int & width, int & height, int & acsent) const; +}; +void +ZOutputDevicePS::getStringBounds (const Foo &, const Cstring & theString, + int & width, int & height, int & ascent) const { + width = theString.getLength () * 8; +} diff --git a/gcc/testsuite/g++.dg/lto/pr65316_0.C b/gcc/testsuite/g++.dg/lto/pr65316_0.C new file mode 100644 index 0000000000..cccd0db7d8 --- /dev/null +++ b/gcc/testsuite/g++.dg/lto/pr65316_0.C @@ -0,0 +1,142 @@ +// { dg-lto-do link } +// { dg-lto-options { { -flto -std=c++11 -g2 -fno-lto-odr-type-merging -O2 } } } +// { dg-extra-ld-options "-r -nostdlib -O2 -fno-lto-odr-type-merging" } +namespace std +{ + typedef long unsigned int size_t; +} +extern "C" +{ + typedef struct + { + } __mbstate_t; +} +namespace std __attribute__ ((__visibility__ ("default"))) +{ + template < class _CharT > struct char_traits; +} + +typedef __mbstate_t mbstate_t; +namespace std __attribute__ ((__visibility__ ("default"))) +{ + template < typename _CharT, typename _Traits = + char_traits < _CharT > >class basic_ostream; + typedef basic_ostream < char >ostream; +} + +using namespace std; +class Cstring +{ +public: + Cstring (const char *str, int l = 0); +}; +extern ostream & operator << (ostream & os, const Cstring & string); +class Foo_Log_Handler +{ + virtual int write_message (const char *msg, size_t msg_len, int channel, + int level) = 0; +}; +class Foo_Log_Handler_Stream:public Foo_Log_Handler +{ + virtual int write_message (const char *msg, size_t msg_len, int channel, + int level) override; + Cstring m_filename; +}; +namespace std __attribute__ ((__visibility__ ("default"))) +{ + template <> struct char_traits <char > + { + typedef mbstate_t state_type; + }; + enum _Ios_Fmtflags + { + }; + enum _Ios_Iostate + { + }; + class ios_base + { + public: + typedef _Ios_Iostate iostate; + }; +} + +namespace std __attribute__ ((__visibility__ ("default"))) +{ + template < typename _CharT > class __ctype_abstract_base + { + }; + template < typename _CharT > class ctype + { + public: + typedef char char_type; + mutable char _M_widen_ok; + char_type widen (char __c) const + { + if (_M_widen_ok) + return this->do_widen (__c); + } + virtual char_type do_widen (char __c) const + { + } + }; + template < typename _Facet > + inline const _Facet & __check_facet (const _Facet * __f) + { + } +template < typename _CharT, typename _Traits > class basic_ios:public + ios_base + { + typedef _CharT char_type; + typedef ctype < _CharT > __ctype_type; + const __ctype_type *_M_ctype; + public: + iostate rdstate ()const + { + } + bool good () const + { + } + char_type widen (char __c) const + { + return __check_facet (_M_ctype).widen (__c); + } + }; +template < typename _CharT, typename _Traits > class basic_ostream:virtual public basic_ios < _CharT, + _Traits + > + { + public: + typedef _CharT char_type; + typedef _Traits traits_type; + typedef basic_ostream < _CharT, _Traits > __ostream_type; + __ostream_type & operator<< (__ostream_type & (*__pf) (__ostream_type &)) + { + return __pf (*this); + } + __ostream_type & put (char_type __c); + }; + template < typename _CharT, + typename _Traits > inline basic_ostream < _CharT, + _Traits > &endl (basic_ostream < _CharT, _Traits > &__os) + { + return flush (__os.put (__os.widen ('\n'))); + } + template < typename _CharT, + typename _Traits > inline basic_ostream < _CharT, + _Traits > &flush (basic_ostream < _CharT, _Traits > &__os) + { + } + extern ostream cerr; +} + +int +Foo_Log_Handler_Stream::write_message (const char *msg, size_t msg_len, int, + int level) +{ + { + { + cerr << "FATAL: cannot write into log file: " << m_filename << endl; + } + } +} diff --git a/gcc/testsuite/g++.dg/lto/pr65316_1.C b/gcc/testsuite/g++.dg/lto/pr65316_1.C new file mode 100644 index 0000000000..e69de29bb2 --- /dev/null +++ b/gcc/testsuite/g++.dg/lto/pr65316_1.C diff --git a/gcc/testsuite/g++.dg/lto/pr65475_0.C b/gcc/testsuite/g++.dg/lto/pr65475_0.C new file mode 100644 index 0000000000..3c8665c92a --- /dev/null +++ b/gcc/testsuite/g++.dg/lto/pr65475_0.C @@ -0,0 +1,9 @@ +/* { dg-lto-do link } */ +/* { dg-lto-options "-O2 -Wno-odr" } */ +/* { dg-extra-ld-options { -O2 -Wno-odr -r -nostdlib } } */ +namespace std { +class ios_base { + struct A {}; + class __attribute((__abi_tag__("cxx11"))) failure : A {}; +} a; +} diff --git a/gcc/testsuite/g++.dg/lto/pr65475_1.C b/gcc/testsuite/g++.dg/lto/pr65475_1.C new file mode 100644 index 0000000000..642a4137f2 --- /dev/null +++ b/gcc/testsuite/g++.dg/lto/pr65475_1.C @@ -0,0 +1,27 @@ +namespace std { +template <typename, typename = int> class Trans_NS___cxx11_basic_ostringstream; +class ios_base { + class __attribute((__abi_tag__("cxx11"))) failure { + virtual char m_fn2(); + }; +}; +class B : virtual ios_base {}; +template <typename, typename> class Trans_NS___cxx11_basic_ostringstream : B { +public: + void m_fn1(); +}; +} + +class A { +public: + A(int) { + std::Trans_NS___cxx11_basic_ostringstream<wchar_t> a; + a.m_fn1(); + } +}; +int b; +void fn1() { (A(b)); } +int +main() +{ +} diff --git a/gcc/testsuite/g++.dg/lto/pr65475b_0.C b/gcc/testsuite/g++.dg/lto/pr65475b_0.C new file mode 100644 index 0000000000..0e5a95c8ee --- /dev/null +++ b/gcc/testsuite/g++.dg/lto/pr65475b_0.C @@ -0,0 +1,9 @@ +/* { dg-lto-do link } */ +/* { dg-lto-options "-O2 -Wno-odr" } */ +/* { dg-extra-ld-options { -O2 -Wno-odr -r -nostdlib } } */ +namespace std { +class exception {}; +class runtime_error : exception { + virtual char m_fn1(); +} a; +} diff --git a/gcc/testsuite/g++.dg/lto/pr65475b_1.C b/gcc/testsuite/g++.dg/lto/pr65475b_1.C new file mode 100644 index 0000000000..29cb461992 --- /dev/null +++ b/gcc/testsuite/g++.dg/lto/pr65475b_1.C @@ -0,0 +1,7 @@ +namespace std { +class exception { + virtual char m_fn1(); +}; +class runtime_error : exception { +} b; +} diff --git a/gcc/testsuite/g++.dg/lto/pr65475c_0.C b/gcc/testsuite/g++.dg/lto/pr65475c_0.C new file mode 100644 index 0000000000..8e1d8bcc83 --- /dev/null +++ b/gcc/testsuite/g++.dg/lto/pr65475c_0.C @@ -0,0 +1,156 @@ +/* { dg-lto-do link } */ +/* { dg-lto-options "-O2 -w" } */ +/* { dg-extra-ld-options { -O2 -Wno-odr -r -nostdlib } } */ +namespace std +{ +template < class > struct char_traits; +typedef long streamsize; +template < typename, typename > class basic_streambuf; +template < typename > class A; +template < typename, typename > class basic_ostream; +template < typename _CharT, typename = + char_traits < _CharT > >class istreambuf_iterator; +template < typename _CharT, typename = + char_traits < _CharT > >class ostreambuf_iterator; +template < typename > class ctype; +template < typename _CharT, typename = + istreambuf_iterator < _CharT > >class num_get; +template < typename _CharT, typename = + ostreambuf_iterator < _CharT > >class num_put; +} +typedef int _Atomic_word; +namespace std +{ +class locale +{ + class facet; + class _Impl; + _Impl *_M_impl; +}; +class locale::facet +{ + _Atomic_word _M_refcount; +protected: + virtual ~ facet (); +}; +enum _Ios_Fmtflags +{ _S_boolalpha = 1, _S_dec, _S_fixed = 1 << 2, _S_hex = + 1 << 3, _S_internal = 1 << 4, _S_left = 1 << 5, _S_oct = + 1 << 6, _S_right = 1 << 7, _S_scientific = 1 << 8, _S_showbase = + 1 << 9, _S_showpoint = 1 << 10, _S_showpos = 1 << 11, _S_skipws = + 1 << 12, _S_unitbuf = 1 << 13, _S_uppercase = 1 << 14, _S_adjustfield = + _S_left | _S_right | _S_internal, _S_basefield = + _S_dec | _S_oct | _S_hex, _S_floatfield = + _S_scientific | _S_fixed, _S_ios_fmtflags_end = 1 << 16 +}; +enum _Ios_Iostate +{ _S_goodbit, _S_badbit, _S_eofbit, _S_failbit = + 1 << 2, _S_ios_iostate_end = 1 << 16 +}; +class ios_base +{ + typedef _Ios_Fmtflags fmtflags; + typedef _Ios_Iostate iostate; + streamsize _M_precision; + streamsize _M_width; + fmtflags _M_flags; + iostate _M_exception; + iostate _M_streambuf_state; + struct _Callback_list; + _Callback_list *_M_callbacks; + struct _Words + { + void *_M_pword; + long _M_iword; + } _M_word_zero; + enum + { _S_local_word_size = 8 }; + _Words _M_local_word[_S_local_word_size]; + int _M_word_size; + _Words *_M_word; + locale _M_ios_locale; + virtual ~ ios_base (); +}; +template < typename, typename > class istreambuf_iterator +{ + typedef A < char_traits < wchar_t > >istream_type; +}; +template < typename, typename > class ostreambuf_iterator +{ + typedef basic_ostream < wchar_t, char_traits < wchar_t > >ostream_type; +}; +template < typename, typename > class num_get:locale::facet +{ +public: + typedef istreambuf_iterator < wchar_t > iter_type; +}; +template < typename, typename > class num_put:locale::facet +{ +public: + typedef ostreambuf_iterator < wchar_t > iter_type; +}; +template < typename, typename > class basic_ios:ios_base +{ + typedef wchar_t char_type; + basic_ostream < wchar_t, char_traits < wchar_t > >*_M_tie; + char_type _M_fill; + bool _M_fill_init; + basic_streambuf < wchar_t, char_traits < wchar_t > >*_M_streambuf; + ctype < wchar_t > *_M_ctype; + num_put < wchar_t > *_M_num_put; + num_get < wchar_t > *_M_num_get; +}; +template < typename, typename > class basic_ostream:virtual basic_ios < wchar_t, + char_traits < wchar_t > + > +{ + typedef basic_ios __ios_type; +}; +template < typename > class A:basic_ios < wchar_t, int > +{ +}; +class B:A < char_traits < wchar_t > >, basic_ostream < wchar_t, + char_traits < wchar_t > > +{ +}; +} + +class C: + std::num_put < + wchar_t > +{ +public: + C (int); + iter_type + do_put_out; +}; +class + D: + std::num_get < + wchar_t > +{ +public: + D (int); + iter_type + do_get_in; +}; +template < typename > void +install_formatting_facets (std::locale, int p2) +{ + (C (p2)); +} + +template < typename > void +install_parsing_facets (std::locale, int p2) +{ + (D (p2)); +} + +std::locale a; +int b; +void +create_formatting () +{ + install_formatting_facets < wchar_t > (a, b); + install_parsing_facets < wchar_t > (a, b); +} diff --git a/gcc/testsuite/g++.dg/lto/pr65475c_1.C b/gcc/testsuite/g++.dg/lto/pr65475c_1.C new file mode 100644 index 0000000000..b63ff9b225 --- /dev/null +++ b/gcc/testsuite/g++.dg/lto/pr65475c_1.C @@ -0,0 +1,234 @@ +namespace std +{ + template < class _CharT > struct char_traits; + typedef long streamsize; + template < typename _CharT, typename _Traits = + char_traits < _CharT > >class basic_ostream; + template < typename _CharT, typename _Traits = + char_traits < _CharT > >class Trans_NS___cxx11_basic_ostringstream; + template < typename _CharT, typename _Traits = + char_traits < _CharT > >class istreambuf_iterator; + template < typename _CharT, typename _Traits = + char_traits < _CharT > >class ostreambuf_iterator; +} +namespace std +{ + template < typename _CharT, typename _InIter = + istreambuf_iterator < _CharT > >class num_get; + template < typename _CharT, typename _OutIter = + ostreambuf_iterator < _CharT > >class num_put; + struct iterator + { + }; +} +typedef int _Atomic_word; +namespace std +{ + class locale + { + public:class facet; + class _Impl; + template < typename _Facet > locale ( const locale & __other, + _Facet * __f ); + private: _Impl * _M_impl; + }; + class locale::facet + { + mutable _Atomic_word _M_refcount; + protected: explicit facet ( void ) throw ( ); + virtual ~ facet ( ); + }; + enum _Ios_Fmtflags + { + _S_boolalpha = 1 << 0, _S_dec, _S_fixed = 1 << 2, _S_hex = + 1 << 3, _S_internal = 1 << 4, _S_left = 1 << 5, _S_oct = + 1 << 6, _S_right = 1 << 7, _S_scientific = 1 << 8, _S_showbase = + 1 << 9, _S_showpoint = 1 << 10, _S_showpos = 1 << 11, _S_skipws = + 1 << 12, _S_unitbuf = 1 << 13, _S_uppercase = 1 << 14, _S_adjustfield = + _S_left | _S_right | _S_internal, _S_basefield = + _S_dec | _S_oct | _S_hex, _S_floatfield = + _S_scientific | _S_fixed, _S_ios_fmtflags_end = 1 << 16 + }; + enum _Ios_Openmode + { + _S_out + }; + enum _Ios_Iostate + { + _S_goodbit, _S_badbit, _S_eofbit, _S_failbit = + 1 << 2, _S_ios_iostate_end = 1 << 16 + }; + class ios_base + { + public:typedef _Ios_Fmtflags fmtflags; + typedef _Ios_Iostate iostate; + protected: streamsize _M_precision; + streamsize _M_width; + fmtflags _M_flags; + iostate _M_exception; + iostate _M_streambuf_state; + struct _Callback_list; + _Callback_list *_M_callbacks; + struct _Words + { + void *_M_pword; + long _M_iword; + }; + _Words _M_word_zero; + enum + { + _S_local_word_size = 8 + }; + _Words _M_local_word[_S_local_word_size]; + int _M_word_size; + _Words *_M_word; + locale _M_ios_locale; + virtual ~ ios_base ( ); + }; + template < typename _CharT, typename _Traits > class basic_streambuf; +template < typename _CharT, typename _Traits > class ostreambuf_iterator:public + iterator + { + typedef basic_ostream < wchar_t, _Traits > ostream_type; + }; + class __ctype_abstract_base:public locale::facet + { + }; +template < typename _CharT > class ctype:public __ctype_abstract_base + { + }; + class Trans_NS___cxx11_numpunct:public locale::facet + { + }; +template < typename _CharT, typename _InIter > class num_get:public locale:: + facet + { + }; +template < typename _CharT, typename _OutIter > class num_put:public locale:: + facet + { + public:typedef int char_type; + typedef std::ostreambuf_iterator < wchar_t, + std::char_traits < wchar_t > >iter_type; + }; +template < typename _CharT, typename _Traits > class basic_ios:public + ios_base + { + public:typedef wchar_t char_type; + typedef num_get < wchar_t, istreambuf_iterator < wchar_t, + _Traits > >__num_get_type; + protected:basic_ostream < wchar_t, _Traits > *_M_tie; + mutable char_type _M_fill; + mutable bool _M_fill_init; + basic_streambuf < wchar_t, _Traits > *_M_streambuf; + const ctype < wchar_t > *_M_ctype; + const num_put < wchar_t, ostreambuf_iterator < wchar_t, + _Traits > >*_M_num_put; + const __num_get_type *_M_num_get; + }; +template < typename _CharT, typename _Traits > class basic_ostream:virtual public basic_ios < wchar_t, + _Traits + > + { + }; +} +typedef enum +{ + posix +} +value_type; +static const unsigned int wchar_t_facet = 1 << 1; +class shared_ptr +{ +}; +namespace std +{ +template < typename _CharT, typename _Traits > class Trans_NS___cxx11_basic_ostringstream:public basic_ostream < wchar_t, + _Traits + > + { + public:explicit Trans_NS___cxx11_basic_ostringstream ( void ); + }; +} +class base_num_format:public + std::num_put < + wchar_t > +{ +public:typedef typename + std::num_put < + wchar_t >::iter_type + iter_type; + typedef wchar_t + char_type; + base_num_format ( unsigned long refs = 0 ); + iter_type + do_put_out; + std::ios_base & + do_put_ios; + char_type + do_put_fill; + unsigned long long + do_put_val; + virtual iter_type + do_put ( void ) const + { + return + do_real_put ( do_put_out, do_put_ios, do_put_fill, do_put_val ); + } +private:template < + typename + ValueType > + iter_type + do_real_put ( iter_type out, std::ios_base & ios, char_type fill, + ValueType val ) const + { + switch ( 0 ) + case posix: + { + typedef + std::Trans_NS___cxx11_basic_ostringstream < + char_type > + sstream_type; + sstream_type + ss; + } + } +}; +class + base_num_parse: + public + std::num_get < + wchar_t > +{ +private:}; +class + num_format: + public + base_num_format +{ +public:typedef wchar_t + iter_type; + num_format ( shared_ptr lc, unsigned long refs = 0 ) + { + } +}; +class + num_punct_posix: + public + std::Trans_NS___cxx11_numpunct +{ +}; +template < typename CharType > + std::locale create_formatting_impl ( std::locale const &in, shared_ptr lc ) +{ + std::locale tmp = std::locale ( tmp, new num_format ( lc ) ); +} +shared_ptr create_formatting_lc; +unsigned int create_formatting_type; +void +create_formatting ( std::locale const &in ) +{ + switch ( create_formatting_type ) + case wchar_t_facet: + create_formatting_impl < wchar_t > ( in, create_formatting_lc ); +} |