From 2813904b118a4c7b914fd44ed9a189ee777c5165 Mon Sep 17 00:00:00 2001 From: Richard Biener Date: Fri, 12 Sep 2014 11:06:49 +0000 Subject: [PATCH] re PR middle-end/63237 (error: invalid operand in unary operation) 2014-09-12 Richard Biener PR middle-end/63237 * gimple-fold.c (get_maxval_strlen): Gimplify string length. * g++.dg/torture/pr63237.C: New testcase. From-SVN: r215212 --- gcc/ChangeLog | 5 +++++ gcc/gimple-fold.c | 1 + gcc/testsuite/ChangeLog | 5 +++++ gcc/testsuite/g++.dg/torture/pr63237.C | 21 +++++++++++++++++++++ 4 files changed, 32 insertions(+) create mode 100644 gcc/testsuite/g++.dg/torture/pr63237.C diff --git a/gcc/ChangeLog b/gcc/ChangeLog index 98586be01d1..52825bb6cf2 100644 --- a/gcc/ChangeLog +++ b/gcc/ChangeLog @@ -1,3 +1,8 @@ +2014-09-12 Richard Biener + + PR middle-end/63237 + * gimple-fold.c (get_maxval_strlen): Gimplify string length. + 2014-09-12 Marc Glisse * tree.c (integer_each_onep): New function. diff --git a/gcc/gimple-fold.c b/gcc/gimple-fold.c index 4aa1f4c1eda..3d5e3b91c04 100644 --- a/gcc/gimple-fold.c +++ b/gcc/gimple-fold.c @@ -2411,6 +2411,7 @@ gimple_fold_builtin_strlen (gimple_stmt_iterator *gsi) tree len = get_maxval_strlen (gimple_call_arg (stmt, 0), 0); if (!len) return false; + len = force_gimple_operand_gsi (gsi, len, true, NULL, true, GSI_SAME_STMT); replace_call_with_value (gsi, len); return true; } diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog index fb727bf0464..20defa5bc3e 100644 --- a/gcc/testsuite/ChangeLog +++ b/gcc/testsuite/ChangeLog @@ -1,3 +1,8 @@ +2014-09-12 Richard Biener + + PR middle-end/63237 + * g++.dg/torture/pr63237.C: New testcase. + 2014-09-12 Marc Glisse * gcc.dg/vec-andxor1.c: New file. diff --git a/gcc/testsuite/g++.dg/torture/pr63237.C b/gcc/testsuite/g++.dg/torture/pr63237.C new file mode 100644 index 00000000000..d1eaadab043 --- /dev/null +++ b/gcc/testsuite/g++.dg/torture/pr63237.C @@ -0,0 +1,21 @@ +// { dg-do compile } + +class A { + int Length; +public: + A(const char *p1) { Length = __builtin_strlen(p1); } +}; +class B { +public: + void m_fn1(int, A); +}; +class C { +public: + B &m_fn2(); +}; +int a; +void RewriteMacrosInInput() { + C b; + B &c = b.m_fn2(); + c.m_fn1(0, &""[a]); +} -- 2.30.2