summaryrefslogtreecommitdiff
path: root/gcc/testsuite/g++.dg/dfp
diff options
context:
space:
mode:
authorupstream source tree <ports@midipix.org>2015-03-15 20:14:05 -0400
committerupstream source tree <ports@midipix.org>2015-03-15 20:14:05 -0400
commit554fd8c5195424bdbcabf5de30fdc183aba391bd (patch)
tree976dc5ab7fddf506dadce60ae936f43f58787092 /gcc/testsuite/g++.dg/dfp
downloadcbb-gcc-4.6.4-554fd8c5195424bdbcabf5de30fdc183aba391bd.tar.bz2
cbb-gcc-4.6.4-554fd8c5195424bdbcabf5de30fdc183aba391bd.tar.xz
obtained gcc-4.6.4.tar.bz2 from upstream website;upstream
verified gcc-4.6.4.tar.bz2.sig; imported gcc-4.6.4 source tree from verified upstream tarball. downloading a git-generated archive based on the 'upstream' tag should provide you with a source tree that is binary identical to the one extracted from the above tarball. if you have obtained the source via the command 'git clone', however, do note that line-endings of files in your working directory might differ from line-endings of the respective files in the upstream repository.
Diffstat (limited to 'gcc/testsuite/g++.dg/dfp')
-rw-r--r--gcc/testsuite/g++.dg/dfp/44473-1.C122
-rw-r--r--gcc/testsuite/g++.dg/dfp/44473-2.C25
-rw-r--r--gcc/testsuite/g++.dg/dfp/base.C23
-rw-r--r--gcc/testsuite/g++.dg/dfp/dfp.exp67
-rw-r--r--gcc/testsuite/g++.dg/dfp/mangle-1.C40
-rw-r--r--gcc/testsuite/g++.dg/dfp/mangle-2.C28
-rw-r--r--gcc/testsuite/g++.dg/dfp/mangle-3.C28
-rw-r--r--gcc/testsuite/g++.dg/dfp/mangle-4.C35
-rw-r--r--gcc/testsuite/g++.dg/dfp/mangle-5.C29
-rw-r--r--gcc/testsuite/g++.dg/dfp/mangle-mode.C37
-rw-r--r--gcc/testsuite/g++.dg/dfp/nofields.C19
-rw-r--r--gcc/testsuite/g++.dg/dfp/typeid1.C8
12 files changed, 461 insertions, 0 deletions
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 000000000..38689fa16
--- /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 <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));
+}
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 000000000..311f62299
--- /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/base.C b/gcc/testsuite/g++.dg/dfp/base.C
new file mode 100644
index 000000000..3e5dc50ba
--- /dev/null
+++ b/gcc/testsuite/g++.dg/dfp/base.C
@@ -0,0 +1,23 @@
+// PR c++/50207
+// { dg-do compile }
+
+namespace std
+{
+ namespace decimal
+ {
+ template <class _Fmt> struct _FmtTraits;
+ class decimal32;
+ template <> struct _FmtTraits <decimal32>
+ {
+ static const long _NumBytes = 4UL;
+ };
+ template <class _Tr> class _DecBase
+ {
+ unsigned char _Bytes[_Tr::_NumBytes];
+ };
+ class decimal32 : public _DecBase <_FmtTraits <decimal32> > // { dg-error "has base" }
+ {
+ decimal32 () { }
+ };
+ }
+}
diff --git a/gcc/testsuite/g++.dg/dfp/dfp.exp b/gcc/testsuite/g++.dg/dfp/dfp.exp
new file mode 100644
index 000000000..4b15ca529
--- /dev/null
+++ b/gcc/testsuite/g++.dg/dfp/dfp.exp
@@ -0,0 +1,67 @@
+# Copyright (C) 2005, 2006, 2007, 2009 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
+# the Free Software Foundation; either version 3 of the License, or
+# (at your option) any later version.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with GCC; see the file COPYING3. If not see
+# <http://www.gnu.org/licenses/>.
+
+# GCC testsuite that uses the `dg.exp' driver.
+
+# Load support procs.
+load_lib g++-dg.exp
+
+# Skip these tests for targets that don't support this extension.
+if { ![check_effective_target_dfp] } {
+ return;
+}
+
+# If the decimal float is supported in the compiler but not yet in the
+# runtime, treat all tests as compile-only.
+global dg-do-what-default
+set save-dg-do-what-default ${dg-do-what-default}
+if { ![check_effective_target_dfprt] } {
+ verbose "dfp.exp: runtime support for decimal float does not exist" 2
+ set dg-do-what-default compile
+} else {
+ verbose "dfp.exp: runtime support for decimal float exists, use it" 2
+ set dg-do-what-default run
+}
+verbose "dfp.exp: dg-do-what-default is ${dg-do-what-default}" 2
+
+global DEFAULT_CXXFLAGS
+if [info exists DEFAULT_CXXFLAGS] then {
+ set save_default_cxxflags $DEFAULT_CXXFLAGS
+}
+
+# If a testcase doesn't have special options, use these.
+set DEFAULT_CXXFLAGS ""
+
+# Initialize `dg'.
+dg-init
+
+# Main loop. Run the tests that are specific to C++.
+dg-runtest [lsort [glob -nocomplain $srcdir/$subdir/*.\[C]] \
+ "" $DEFAULT_CXXFLAGS
+# Run tests that are shared with C testing.
+dg-runtest [lsort [glob -nocomplain $srcdir/c-c++-common/dfp/*.c]] \
+ "" $DEFAULT_CXXFLAGS
+
+# All done.
+dg-finish
+
+set dg-do-what-default ${save-dg-do-what-default}
+verbose "dfp.exp: dg-do-what-default is ${dg-do-what-default}" 2
+if [info exists save_default_cxxflags] {
+ set DEFAULT_CXXFLAGS $save_default_cxxflags
+} else {
+ unset DEFAULT_CXXFLAGS
+}
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 000000000..455d3e4c0
--- /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 <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\]" } }
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 000000000..1af9aa1a0
--- /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 <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\]" } }
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 000000000..c716ed0e9
--- /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 <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\]" } }
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 000000000..899d5661c
--- /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 <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" } }
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 000000000..794577f86
--- /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<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" } }
diff --git a/gcc/testsuite/g++.dg/dfp/mangle-mode.C b/gcc/testsuite/g++.dg/dfp/mangle-mode.C
new file mode 100644
index 000000000..ac30cb323
--- /dev/null
+++ b/gcc/testsuite/g++.dg/dfp/mangle-mode.C
@@ -0,0 +1,37 @@
+// { dg-do compile }
+
+// Check that the compiler mangles types defined with decimal float
+// modes according to the vendor-neutral C++ ABI.
+
+typedef float _Decimal32 __attribute__((mode(SD)));
+typedef float _Decimal64 __attribute__((mode(DD)));
+typedef float _Decimal128 __attribute__((mode(TD)));
+
+extern void foo32 (_Decimal32 a, _Decimal32 &b, _Decimal32 *c);
+extern void foo64 (_Decimal64 *a, _Decimal64 b, _Decimal64 &c);
+extern void foo128 (_Decimal128 &a, _Decimal128 *b, _Decimal128 c);
+
+void
+bar32 (void)
+{
+ _Decimal32 x, y, z;
+ foo32 (x, y, &z);
+}
+
+void
+bar64 (void)
+{
+ _Decimal64 x, y, z;
+ foo64 (&x, y, z);
+}
+
+void
+bar128 (void)
+{
+ _Decimal128 x, y, z;
+ foo128 (x, &y, z);
+}
+
+// { dg-final { scan-assembler "Z5foo32DfRDfPDf" } }
+// { dg-final { scan-assembler "Z5foo64PDdDdRDd" } }
+// { dg-final { scan-assembler "Z6foo128RDePDeDe" } }
diff --git a/gcc/testsuite/g++.dg/dfp/nofields.C b/gcc/testsuite/g++.dg/dfp/nofields.C
new file mode 100644
index 000000000..7234672d4
--- /dev/null
+++ b/gcc/testsuite/g++.dg/dfp/nofields.C
@@ -0,0 +1,19 @@
+// PR c++/46862
+// { dg-do compile }
+
+namespace std
+{
+ namespace decimal
+ {
+ class decimal32 { }; // { dg-error "does not have any fields" }
+ class decimal64 { }; // { dg-error "does not have any fields" }
+ class decimal128 { }; // { dg-error "does not have any fields" }
+ }
+}
+
+void
+foo (std::decimal::decimal32 x,
+ std::decimal::decimal64 y,
+ std::decimal::decimal128 z)
+{
+}
diff --git a/gcc/testsuite/g++.dg/dfp/typeid1.C b/gcc/testsuite/g++.dg/dfp/typeid1.C
new file mode 100644
index 000000000..cdc33a774
--- /dev/null
+++ b/gcc/testsuite/g++.dg/dfp/typeid1.C
@@ -0,0 +1,8 @@
+// PR c++/39131
+// { dg-do link }
+
+#include <typeinfo>
+
+const std::type_info &r = typeid(0.dd);
+
+int main() { }