c-pretty-print.cc (pp_c_tree_decl_identifier): Strip private name encoding, PR118303
Checks
Context |
Check |
Description |
linaro-tcwg-bot/tcwg_gcc_build--master-arm |
success
|
Build passed
|
linaro-tcwg-bot/tcwg_gcc_build--master-aarch64 |
success
|
Build passed
|
linaro-tcwg-bot/tcwg_gcc_check--master-arm |
success
|
Test passed
|
linaro-tcwg-bot/tcwg_gcc_check--master-aarch64 |
success
|
Test passed
|
Commit Message
Regtested native x86_64-linux. Also tested mmix-knuth-mmixware,
where it fixes ONE testcase, but one which is a regression on
master. The PR component is currently ipa, changed from the
original middle-end. IIUC this bug-fix doesn't fit the ipa
category IMHO, but rather more general tree-optimization or
rather middle-end, to which I'll change the component unless I
see a reason for this fitting ipa stated.
Ok to commit?
-- >8 --
This is a part of PR118303. It fixes
FAIL: gcc.dg/analyzer/CVE-2005-1689-minimal.c (test for excess errors)
FAIL: gcc.dg/analyzer/CVE-2005-1689-minimal.c inbuf.data (test for warnings, line 62)
for targets where the parameter on that line is subject to
TARGET_CALLEE_COPIES being true.
c-family:
PR middle-end/118303
* c-pretty-print.cc (c_pretty_printer::primary_expression) <SSA_NAME>:
Call primary_expression for all SSA_NAME_VAR nodes and instead move the
DECL_ARTIFICIAL private name stripping to...
(pp_c_tree_decl_identifier): ...here.
---
gcc/c-family/c-pretty-print.cc | 39 +++++++++++++---------------------
1 file changed, 15 insertions(+), 24 deletions(-)
Comments
On 1/6/25 5:01 PM, Hans-Peter Nilsson wrote:
> Regtested native x86_64-linux. Also tested mmix-knuth-mmixware,
> where it fixes ONE testcase, but one which is a regression on
> master. The PR component is currently ipa, changed from the
> original middle-end. IIUC this bug-fix doesn't fit the ipa
> category IMHO, but rather more general tree-optimization or
> rather middle-end, to which I'll change the component unless I
> see a reason for this fitting ipa stated.
>
> Ok to commit?
>
> -- >8 --
> This is a part of PR118303. It fixes
> FAIL: gcc.dg/analyzer/CVE-2005-1689-minimal.c (test for excess errors)
> FAIL: gcc.dg/analyzer/CVE-2005-1689-minimal.c inbuf.data (test for warnings, line 62)
> for targets where the parameter on that line is subject to
> TARGET_CALLEE_COPIES being true.
>
> c-family:
> PR middle-end/118303
> * c-pretty-print.cc (c_pretty_printer::primary_expression) <SSA_NAME>:
> Call primary_expression for all SSA_NAME_VAR nodes and instead move the
> DECL_ARTIFICIAL private name stripping to...
> (pp_c_tree_decl_identifier): ...here.
OK assuming it's successfully gone through the usual regression test
cycle on one of the primary platforms.
jeff
@@ -1398,29 +1398,7 @@ c_pretty_printer::primary_expression (tree e)
case SSA_NAME:
if (SSA_NAME_VAR (e))
- {
- tree var = SSA_NAME_VAR (e);
- if (tree id = SSA_NAME_IDENTIFIER (e))
- {
- const char *name = IDENTIFIER_POINTER (id);
- const char *dot;
- if (DECL_ARTIFICIAL (var) && (dot = strchr (name, '.')))
- {
- /* Print the name without the . suffix (such as in VLAs).
- Use pp_c_identifier so that it can be converted into
- the appropriate encoding. */
- size_t size = dot - name;
- char *ident = XALLOCAVEC (char, size + 1);
- memcpy (ident, name, size);
- ident[size] = '\0';
- pp_c_identifier (this, ident);
- }
- else
- primary_expression (var);
- }
- else
- primary_expression (var);
- }
+ primary_expression (SSA_NAME_VAR (e));
else if (gimple_assign_single_p (SSA_NAME_DEF_STMT (e)))
{
/* Print only the right side of the GIMPLE assignment. */
@@ -3033,7 +3011,20 @@ pp_c_tree_decl_identifier (c_pretty_printer *pp, tree t)
gcc_assert (DECL_P (t));
if (DECL_NAME (t))
- name = IDENTIFIER_POINTER (DECL_NAME (t));
+ {
+ const char *dot;
+ name = IDENTIFIER_POINTER (DECL_NAME (t));
+ if (DECL_ARTIFICIAL (t) && (dot = strchr (name, '.')))
+ {
+ /* Print the name without the . suffix (such as in VLAs and
+ callee-copied parameters). */
+ size_t size = dot - name;
+ char *ident = XALLOCAVEC (char, size + 1);
+ memcpy (ident, name, size);
+ ident[size] = '\0';
+ name = ident;
+ }
+ }
else
{
static char xname[8];