This is the mail archive of the
gcc-patches@gcc.gnu.org
mailing list for the GCC project.
Small C++ tweak to fold_simple
- From: Marek Polacek <polacek at redhat dot com>
- To: GCC Patches <gcc-patches at gcc dot gnu dot org>, Jason Merrill <jason at redhat dot com>
- Date: Fri, 19 Jan 2018 14:28:15 +0100
- Subject: Small C++ tweak to fold_simple
- Authentication-results: sourceware.org; auth=none
fold_simple struck me as odd, certainly the NULL_TREE assignment is
unnecessary, so this patch simplifies it a bit.
I've been confused about the commentary too, what is the difference between
"constant-expressions" and "constexpressions"? We should clarify that.
Bootstrapped/regtested on x86_64-linux, ok for trunk?
2018-01-19 Marek Polacek <polacek@redhat.com>
* constexpr.c (fold_simple): Simplify.
diff --git gcc/cp/constexpr.c gcc/cp/constexpr.c
index 9a548d29bbc..ca7f369f7e9 100644
--- gcc/cp/constexpr.c
+++ gcc/cp/constexpr.c
@@ -4931,22 +4931,21 @@ fold_simple_1 (tree t)
}
/* If T is a simple constant expression, returns its simplified value.
- Otherwise returns T. In contrast to maybe_constant_value do we
+ Otherwise returns T. In contrast to maybe_constant_value we
simplify only few operations on constant-expressions, and we don't
try to simplify constexpressions. */
tree
fold_simple (tree t)
{
- tree r = NULL_TREE;
if (processing_template_decl)
return t;
- r = fold_simple_1 (t);
- if (!r)
- r = t;
+ tree r = fold_simple_1 (t);
+ if (r)
+ return r;
- return r;
+ return t;
}
/* If T is a constant expression, returns its reduced value.
Marek