From 2c703f3a6a2a283318a0678fc8a5eba27b6663df Mon Sep 17 00:00:00 2001 From: Jakub Jelinek Date: Thu, 12 May 2011 13:54:33 +0200 Subject: [PATCH] re PR debug/48967 (ICE during use_narrower_mode) PR debug/48967 * var-tracking.c (use_narrower_mode_test) : Return 1 if validate_subreg fails. * g++.dg/opt/pr48967.C: New test. From-SVN: r173701 --- gcc/ChangeLog | 8 ++- gcc/testsuite/ChangeLog | 5 ++ gcc/testsuite/g++.dg/opt/pr48967.C | 98 ++++++++++++++++++++++++++++++ gcc/var-tracking.c | 4 ++ 4 files changed, 114 insertions(+), 1 deletion(-) create mode 100644 gcc/testsuite/g++.dg/opt/pr48967.C diff --git a/gcc/ChangeLog b/gcc/ChangeLog index 4bb674995f7..6f994adaedb 100644 --- a/gcc/ChangeLog +++ b/gcc/ChangeLog @@ -1,4 +1,10 @@ -2011-05-12 Hariharan Sandanagobalane +2011-05-12 Jakub Jelinek + + PR debug/48967 + * var-tracking.c (use_narrower_mode_test) : Return 1 + if validate_subreg fails. + +2011-05-12 Hariharan Sandanagobalane * ira.c (clarify_prohibited_class_mode_regs): Prevent the function from accessing beyond the end of REGNO_REG_CLASS array by stopping the loop diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog index d6f1b4cde93..b0b337445ad 100644 --- a/gcc/testsuite/ChangeLog +++ b/gcc/testsuite/ChangeLog @@ -1,3 +1,8 @@ +2011-05-12 Jakub Jelinek + + PR debug/48967 + * g++.dg/opt/pr48967.C: New test. + 2011-05-11 Jason Merrill * g++.dg/cpp0x/constexpr-friend.C: New. diff --git a/gcc/testsuite/g++.dg/opt/pr48967.C b/gcc/testsuite/g++.dg/opt/pr48967.C new file mode 100644 index 00000000000..db2ea5474e4 --- /dev/null +++ b/gcc/testsuite/g++.dg/opt/pr48967.C @@ -0,0 +1,98 @@ +// PR debug/48967 +// { dg-do compile } +// { dg-options "-g -O2" } + +template struct A; +template struct A +{ + typedef T ref; +}; +template struct B +{ + typedef A t; + typedef typename t::ref ref; + ref operator * () { return ref (); } +}; +template struct I +{ + typedef T *cp; + template struct J + { + typedef I other; + }; +}; +template struct S : public I +{ +}; +template struct E +{ + typedef typename _A::template J ::other at; +}; +template > struct D +{ + typedef E _Base; + typedef typename _Base::at at; + typedef typename at::cp cp; + typedef B H; +}; +template struct F +{ + T *operator -> () { return __null; } +}; +template long +lfloor (T x) +{ + return static_cast (x) - (x && x != static_cast (x)); +} +template long +lround (T x) +{ + return lfloor (x - 0.5) + 1; +} +class M; +template class P; +typedef P Q; +template struct P +{ + float x (); +}; +struct CV +{ + Q c; +}; +struct C +{ + void foo (const CV &) const; + class O; + typedef D > R; + R n; +}; +struct S3 +{ + S3 (int, int); +}; +struct S2 +{ + S3 sx, sy; + S2 (int x = 0, int y = 0, int s = 0, int t = 0) : sx (x, y), sy (s, t) {} +}; +template struct N +{ + int bar (); +}; +struct C::O +{ + N o; + void foo (CV r, int) + { + Q c = r.c; + float t = 0.5 * (o.bar ()); + S2 (lround (c.x ()), t); + } +}; +void +C::foo (const CV &w) const +{ + R::H m; + (*m)->foo (w, 8); +} diff --git a/gcc/var-tracking.c b/gcc/var-tracking.c index 90411123a69..278f546a860 100644 --- a/gcc/var-tracking.c +++ b/gcc/var-tracking.c @@ -745,6 +745,10 @@ use_narrower_mode_test (rtx *loc, void *data) case REG: if (cselib_lookup (*loc, GET_MODE (SUBREG_REG (subreg)), 0, VOIDmode)) return 1; + if (!validate_subreg (GET_MODE (subreg), GET_MODE (*loc), + *loc, subreg_lowpart_offset (GET_MODE (subreg), + GET_MODE (*loc)))) + return 1; return -1; case PLUS: case MINUS: -- 2.30.2