diff options
author | jakub <jakub@138bc75d-0d04-0410-961f-82ee72b054a4> | 2016-01-21 07:59:32 +0000 |
---|---|---|
committer | jakub <jakub@138bc75d-0d04-0410-961f-82ee72b054a4> | 2016-01-21 07:59:32 +0000 |
commit | ac7d424b10b37fc072fb3be0c9b9ae4fde9453bf (patch) | |
tree | cba686a88e409c5c096dcbba16a02aa2df958b48 | |
parent | c2f6e0d05e1599c95b06d8c444638ea97a6360c5 (diff) | |
download | gcc-ac7d424b10b37fc072fb3be0c9b9ae4fde9453bf.tar.gz |
PR c++/69355
* tree-dfa.c (get_ref_base_and_extent): Use GET_MODE_BITSIZE (mode)
for bitsize instead of GET_MODE_PRECISION (mode).
* g++.dg/torture/pr69355.C: New test.
git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@232663 138bc75d-0d04-0410-961f-82ee72b054a4
-rw-r--r-- | gcc/ChangeLog | 6 | ||||
-rw-r--r-- | gcc/testsuite/ChangeLog | 5 | ||||
-rw-r--r-- | gcc/testsuite/g++.dg/torture/pr69355.C | 150 | ||||
-rw-r--r-- | gcc/tree-dfa.c | 2 |
4 files changed, 162 insertions, 1 deletions
diff --git a/gcc/ChangeLog b/gcc/ChangeLog index 36a210a699a..5b4ed595fd6 100644 --- a/gcc/ChangeLog +++ b/gcc/ChangeLog @@ -1,3 +1,9 @@ +2016-01-21 Jakub Jelinek <jakub@redhat.com> + + PR c++/69355 + * tree-dfa.c (get_ref_base_and_extent): Use GET_MODE_BITSIZE (mode) + for bitsize instead of GET_MODE_PRECISION (mode). + 2016-01-20 Martin Sebor <msebor@redhat.com> PR c/52291 diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog index 50aa4392641..a6bc40c1ece 100644 --- a/gcc/testsuite/ChangeLog +++ b/gcc/testsuite/ChangeLog @@ -1,3 +1,8 @@ +2016-01-21 Jakub Jelinek <jakub@redhat.com> + + PR c++/69355 + * g++.dg/torture/pr69355.C: New test. + 2016-01-21 Aditya Kumar <aditya.k7@samsung.com> Sebastian Pop <s.pop@samsung.com> diff --git a/gcc/testsuite/g++.dg/torture/pr69355.C b/gcc/testsuite/g++.dg/torture/pr69355.C new file mode 100644 index 00000000000..58cb9615e21 --- /dev/null +++ b/gcc/testsuite/g++.dg/torture/pr69355.C @@ -0,0 +1,150 @@ +// PR c++/69355 +// { dg-do run } + +template <int> struct A; +template <> struct A<1> {}; +template <class Obj, int> struct B +{ + template <class T> struct C + { + typedef T *iterator; + C (iterator p1) : m_iter (p1) {} + void operator, (T p1) { *m_iter = p1; } + iterator m_iter; + }; + typedef double *iterator; + B (Obj &p1, double) : m_object (p1) {} + C<double> operator, (double); + Obj &m_object; +}; +template <class Obj, int LEN> +typename B<Obj, LEN>::template C<double> +B<Obj, LEN>::operator, (double p1) +{ + iterator a = m_object.data (), b = a + 1; + *a = 1; + *b = p1; + return C<double>(b + 1); +} +class D {}; +inline double operator+(const double &p1, D) { return p1; } +template <int> class U; +template <int Sz, int K = 0> struct F +{ + enum { doIt = K < Sz - 1 ? 1 : 0 }; + template <class Dest, class Src, class Assign> + static void assign (Dest &p1, Src &p2, Assign &p3) + { + p3.apply_on (p1 (K), p2 (K)); + F<Sz * doIt, (K + 1) * doIt>::assign (p1, p2, p3); + } + template <class Dest, class Src> static double dot (Dest &p1, Src &p2) + { + return p1 (K) * p2 (K) + F<Sz * doIt, (K + 1) * doIt>::dot (p1, p2); + } +}; +template <> struct F<0> +{ + template <class Dest, class Src, class Assign> + static void assign (Dest &, Src &, Assign &) {} + template <class Dest, class Src> static D dot (Dest &, Src &) { return D (); } +}; +template <class E, int Sz> struct G +{ + enum { ops_assign, use_meta }; + G (const E &p1) : m_expr (p1) {} + double operator()(int p1) const { return m_expr (p1); } + template <class Dest, class Src, class Assign> + static void do_assign (A<1>, Dest &p2, Src &p3, Assign &p4) + { + F<Sz>::assign (p2, p3, p4); + } + template <class Dest, class Assign> + void assign_to (Dest &p1, const Assign &p2) const + { + do_assign (A<1>(), p1, *this, p2); + } + E m_expr; +}; +struct H +{ + static double apply_on (double p1, long double p2) { return p1 / p2; } + static void apply_on (double &p1, double p2) { p1 = p2; } +}; +template <class E1, class E2> struct I +{ + I (const E1 &p1, const E2 &p2) : m_lhs (p1), m_rhs (p2) {} + double operator()(int p1) const + { + double c = m_lhs (p1); + return H::apply_on (c, m_rhs (0)); + } + E1 m_lhs; + const E2 m_rhs; +}; +struct J +{ + J (double p1) : m_data (p1) {} + long double operator()(int) const { return m_data; } + long double m_data; +}; +template <int Sz> struct K +{ + K (const U<Sz> &p1) : m_data (p1.data ()) {} + double operator()(int p1) const { return m_data[p1]; } + const double *m_data; +}; +template <int Sz> struct U +{ + U () {} + U (const U &p1) + { + *this = G<ConstReference, Sz>(p1.const_ref ()); + } + B<U, Sz> operator=(double) { return B<U, Sz>(*this, 0); } + double *data () { return m_data; } + const double *data () const { return m_data; } + double &operator()(int p1) { return m_data[p1]; } + double operator()(int p1) const { return m_data[p1]; } + typedef K<Sz> ConstReference; + ConstReference const_ref () const { return *this; } + template <class E> void operator=(const G<E, Sz> &p1) + { + p1.assign_to (*this, H ()); + } + double m_data[Sz]; +}; +template <int Sz> +G<I<K<Sz>, J>, Sz> div (U<Sz> &p1, double p2) +{ + typedef I<K<Sz>, J> expr_type; + return G<expr_type, Sz>(expr_type (p1.const_ref (), p2)); +} +template <int Sz> double norm2 (U<Sz> &p1) +{ + return __builtin_sqrt (F<Sz>::dot (p1, p1)); +} +template <int Sz> +G<I<K<Sz>, J>, Sz> operator/(U<Sz> &p1, double p2) +{ + return div (p1, p2); +} +typedef U<3> V; +V foo (V p1) +{ + double e = norm2 (p1); + V r; + r = p1 / e; + return r; +} +int +main () +{ + V f; + f = 1, 2, 3; + V r = foo (f); + if (__builtin_fabs (r (0) - 0.267261) > 0.01 + || __builtin_fabs (r (1) - 0.534522) > 0.01 + || __builtin_fabs (r (2) - 0.801784) > 0.01) + __builtin_abort (); +} diff --git a/gcc/tree-dfa.c b/gcc/tree-dfa.c index 54a6d07dbd5..db560cf7360 100644 --- a/gcc/tree-dfa.c +++ b/gcc/tree-dfa.c @@ -395,7 +395,7 @@ get_ref_base_and_extent (tree exp, HOST_WIDE_INT *poffset, if (mode == BLKmode) size_tree = TYPE_SIZE (TREE_TYPE (exp)); else - bitsize = int (GET_MODE_PRECISION (mode)); + bitsize = int (GET_MODE_BITSIZE (mode)); } if (size_tree != NULL_TREE && TREE_CODE (size_tree) == INTEGER_CST) |