From: Janis Johnson Date: Tue, 11 Oct 2011 16:58:59 +0000 (+0000) Subject: re PR c++/44473 (iterators already defined for std::vector when using std::decimal) X-Git-Tag: releases/gcc-4.5.4~407 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=8e4bbf2115efd6d41c84fba5c0da32167a8290ad;p=thirdparty%2Fgcc.git re PR c++/44473 (iterators already defined for std::vector when using std::decimal) gcc/ PR c++/44473 * mangle.c (write_type): Handle CV qualifiers for decimal classes. gcc/testsuite/ PR c++/44473 * g++.dg/dfp/44473-1.C: New test. * g++.dg/dfp/44473-2.C: New test. * g++.dg/dfp/mangle-1.C: New test. * g++.dg/dfp/mangle-2.C: New test. * g++.dg/dfp/mangle-3.C: New test. * g++.dg/dfp/mangle-4.C: New test. * g++.dg/dfp/mangle-5.C: New test. From-SVN: r179808 --- diff --git a/gcc/ChangeLog b/gcc/ChangeLog index f85bf1c3bcd0..ae99530c4126 100644 --- a/gcc/ChangeLog +++ b/gcc/ChangeLog @@ -1,3 +1,8 @@ +2011-10-11 Janis Johnson + + PR c++/44473 + * mangle.c (write_type): Handle CV qualifiers for decimal classes. + 2011-09-22 Uros Bizjak PR target/50464 diff --git a/gcc/cp/mangle.c b/gcc/cp/mangle.c index 80d6aa38ca44..314e5fefd9b3 100644 --- a/gcc/cp/mangle.c +++ b/gcc/cp/mangle.c @@ -1778,11 +1778,6 @@ write_type (tree type) if (find_substitution (type)) return; - /* According to the C++ ABI, some library classes are passed the - same as the scalar type of their single member and use the same - mangling. */ - if (TREE_CODE (type) == RECORD_TYPE && TYPE_TRANSPARENT_AGGR (type)) - type = TREE_TYPE (first_field (type)); if (write_CV_qualifiers_for_type (type) > 0) /* If TYPE was CV-qualified, we just wrote the qualifiers; now @@ -1802,6 +1797,12 @@ write_type (tree type) /* See through any typedefs. */ type = TYPE_MAIN_VARIANT (type); + /* According to the C++ ABI, some library classes are passed the + same as the scalar type of their single member and use the same + mangling. */ + if (TREE_CODE (type) == RECORD_TYPE && TYPE_TRANSPARENT_AGGR (type)) + type = TREE_TYPE (first_field (type)); + if (TYPE_PTRMEM_P (type)) write_pointer_to_member_type (type); else diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog index 0f1c6907de41..964651820a4a 100644 --- a/gcc/testsuite/ChangeLog +++ b/gcc/testsuite/ChangeLog @@ -1,3 +1,14 @@ +2011-10-11 Janis Johnson + + PR c++/44473 + * g++.dg/dfp/44473-1.C: New test. + * g++.dg/dfp/44473-2.C: New test. + * g++.dg/dfp/mangle-1.C: New test. + * g++.dg/dfp/mangle-2.C: New test. + * g++.dg/dfp/mangle-3.C: New test. + * g++.dg/dfp/mangle-4.C: New test. + * g++.dg/dfp/mangle-5.C: New test. + 2011-10-11 Tobias Burnus PR fortran/50273 diff --git a/gcc/testsuite/g++.dg/dfp/44473-1.C b/gcc/testsuite/g++.dg/dfp/44473-1.C new file mode 100644 index 000000000000..38689fa165da --- /dev/null +++ b/gcc/testsuite/g++.dg/dfp/44473-1.C @@ -0,0 +1,122 @@ +/* { dg-do assemble } */ + +/* Minimized from the testcase in PR c++/44473; mangling of decimal types + did not include CV qualifiers. */ + +namespace std +{ + namespace decimal + { + class decimal32 + { + public: + typedef float __decfloat32 __attribute__ ((mode (SD))); + explicit decimal32 (float __r):__val (__r) {} + private: + __decfloat32 __val; + }; + }; + + template + _BI2 copy_backward (_BI1 __first, _BI2 __result); +} + +namespace __gnu_cxx +{ + template + class __normal_iterator + { + public: + explicit __normal_iterator (const _Iterator & __i) {} + const _Iterator & base () const {} + }; + + template + bool operator== (const __normal_iterator <_IteratorL, _Container> &__lhs, + const __normal_iterator <_IteratorR, _Container> &__rhs) + { + return __lhs.base () == __rhs.base (); + } + + template + class new_allocator + { + public: + typedef _Tp *pointer; + typedef const _Tp *const_pointer; + template + struct rebind + { + typedef new_allocator <_Tp1> other; + }; + }; +} + +namespace std +{ + template + class allocator:public __gnu_cxx::new_allocator <_Tp> {}; + + template + struct _Vector_base + { + typedef typename _Alloc::template rebind <_Tp>::other _Tp_alloc_type; + struct _Vector_impl:public _Tp_alloc_type + { + typename _Tp_alloc_type::pointer _M_finish; + }; + public: _Vector_impl _M_impl; + }; + + template > + class vector:protected _Vector_base <_Tp, _Alloc> + { + typedef _Vector_base <_Tp, _Alloc> _Base; + typedef typename _Base::_Tp_alloc_type _Tp_alloc_type; + public: + typedef _Tp value_type; + typedef typename _Tp_alloc_type::pointer pointer; + typedef typename _Tp_alloc_type::const_pointer const_pointer; + typedef __gnu_cxx::__normal_iterator iterator; + typedef __gnu_cxx::__normal_iterator + const_iterator; + const_iterator begin () const; + iterator end () + { + return iterator (this->_M_impl._M_finish); + } + const_iterator end () const + { + return const_iterator (this->_M_impl._M_finish); + } + bool empty () const + { + return begin () == end (); + } + void push_back (const value_type & __x) + { + _M_insert_aux (end ()); + } + void _M_insert_aux (iterator __position); + }; + + template + void vector <_Tp, _Alloc>::_M_insert_aux (iterator __position) + { + std::copy_backward (__position.base (), this->_M_impl._M_finish - 1); + } +} + +std::vector vec; + +int +foo () +{ + return (vec.empty ()) ? 1 : 0; +} + +bool +bar () +{ + vec.push_back (std::decimal::decimal32 (0)); +} diff --git a/gcc/testsuite/g++.dg/dfp/44473-2.C b/gcc/testsuite/g++.dg/dfp/44473-2.C new file mode 100644 index 000000000000..311f62299b38 --- /dev/null +++ b/gcc/testsuite/g++.dg/dfp/44473-2.C @@ -0,0 +1,25 @@ +// { dg-do compile } + +// Mangling of classes from std::decimal are special-cased. + +namespace std { + namespace decimal { + class decimal64 { + public: + typedef float __decfloat64 __attribute__ ((mode (DD))); + explicit decimal64 (int __r):__val (__r) {} + private: + __decfloat64 __val; + }; + } +} + +int bar (const std::decimal::decimal64 & x) { } + +int foo () +{ + std::decimal::decimal64 x(0); + bar (x); +} + +// { dg-final { scan-assembler "_Z3barRKDd:" } } diff --git a/gcc/testsuite/g++.dg/dfp/mangle-1.C b/gcc/testsuite/g++.dg/dfp/mangle-1.C new file mode 100644 index 000000000000..455d3e4c0ef6 --- /dev/null +++ b/gcc/testsuite/g++.dg/dfp/mangle-1.C @@ -0,0 +1,40 @@ +// { dg-do compile } + +// Mangling of classes from std::decimal are special-cased. +// Derived from g++.dg/abi/mangle13.C. + +namespace std { + namespace decimal { + class decimal64 { + public: + typedef float __decfloat64 __attribute__ ((mode (DD))); + explicit decimal64 (float __r):__val (__r) {} + private: + __decfloat64 __val; + }; + } +} + +struct A { + template std::decimal::decimal64 f (); + std::decimal::decimal64 operator+(); + operator std::decimal::decimal64 (); + template + std::decimal::decimal64 operator-(); +}; + +typedef std::decimal::decimal64 (A::*P)(); + +template

struct S {}; + +template void g (S<&T::template f >) {} +template void g (S<&T::operator+ >) {} +template void g (S<&T::operator std::decimal::decimal64>) {} +template void g (S<&T::template operator- >) {} + +template void g (S<&A::f >); +template void g (S<&A::operator+>); +template void g (S<&A::operator std::decimal::decimal64>); + +// { dg-final { scan-assembler "\n?_Z1gI1AEv1SIXadsrT_1fIDdEEE\[: \t\n\]" } } +// { dg-final { scan-assembler "\n?_Z1gI1AEv1SIXadsrT_plEE\[: \t\n\]" } } diff --git a/gcc/testsuite/g++.dg/dfp/mangle-2.C b/gcc/testsuite/g++.dg/dfp/mangle-2.C new file mode 100644 index 000000000000..1af9aa1a03b2 --- /dev/null +++ b/gcc/testsuite/g++.dg/dfp/mangle-2.C @@ -0,0 +1,28 @@ +// { dg-do compile } + +// Mangling of classes from std::decimal are special-cased. +// Derived from g++.dg/abi/mangle15.C. + +namespace std { + namespace decimal { + class decimal64 { + public: + typedef float __decfloat64 __attribute__ ((mode (DD))); + explicit decimal64 (float __r):__val (__r) {} + private: + __decfloat64 __val; + }; + } +} + +struct A { + template std::decimal::decimal64 f (); +}; + +typedef std::decimal::decimal64 (A::*P)(); + +template

struct S {}; + +void g (S<&A::f >) {} + +// { dg-final { scan-assembler "\n?_Z1g1SIXadL_ZN1A1fIDdEEDdvEEE\[: \t\n\]" } } diff --git a/gcc/testsuite/g++.dg/dfp/mangle-3.C b/gcc/testsuite/g++.dg/dfp/mangle-3.C new file mode 100644 index 000000000000..c716ed0e9199 --- /dev/null +++ b/gcc/testsuite/g++.dg/dfp/mangle-3.C @@ -0,0 +1,28 @@ +// { dg-do compile } + +// Mangling of classes from std::decimal are special-cased. +// Derived from g++.dg/abi/mangle20-1.C. + +namespace std { + namespace decimal { + class decimal64 { + public: + typedef float __decfloat64 __attribute__ ((mode (DD))); + explicit decimal64 (int __r):__val (__r) {} + private: + __decfloat64 __val; + }; + } +} + +template void f(std::decimal::decimal64 (*)[2]) {} +template void g(std::decimal::decimal64 (*)[I+2]) {} + +static const std::decimal::decimal64 I(1); +static const std::decimal::decimal64 J(2); + +template void f<1>(std::decimal::decimal64 (*)[2]); +template void g<1>(std::decimal::decimal64 (*)[3]); + +// { dg-final { scan-assembler "\n_?_Z1fILi1EEvPA2_Dd\[: \t\n\]" } } +// { dg-final { scan-assembler "\n_?_Z1gILi1EEvPAplT_Li2E_Dd\[: \t\n\]" } } diff --git a/gcc/testsuite/g++.dg/dfp/mangle-4.C b/gcc/testsuite/g++.dg/dfp/mangle-4.C new file mode 100644 index 000000000000..899d5661c0d6 --- /dev/null +++ b/gcc/testsuite/g++.dg/dfp/mangle-4.C @@ -0,0 +1,35 @@ +// { dg-do compile } + +// Mangling of classes from std::decimal are special-cased. +// Derived from g++.dg/abi/mangle30.C. + +namespace std { + namespace decimal { + class decimal64 { + public: + typedef float __decfloat64 __attribute__ ((mode (DD))); + explicit decimal64 (int __r):__val (__r) {} + private: + __decfloat64 __val; + }; + } +} + +struct A +{ + template + struct B + { + typedef T myT; + }; +}; + +template +void f (T t, typename T::template B::myT u, typename T::template B::myT v); + +void foo () +{ + f (A(), std::decimal::decimal64(0), 1); +} + +// { dg-final { scan-assembler "_Z1fI1AEvT_NS1_1BIDdE3myTENS2_IiE3myTE" } } diff --git a/gcc/testsuite/g++.dg/dfp/mangle-5.C b/gcc/testsuite/g++.dg/dfp/mangle-5.C new file mode 100644 index 000000000000..794577f866a3 --- /dev/null +++ b/gcc/testsuite/g++.dg/dfp/mangle-5.C @@ -0,0 +1,29 @@ +// { dg-do compile } + +// Mangling of classes from std::decimal are special-cased. +// Derived from g++.dg/abi/mangle35.C. + +namespace std { + namespace decimal { + class decimal128 { + public: + typedef float __decfloat128 __attribute__ ((mode (TD))); + explicit decimal128 (int __r):__val (__r) {} + private: + __decfloat128 __val; + }; + } +} + +template struct A {}; + +template void foo(); + +template A > bar(); + +void baz() +{ + bar(); +} + +// { dg-final { scan-assembler "_Z3barIDeE1AIX3fooIT_EEEv" } }