aboutsummaryrefslogtreecommitdiff
path: root/gcc
diff options
context:
space:
mode:
authorJonathan Wakely <jwakely@redhat.com>2018-05-30 09:18:33 +0100
committerJonathan Wakely <redi@gcc.gnu.org>2018-05-30 09:18:33 +0100
commitb005486b25cf42a55c418830a4007c83b42c1625 (patch)
tree8c1016f38e8b35c7091b9aa57680371b53843156 /gcc
parent6e246559b842b9fc561f5ce6eefa08912dd4f7fd (diff)
downloadgcc-b005486b25cf42a55c418830a4007c83b42c1625.zip
gcc-b005486b25cf42a55c418830a4007c83b42c1625.tar.gz
gcc-b005486b25cf42a55c418830a4007c83b42c1625.tar.bz2
Replace dead store with early return
* typeck.c (cxx_sizeof_or_alignof_type): Return size_one_node instead of using it in dead store. From-SVN: r260920
Diffstat (limited to 'gcc')
-rw-r--r--gcc/cp/ChangeLog5
-rw-r--r--gcc/cp/typeck.c17
2 files changed, 13 insertions, 9 deletions
diff --git a/gcc/cp/ChangeLog b/gcc/cp/ChangeLog
index e94615f..37874c0 100644
--- a/gcc/cp/ChangeLog
+++ b/gcc/cp/ChangeLog
@@ -1,3 +1,8 @@
+2018-05-30 Jonathan Wakely <jwakely@redhat.com>
+
+ * typeck.c (cxx_sizeof_or_alignof_type): Return size_one_node instead
+ of using it in dead store.
+
2018-05-29 Jason Merrill <jason@redhat.com>
PR c++/67445 - returning temporary initializer_list.
diff --git a/gcc/cp/typeck.c b/gcc/cp/typeck.c
index 25d11f5..9febdb9 100644
--- a/gcc/cp/typeck.c
+++ b/gcc/cp/typeck.c
@@ -1597,9 +1597,6 @@ tree
cxx_sizeof_or_alignof_type (tree type, enum tree_code op, bool std_alignof,
bool complain)
{
- tree value;
- bool dependent_p;
-
gcc_assert (op == SIZEOF_EXPR || op == ALIGNOF_EXPR);
if (type == error_mark_node)
return error_mark_node;
@@ -1608,15 +1605,17 @@ cxx_sizeof_or_alignof_type (tree type, enum tree_code op, bool std_alignof,
if (TREE_CODE (type) == METHOD_TYPE)
{
if (complain)
- pedwarn (input_location, OPT_Wpointer_arith,
- "invalid application of %qs to a member function",
- OVL_OP_INFO (false, op)->name);
+ {
+ pedwarn (input_location, OPT_Wpointer_arith,
+ "invalid application of %qs to a member function",
+ OVL_OP_INFO (false, op)->name);
+ return size_one_node;
+ }
else
return error_mark_node;
- value = size_one_node;
}
- dependent_p = dependent_type_p (type);
+ bool dependent_p = dependent_type_p (type);
if (!dependent_p)
complete_type (type);
if (dependent_p
@@ -1630,7 +1629,7 @@ cxx_sizeof_or_alignof_type (tree type, enum tree_code op, bool std_alignof,
&& COMPLETE_TYPE_P (type)
&& TREE_CODE (TYPE_SIZE (type)) != INTEGER_CST))
{
- value = build_min (op, size_type_node, type);
+ tree value = build_min (op, size_type_node, type);
TREE_READONLY (value) = 1;
if (op == ALIGNOF_EXPR && std_alignof)
ALIGNOF_EXPR_STD_P (value) = true;