* Small C++ tweak to fold_simple
@ 2018-01-19 13:47 Marek Polacek
2018-01-19 20:24 ` Jason Merrill
0 siblings, 1 reply; 2+ messages in thread
From: Marek Polacek @ 2018-01-19 13:47 UTC (permalink / raw)
To: GCC Patches, Jason Merrill
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
^ permalink raw reply [flat|nested] 2+ messages in thread
* Re: Small C++ tweak to fold_simple
2018-01-19 13:47 Small C++ tweak to fold_simple Marek Polacek
@ 2018-01-19 20:24 ` Jason Merrill
0 siblings, 0 replies; 2+ messages in thread
From: Jason Merrill @ 2018-01-19 20:24 UTC (permalink / raw)
To: Marek Polacek; +Cc: GCC Patches
On Fri, Jan 19, 2018 at 8:28 AM, Marek Polacek <polacek@redhat.com> wrote:
> fold_simple struck me as odd, certainly the NULL_TREE assignment is
> unnecessary, so this patch simplifies it a bit.
OK.
> I've been confused about the commentary too, what is the difference between
> "constant-expressions" and "constexpressions"? We should clarify that.
I have no idea, I think it's probably an editing mistake that can be removed.
Jason
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2018-01-19 20:02 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2018-01-19 13:47 Small C++ tweak to fold_simple Marek Polacek
2018-01-19 20:24 ` Jason Merrill
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).