diff options
author | Jakub Jelinek <jakub@redhat.com> | 2016-12-02 00:15:57 +0100 |
---|---|---|
committer | Jakub Jelinek <jakub@gcc.gnu.org> | 2016-12-02 00:15:57 +0100 |
commit | 0e81719703bf681533220f3629cc4f1a24110778 (patch) | |
tree | 3fb10cf35706062a4e3b6a57086e86beb047be20 /gcc | |
parent | 90ee6453b254cd77819bc30d9d13a3c9828fd1c5 (diff) | |
download | gcc-0e81719703bf681533220f3629cc4f1a24110778.zip gcc-0e81719703bf681533220f3629cc4f1a24110778.tar.gz gcc-0e81719703bf681533220f3629cc4f1a24110778.tar.bz2 |
re PR tree-optimization/78586 (Wrong code caused by printf-return-value)
PR tree-optimization/78586
* gimple-ssa-sprintf.c (format_integer): Don't handle NOP_EXPR,
CONVERT_EXPR or COMPONENT_REF here. Formatting fix. For
SSA_NAME_DEF_STMT with NOP_EXPR only change argtype if the rhs1's
type is INTEGER_TYPE or POINTER_TYPE.
From-SVN: r243145
Diffstat (limited to 'gcc')
-rw-r--r-- | gcc/ChangeLog | 8 | ||||
-rw-r--r-- | gcc/gimple-ssa-sprintf.c | 30 |
2 files changed, 20 insertions, 18 deletions
diff --git a/gcc/ChangeLog b/gcc/ChangeLog index 7f9dd0e..c3170c0 100644 --- a/gcc/ChangeLog +++ b/gcc/ChangeLog @@ -1,3 +1,11 @@ +2016-12-02 Jakub Jelinek <jakub@redhat.com> + + PR tree-optimization/78586 + * gimple-ssa-sprintf.c (format_integer): Don't handle NOP_EXPR, + CONVERT_EXPR or COMPONENT_REF here. Formatting fix. For + SSA_NAME_DEF_STMT with NOP_EXPR only change argtype if the rhs1's + type is INTEGER_TYPE or POINTER_TYPE. + 2016-12-01 Kelvin Nilsen <kelvin@gcc.gnu.org> PR target/78577 diff --git a/gcc/gimple-ssa-sprintf.c b/gcc/gimple-ssa-sprintf.c index 99a635a..e86c4dc 100644 --- a/gcc/gimple-ssa-sprintf.c +++ b/gcc/gimple-ssa-sprintf.c @@ -968,24 +968,13 @@ format_integer (const conversion_spec &spec, tree arg) } else if (TREE_CODE (TREE_TYPE (arg)) == INTEGER_TYPE || TREE_CODE (TREE_TYPE (arg)) == POINTER_TYPE) - { - /* Determine the type of the provided non-constant argument. */ - if (TREE_CODE (arg) == NOP_EXPR) - arg = TREE_OPERAND (arg, 0); - else if (TREE_CODE (arg) == CONVERT_EXPR) - arg = TREE_OPERAND (arg, 0); - if (TREE_CODE (arg) == COMPONENT_REF) - arg = TREE_OPERAND (arg, 1); - - argtype = TREE_TYPE (arg); - } + /* Determine the type of the provided non-constant argument. */ + argtype = TREE_TYPE (arg); else - { - /* Don't bother with invalid arguments since they likely would - have already been diagnosed, and disable any further checking - of the format string by returning [-1, -1]. */ - return fmtresult (); - } + /* Don't bother with invalid arguments since they likely would + have already been diagnosed, and disable any further checking + of the format string by returning [-1, -1]. */ + return fmtresult (); fmtresult res; @@ -1059,7 +1048,12 @@ format_integer (const conversion_spec &spec, tree arg) } if (code == NOP_EXPR) - argtype = TREE_TYPE (gimple_assign_rhs1 (def)); + { + tree type = TREE_TYPE (gimple_assign_rhs1 (def)); + if (TREE_CODE (type) == INTEGER_TYPE + || TREE_CODE (type) == POINTER_TYPE) + argtype = type; + } } } } |