]> code.ossystems Code Review - openembedded-core.git/blob
f5ce975b8d5e695183ff3208f60460b19416d8ad
[openembedded-core.git] /
1 Upstream-Status: Inappropriate [Backport]
2 From 838560450136f202dc9170f2ad3eec80b41e0381 Mon Sep 17 00:00:00 2001
3 From: paolo <paolo@138bc75d-0d04-0410-961f-82ee72b054a4>
4 Date: Fri, 29 Apr 2011 23:19:59 +0000
5 Subject: [PATCH 199/200] 2011-04-29  Paolo Carlini  <paolo.carlini@oracle.com>
6
7         PR libstdc++/48760
8         * include/std/complex (complex<float>::complex(float, float),
9         complex<double>::complex(double, double),
10         complex<long double>::complex(long double, long double)): Initialize
11         in the body in C++03 mode (no fix in C++0x mode).
12         * testsuite/26_numerics/complex/cons/48760.cc: New.
13
14
15 git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/branches/gcc-4_6-branch@173195 138bc75d-0d04-0410-961f-82ee72b054a4
16
17 index d36eddc..aa6e81d 100644
18 --- a/libstdc++-v3/include/std/complex
19 +++ b/libstdc++-v3/include/std/complex
20 @@ -1046,7 +1046,17 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
21        _GLIBCXX_CONSTEXPR complex(_ComplexT __z) : _M_value(__z) { }
22  
23        _GLIBCXX_CONSTEXPR complex(float __r = 0.0f, float __i = 0.0f)
24 +#ifdef __GXX_EXPERIMENTAL_CXX0X__
25 +      // The list-initialization extension to __complex__ types is
26 +      // not available in GCC 4.6.  Thus libstdc++/48760 cannot be
27 +      // fixed in C++0x mode, unfortunately.
28        : _M_value(__r + __i * 1.0fi) { }
29 +#else
30 +      {
31 +       __real__ _M_value = __r;
32 +       __imag__ _M_value = __i;
33 +      }
34 +#endif
35  
36        explicit _GLIBCXX_CONSTEXPR complex(const complex<double>&);
37        explicit _GLIBCXX_CONSTEXPR complex(const complex<long double>&);        
38 @@ -1186,7 +1196,17 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
39        _GLIBCXX_CONSTEXPR complex(_ComplexT __z) : _M_value(__z) { }
40  
41        _GLIBCXX_CONSTEXPR complex(double __r = 0.0, double __i = 0.0)
42 +#ifdef __GXX_EXPERIMENTAL_CXX0X__
43 +      // The list-initialization extension to __complex__ types is
44 +      // not available in GCC 4.6.  Thus libstdc++/48760 cannot be
45 +      // fixed in C++0x mode, unfortunately.
46        : _M_value(__r + __i * 1.0i) { }
47 +#else
48 +      {
49 +       __real__ _M_value = __r;
50 +       __imag__ _M_value = __i;
51 +      }
52 +#endif
53  
54        _GLIBCXX_CONSTEXPR complex(const complex<float>& __z)
55        : _M_value(__z.__rep()) { }
56 @@ -1328,7 +1348,17 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
57  
58        _GLIBCXX_CONSTEXPR complex(long double __r = 0.0L, 
59                                  long double __i = 0.0L)
60 +#ifdef __GXX_EXPERIMENTAL_CXX0X__
61 +      // The list-initialization extension to __complex__ types is
62 +      // not available in GCC 4.6.  Thus libstdc++/48760 cannot be
63 +      // fixed in C++0x mode, unfortunately.
64        : _M_value(__r + __i * 1.0Li) { }
65 +#else
66 +      {
67 +       __real__ _M_value = __r;
68 +       __imag__ _M_value = __i;
69 +      }
70 +#endif
71  
72        _GLIBCXX_CONSTEXPR complex(const complex<float>& __z)
73        : _M_value(__z.__rep()) { }
74 diff --git a/libstdc++-v3/testsuite/26_numerics/complex/cons/48760.cc b/libstdc++-v3/testsuite/26_numerics/complex/cons/48760.cc
75 new file mode 100644
76 index 0000000..0201cc7
77 --- /dev/null
78 +++ b/libstdc++-v3/testsuite/26_numerics/complex/cons/48760.cc
79 @@ -0,0 +1,56 @@
80 +// Copyright (C) 2011 Free Software Foundation, Inc.
81 +//
82 +// This file is part of the GNU ISO C++ Library.  This library is free
83 +// software; you can redistribute it and/or modify it under the
84 +// terms of the GNU General Public License as published by the
85 +// Free Software Foundation; either version 3, or (at your option)
86 +// any later version.
87 +
88 +// This library is distributed in the hope that it will be useful,
89 +// but WITHOUT ANY WARRANTY; without even the implied warranty of
90 +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
91 +// GNU General Public License for more details.
92 +
93 +// You should have received a copy of the GNU General Public License along
94 +// with this library; see the file COPYING3.  If not see
95 +// <http://www.gnu.org/licenses/>.
96 +
97 +#include <complex>
98 +#include <limits>
99 +#include <testsuite_hooks.h>
100 +
101 +template<typename T>
102 +  void do_test01()
103 +  {
104 +    bool test __attribute__((unused)) = true;
105 +
106 +    if (std::numeric_limits<T>::has_quiet_NaN)
107 +      {
108 +       std::complex<T> c1(T(0), std::numeric_limits<T>::quiet_NaN());
109 +       VERIFY( c1.real() == T(0) );
110 +       VERIFY( std::isnan(c1.imag()) );
111 +
112 +       std::complex<T> c2(std::numeric_limits<T>::quiet_NaN(), T(0));
113 +       VERIFY( std::isnan(c2.real()) );
114 +       VERIFY( c2.imag() == T(0) );
115 +
116 +       std::complex<T> c3(std::numeric_limits<T>::quiet_NaN(),
117 +                          std::numeric_limits<T>::quiet_NaN());
118 +       VERIFY( std::isnan(c3.real()) );
119 +       VERIFY( std::isnan(c3.imag()) );
120 +      }
121 +  }
122 +
123 +// libstdc++/48760
124 +void test01()
125 +{
126 +  do_test01<float>();
127 +  do_test01<double>();
128 +  do_test01<long double>();
129 +}
130 +
131 +int main()
132 +{
133 +  test01();
134 +  return 0;
135 +}
136 -- 
137 1.7.0.4
138