===================================================================
@@ -1787,11 +1787,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
@@ -1811,6 +1806,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
===================================================================
@@ -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 <typename _BI1, typename _BI2>
+ _BI2 copy_backward (_BI1 __first, _BI2 __result);
+}
+
+namespace __gnu_cxx
+{
+ template <typename _Iterator, typename _Container>
+ class __normal_iterator
+ {
+ public:
+ explicit __normal_iterator (const _Iterator & __i) {}
+ const _Iterator & base () const {}
+ };
+
+ template <typename _IteratorL, typename _IteratorR, typename _Container>
+ bool operator== (const __normal_iterator <_IteratorL, _Container> &__lhs,
+ const __normal_iterator <_IteratorR, _Container> &__rhs)
+ {
+ return __lhs.base () == __rhs.base ();
+ }
+
+ template <typename _Tp>
+ class new_allocator
+ {
+ public:
+ typedef _Tp *pointer;
+ typedef const _Tp *const_pointer;
+ template <typename _Tp1>
+ struct rebind
+ {
+ typedef new_allocator <_Tp1> other;
+ };
+ };
+}
+
+namespace std
+{
+ template <typename _Tp>
+ class allocator:public __gnu_cxx::new_allocator <_Tp> {};
+
+ template <typename _Tp, typename _Alloc>
+ 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 <typename _Tp, typename _Alloc = std::allocator <_Tp> >
+ 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 <pointer, vector> iterator;
+ typedef __gnu_cxx::__normal_iterator <const_pointer, vector>
+ 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 <typename _Tp, typename _Alloc>
+ void vector <_Tp, _Alloc>::_M_insert_aux (iterator __position)
+ {
+ std::copy_backward (__position.base (), this->_M_impl._M_finish - 1);
+ }
+}
+
+std::vector <std::decimal::decimal32> vec;
+
+int
+foo ()
+{
+ return (vec.empty ()) ? 1 : 0;
+}
+
+bool
+bar ()
+{
+ vec.push_back (std::decimal::decimal32 (0));
+}
===================================================================
@@ -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:" } }
===================================================================
@@ -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 <typename T> std::decimal::decimal64 f ();
+ std::decimal::decimal64 operator+();
+ operator std::decimal::decimal64 ();
+ template <typename T>
+ std::decimal::decimal64 operator-();
+};
+
+typedef std::decimal::decimal64 (A::*P)();
+
+template <P> struct S {};
+
+template <typename T> void g (S<&T::template f<std::decimal::decimal64> >) {}
+template <typename T> void g (S<&T::operator+ >) {}
+template <typename T> void g (S<&T::operator std::decimal::decimal64>) {}
+template <typename T> void g (S<&T::template operator- <std::decimal::decimal64> >) {}
+
+template void g<A> (S<&A::f<std::decimal::decimal64> >);
+template void g<A> (S<&A::operator+>);
+template void g<A> (S<&A::operator std::decimal::decimal64>);
+
+// { dg-final { scan-assembler "\n?_Z1gI1AEv1SIXadsrT_1fIDdEEE\[: \t\n\]" } }
+// { dg-final { scan-assembler "\n?_Z1gI1AEv1SIXadsrT_plEE\[: \t\n\]" } }
===================================================================
@@ -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 <typename T> std::decimal::decimal64 f ();
+};
+
+typedef std::decimal::decimal64 (A::*P)();
+
+template <P> struct S {};
+
+void g (S<&A::f<std::decimal::decimal64> >) {}
+
+// { dg-final { scan-assembler "\n?_Z1g1SIXadL_ZN1A1fIDdEEDdvEEE\[: \t\n\]" } }
===================================================================
@@ -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 <int I> void f(std::decimal::decimal64 (*)[2]) {}
+template <int I> 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\]" } }
===================================================================
@@ -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 <class T>
+ struct B
+ {
+ typedef T myT;
+ };
+};
+
+template <class T>
+void f (T t, typename T::template B<std::decimal::decimal64>::myT u, typename T::template B<int>::myT v);
+
+void foo ()
+{
+ f (A(), std::decimal::decimal64(0), 1);
+}
+
+// { dg-final { scan-assembler "_Z1fI1AEvT_NS1_1BIDdE3myTENS2_IiE3myTE" } }
===================================================================
@@ -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<void (*)()> struct A {};
+
+template<typename> void foo();
+
+template<typename T> A<foo<T> > bar();
+
+void baz()
+{
+ bar<std::decimal::decimal128>();
+}
+
+// { dg-final { scan-assembler "_Z3barIDeE1AIX3fooIT_EEEv" } }