From patchwork Thu May 2 21:39:16 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Andrew Pinski X-Patchwork-Id: 1930886 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@legolas.ozlabs.org Authentication-Results: legolas.ozlabs.org; dkim=pass (2048-bit key; unprotected) header.d=quicinc.com header.i=@quicinc.com header.a=rsa-sha256 header.s=qcppdkim1 header.b=AJvVzjoX; dkim-atps=neutral Authentication-Results: legolas.ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=gcc.gnu.org (client-ip=8.43.85.97; helo=server2.sourceware.org; envelope-from=gcc-patches-bounces+incoming=patchwork.ozlabs.org@gcc.gnu.org; receiver=patchwork.ozlabs.org) Received: from server2.sourceware.org (server2.sourceware.org [8.43.85.97]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (secp384r1) server-digest SHA384) (No client certificate requested) by legolas.ozlabs.org (Postfix) with ESMTPS id 4VVnQm6P07z213v for ; Fri, 3 May 2024 07:40:00 +1000 (AEST) Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id 1DE983849AFB for ; Thu, 2 May 2024 21:39:58 +0000 (GMT) X-Original-To: gcc-patches@gcc.gnu.org Delivered-To: gcc-patches@gcc.gnu.org Received: from mx0b-0031df01.pphosted.com (mx0b-0031df01.pphosted.com [205.220.180.131]) by sourceware.org (Postfix) with ESMTPS id A0CC8384AB78 for ; Thu, 2 May 2024 21:39:30 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org A0CC8384AB78 Authentication-Results: sourceware.org; dmarc=pass (p=none dis=none) header.from=quicinc.com Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=quicinc.com ARC-Filter: OpenARC Filter v1.0.0 sourceware.org A0CC8384AB78 Authentication-Results: server2.sourceware.org; arc=none smtp.remote-ip=205.220.180.131 ARC-Seal: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1714685973; cv=none; b=scBq39YSpXhYjHc0rYCYitV7FGjWzBRownSGEnwt/10DtLLnRpX1Pn8XJgQiNl0wDzuKL73KwUA8EjOKBiGt5fh+LDBENl2nHW5Rtx4T6pcbCSEgAbUldl6rwsKQ2F4ZKj9MF1UTLgv9SWoe317ZgbbHPzPhceUeqqZsnTiiIGs= ARC-Message-Signature: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1714685973; c=relaxed/simple; bh=tLa4bDYtiJwUmnMudIKrHu5SsCxs29uGtfO1HtPVLvU=; h=DKIM-Signature:From:To:Subject:Date:Message-ID:MIME-Version; b=v6hALdTHlfgZzzhcmzsGgNuy94aRULjj0kgteI/sy8v02yduRTW2k8Szwg6SXf4W3BLisDNEsINrdLGLklVLmlH3jhj7iUueDc0PTZMB/6W3lqUQp89PN5cvINUCxmhsUhGWNK98Dl6LiPgCkMxedaJHpKOX2qAMWKEVkN52T9I= ARC-Authentication-Results: i=1; server2.sourceware.org Received: from pps.filterd (m0279872.ppops.net [127.0.0.1]) by mx0a-0031df01.pphosted.com (8.18.1.2/8.18.1.2) with ESMTP id 442LRw7t005286 for ; Thu, 2 May 2024 21:39:30 GMT DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=quicinc.com; h= from:to:cc:subject:date:message-id:mime-version :content-transfer-encoding:content-type; s=qcppdkim1; bh=LBEkh6U sUYP++6gBf25iqfAQsbVqUbNLAFmMJatr+oM=; b=AJvVzjoXiFgKuuNcSCtBQ7z K6+yX4epxbM1svC5/MYBKoi8EHpbR2AzbWHqnmplrWLL/95r0RrdDO3EM2D2Bb6/ 7DIzn2yfUd22R/vZUgEJmmeHYRwqcLEgem0+iJmelICkNaB/758Cxmwmk+zxshQp b8h3w7f1zA1WJ1N55EBTidWSP6G3sh9pbC9eeoiBHwpseh7+Oov+iudXCHIdDy4R Yox13hrXb1ro+7v5oTFmgZsJukwPVHALAGM+9oL6RpBOdwsufi9+FyME48WrsFWj DER8rcU4qdYvF62CTDBkgSEX+4kG0iJRoz0Hyyy3yalalzy8nUXGoTkKVb7UHLg= = Received: from nasanppmta01.qualcomm.com (i-global254.qualcomm.com [199.106.103.254]) by mx0a-0031df01.pphosted.com (PPS) with ESMTPS id 3xv8vs9dbc-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT) for ; Thu, 02 May 2024 21:39:29 +0000 (GMT) Received: from nasanex01c.na.qualcomm.com (nasanex01c.na.qualcomm.com [10.45.79.139]) by NASANPPMTA01.qualcomm.com (8.17.1.5/8.17.1.5) with ESMTPS id 442LdSde032290 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT) for ; Thu, 2 May 2024 21:39:28 GMT Received: from hu-apinski-lv.qualcomm.com (10.49.16.6) by nasanex01c.na.qualcomm.com (10.45.79.139) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.1544.9; Thu, 2 May 2024 14:39:28 -0700 From: Andrew Pinski To: CC: Andrew Pinski Subject: [PATCH 1/3] Fix printing COMPOUND_EXPR in .original [PR23872] Date: Thu, 2 May 2024 14:39:16 -0700 Message-ID: <20240502213918.2029860-1-quic_apinski@quicinc.com> X-Mailer: git-send-email 2.34.1 MIME-Version: 1.0 X-Originating-IP: [10.49.16.6] X-ClientProxiedBy: nalasex01b.na.qualcomm.com (10.47.209.197) To nasanex01c.na.qualcomm.com (10.45.79.139) X-QCInternal: smtphost X-Proofpoint-Virus-Version: vendor=nai engine=6200 definitions=5800 signatures=585085 X-Proofpoint-ORIG-GUID: yugnEFnon3KDkMGABRspUlCh3FSIlwcD X-Proofpoint-GUID: yugnEFnon3KDkMGABRspUlCh3FSIlwcD X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.293,Aquarius:18.0.1011,Hydra:6.0.650,FMLib:17.11.176.26 definitions=2024-05-02_13,2024-05-02_03,2023-05-22_02 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 mlxlogscore=489 suspectscore=0 priorityscore=1501 mlxscore=0 spamscore=0 adultscore=0 impostorscore=0 lowpriorityscore=0 bulkscore=0 malwarescore=0 phishscore=0 clxscore=1015 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.19.0-2404010003 definitions=main-2405020143 X-Spam-Status: No, score=-13.4 required=5.0 tests=BAYES_00, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, DKIM_VALID_EF, GIT_PATCH_0, SPF_HELO_NONE, SPF_PASS, TXREP autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on server2.sourceware.org X-BeenThere: gcc-patches@gcc.gnu.org X-Mailman-Version: 2.1.30 Precedence: list List-Id: Gcc-patches mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: gcc-patches-bounces+incoming=patchwork.ozlabs.org@gcc.gnu.org Starting with the merge of the openmp branch into the trunk (r0-73077-g953ff28998b59b), COMPOUND_EXPR started to be printed as `expr; , expr` which is wrong. This was due to the wrong conversion of dumping_stmts into `!(flags & TDF_SLIM)`. That is wrong as we are not dumping stmts at this point (`!(flags & TDF_SLIM)` was always true for this case as TDF_SLIM case was handled before hand). So switch it to be always false. Bootstrapped and tested on x86_64-linux-gnu with no regressions. gcc/ChangeLog: PR middle-end/23872 * tree-pretty-print.cc (dump_generic_node ): Fix calls to dump_generic_node and also remove unreachable code that is testing `flags & TDF_SLIM`. gcc/testsuite/ChangeLog: * gfortran.dg/gomp/atomic-21.f90: Update testcase for the removal of `;`. Signed-off-by: Andrew Pinski --- gcc/testsuite/gfortran.dg/gomp/atomic-21.f90 | 4 ++-- gcc/tree-pretty-print.cc | 24 ++++++-------------- 2 files changed, 9 insertions(+), 19 deletions(-) diff --git a/gcc/testsuite/gfortran.dg/gomp/atomic-21.f90 b/gcc/testsuite/gfortran.dg/gomp/atomic-21.f90 index febcdbbacfb..35099294d7a 100644 --- a/gcc/testsuite/gfortran.dg/gomp/atomic-21.f90 +++ b/gcc/testsuite/gfortran.dg/gomp/atomic-21.f90 @@ -56,7 +56,7 @@ subroutine foobar() endif ! TARGET_EXPR = #pragma omp atomic capture acq_rel -! TARGET_EXPR = NON_LVALUE_EXPR = *TARGET_EXPR == oo> ? pp : *TARGET_EXPR ;, if (TARGET_EXPR ) +! TARGET_EXPR = NON_LVALUE_EXPR = *TARGET_EXPR == oo> ? pp : *TARGET_EXPR , if (TARGET_EXPR ) ! { ! <<< Unknown tree: void_cst >>> ! } @@ -66,7 +66,7 @@ subroutine foobar() ! }; ! ! { dg-final { scan-tree-dump-times "TARGET_EXPR = #pragma omp atomic capture acq_rel" 1 "original" } } -! { dg-final { scan-tree-dump-times "TARGET_EXPR = NON_LVALUE_EXPR = \\*TARGET_EXPR == oo> \\? pp : \\*TARGET_EXPR ;, if \\(TARGET_EXPR \\)" 1 "original" } } +! { dg-final { scan-tree-dump-times "TARGET_EXPR = NON_LVALUE_EXPR = \\*TARGET_EXPR == oo> \\? pp : \\*TARGET_EXPR , if \\(TARGET_EXPR \\)" 1 "original" } } ! { dg-final { scan-tree-dump-times "<<< Unknown tree: void_cst >>>" 1 "original" } } ! { dg-final { scan-tree-dump-times "qq = TARGET_EXPR ;" 1 "original" } } diff --git a/gcc/tree-pretty-print.cc b/gcc/tree-pretty-print.cc index c935a7da7d1..f9ad8562078 100644 --- a/gcc/tree-pretty-print.cc +++ b/gcc/tree-pretty-print.cc @@ -2856,31 +2856,21 @@ dump_generic_node (pretty_printer *pp, tree node, int spc, dump_flags_t flags, } dump_generic_node (pp, TREE_OPERAND (node, 0), - spc, flags, !(flags & TDF_SLIM)); - if (flags & TDF_SLIM) - newline_and_indent (pp, spc); - else - { - pp_comma (pp); - pp_space (pp); - } + spc, flags, false); + pp_comma (pp); + pp_space (pp); for (tp = &TREE_OPERAND (node, 1); TREE_CODE (*tp) == COMPOUND_EXPR; tp = &TREE_OPERAND (*tp, 1)) { dump_generic_node (pp, TREE_OPERAND (*tp, 0), - spc, flags, !(flags & TDF_SLIM)); - if (flags & TDF_SLIM) - newline_and_indent (pp, spc); - else - { - pp_comma (pp); - pp_space (pp); - } + spc, flags, false); + pp_comma (pp); + pp_space (pp); } - dump_generic_node (pp, *tp, spc, flags, !(flags & TDF_SLIM)); + dump_generic_node (pp, *tp, spc, flags, false); } break; From patchwork Thu May 2 21:39:17 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Andrew Pinski X-Patchwork-Id: 1930887 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@legolas.ozlabs.org Authentication-Results: legolas.ozlabs.org; dkim=pass (2048-bit key; unprotected) header.d=quicinc.com header.i=@quicinc.com header.a=rsa-sha256 header.s=qcppdkim1 header.b=arHxmvWo; dkim-atps=neutral Authentication-Results: legolas.ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=gcc.gnu.org (client-ip=2620:52:3:1:0:246e:9693:128c; helo=server2.sourceware.org; envelope-from=gcc-patches-bounces+incoming=patchwork.ozlabs.org@gcc.gnu.org; receiver=patchwork.ozlabs.org) Received: from server2.sourceware.org (server2.sourceware.org [IPv6:2620:52:3:1:0:246e:9693:128c]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (secp384r1) server-digest SHA384) (No client certificate requested) by legolas.ozlabs.org (Postfix) with ESMTPS id 4VVnQv5bnzz20fW for ; Fri, 3 May 2024 07:40:07 +1000 (AEST) Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id 00CAA3844748 for ; Thu, 2 May 2024 21:40:06 +0000 (GMT) X-Original-To: gcc-patches@gcc.gnu.org Delivered-To: gcc-patches@gcc.gnu.org Received: from mx0a-0031df01.pphosted.com (mx0a-0031df01.pphosted.com [205.220.168.131]) by sourceware.org (Postfix) with ESMTPS id A34F63846400 for ; Thu, 2 May 2024 21:39:41 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org A34F63846400 Authentication-Results: sourceware.org; dmarc=pass (p=none dis=none) header.from=quicinc.com Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=quicinc.com ARC-Filter: OpenARC Filter v1.0.0 sourceware.org A34F63846400 Authentication-Results: server2.sourceware.org; arc=none smtp.remote-ip=205.220.168.131 ARC-Seal: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1714685983; cv=none; b=C9/9V3q5cvZWOIV6WqYPItEsxRpknVOK2sHDiSHof07i2FTWe2mQxC4UOro4haL/5+sXYF16Sq7NaCqxKsG74n5Pc6KLwbcN0oS7begYUMXQzlBWqX1ZtqNw2mF6R/UWBNyg/1kheG9uy4jTVo+HtjZk888JHLtxPzWV21hcPd8= ARC-Message-Signature: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1714685983; c=relaxed/simple; bh=b3vU463d3/vyEO7corJ2BsTeAAbvMR0EsugE9AaJW1k=; h=DKIM-Signature:From:To:Subject:Date:Message-ID:MIME-Version; b=VmtO/j1WY/r78YgOfw3ytKhUe55xA+wJaQOmWWNSz18U+8hCQ68AUjcDtKNPEX9d633Gd42/541ZnNWS2g75fPKqwLGY7qz2Zv8W26ueOZNUEcWP3nnVp/E/yHHqsFi6KwHI5V2ka9wBgRt2n2LuRkWE2Bydhgebu2ZXwNIZLG8= ARC-Authentication-Results: i=1; server2.sourceware.org Received: from pps.filterd (m0279866.ppops.net [127.0.0.1]) by mx0a-0031df01.pphosted.com (8.18.1.2/8.18.1.2) with ESMTP id 442LcInH000754 for ; Thu, 2 May 2024 21:39:40 GMT DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=quicinc.com; h= from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding:content-type; s= qcppdkim1; bh=dKaj7aha9sNP5noPthVNSvcMu7H0PJRP3IYMHipOfmU=; b=ar HxmvWoGIdt/NCQnHY1BzyDMf/aJPfeZQNl4RQShcJU4aCsaxrJ2FGI7nI7wSGYOi FDCXQTf87G2GxQevRRu6gfhWHTC0FIU8Xk0kk2QTGiovovX2kAYV26L01T6O/DU/ H7BmZEdlFWMBQivamTG5zI0+ViERuGaGVNMM3DybCxounLsQbGkYcp8imTDFGz6Y EQpfmM+2NsM/TlkAloB2hkplVi9Nj73tY6xONWeFkEN4IynBzsqsDwEWZXVdcNDT wlm6oQ87bXg0lKDbdpORCGZ3s5EqVMGG1b7ThwVRd9RdtDYVo3+PWIO+3iBkwoqp 7nVK4e0fEMbWJ/5RnO7w== Received: from nasanppmta03.qualcomm.com (i-global254.qualcomm.com [199.106.103.254]) by mx0a-0031df01.pphosted.com (PPS) with ESMTPS id 3xvawbh60b-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT) for ; Thu, 02 May 2024 21:39:40 +0000 (GMT) Received: from nasanex01c.na.qualcomm.com (nasanex01c.na.qualcomm.com [10.45.79.139]) by NASANPPMTA03.qualcomm.com (8.17.1.5/8.17.1.5) with ESMTPS id 442LdTt5011400 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT) for ; Thu, 2 May 2024 21:39:29 GMT Received: from hu-apinski-lv.qualcomm.com (10.49.16.6) by nasanex01c.na.qualcomm.com (10.45.79.139) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.1544.9; Thu, 2 May 2024 14:39:29 -0700 From: Andrew Pinski To: CC: Andrew Pinski Subject: [PATCH 2/3] Improve DECL_EXPR printing in .original [PR23872] Date: Thu, 2 May 2024 14:39:17 -0700 Message-ID: <20240502213918.2029860-2-quic_apinski@quicinc.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20240502213918.2029860-1-quic_apinski@quicinc.com> References: <20240502213918.2029860-1-quic_apinski@quicinc.com> MIME-Version: 1.0 X-Originating-IP: [10.49.16.6] X-ClientProxiedBy: nalasex01b.na.qualcomm.com (10.47.209.197) To nasanex01c.na.qualcomm.com (10.45.79.139) X-QCInternal: smtphost X-Proofpoint-Virus-Version: vendor=nai engine=6200 definitions=5800 signatures=585085 X-Proofpoint-GUID: VNMm6KnXFN2IK93MgP3JTi3QkI-9k0zy X-Proofpoint-ORIG-GUID: VNMm6KnXFN2IK93MgP3JTi3QkI-9k0zy X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.293,Aquarius:18.0.1011,Hydra:6.0.650,FMLib:17.11.176.26 definitions=2024-05-02_13,2024-05-02_03,2023-05-22_02 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 mlxscore=0 phishscore=0 malwarescore=0 bulkscore=0 suspectscore=0 priorityscore=1501 impostorscore=0 lowpriorityscore=0 spamscore=0 clxscore=1015 adultscore=0 mlxlogscore=675 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.19.0-2404010003 definitions=main-2405020145 X-Spam-Status: No, score=-13.4 required=5.0 tests=BAYES_00, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, DKIM_VALID_EF, GIT_PATCH_0, SPF_HELO_NONE, SPF_PASS, TXREP autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on server2.sourceware.org X-BeenThere: gcc-patches@gcc.gnu.org X-Mailman-Version: 2.1.30 Precedence: list List-Id: Gcc-patches mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: gcc-patches-bounces+incoming=patchwork.ozlabs.org@gcc.gnu.org Right now we don't print that a DECL_EXPR and we get basically double output of the decls and it looks confusing. This fixes that. for the simple example: `void foo () { int result = 0;}` This gives: ``` { int result = 0; DECL_EXPR; } ``` Bootstrapped and tested on x86_64-linux-gnu with no regressions. gcc/ChangeLog: * tree-pretty-print.cc (dump_generic_node ): Print out `DECL_EXPR<...>` around the decl and update the call to print_declaration to pass false for new argument and pass 0 for the spacing. (print_declaration): Add argument is_stmt and don't print a semicolon nor the initializer. * tree-pretty-print.h (print_declaration): Add bool argument and default it to true. Signed-off-by: Andrew Pinski --- gcc/tree-pretty-print.cc | 18 +++++++++++------- gcc/tree-pretty-print.h | 2 +- 2 files changed, 12 insertions(+), 8 deletions(-) diff --git a/gcc/tree-pretty-print.cc b/gcc/tree-pretty-print.cc index f9ad8562078..825ba74443b 100644 --- a/gcc/tree-pretty-print.cc +++ b/gcc/tree-pretty-print.cc @@ -2917,8 +2917,9 @@ dump_generic_node (pretty_printer *pp, tree node, int spc, dump_flags_t flags, break; case DECL_EXPR: - print_declaration (pp, DECL_EXPR_DECL (node), spc, flags); - is_stmt = false; + pp_string (pp, "DECL_EXPR<"); + print_declaration (pp, DECL_EXPR_DECL (node), 0, flags, false); + pp_greater (pp); break; case COND_EXPR: @@ -4151,10 +4152,11 @@ dump_generic_node (pretty_printer *pp, tree node, int spc, dump_flags_t flags, return spc; } -/* Print the declaration of a variable. */ +/* Print the declaration of a variable, T to PP starting with SPC spaces with FLAGS + and called as IS_STMT a statement or not. */ void -print_declaration (pretty_printer *pp, tree t, int spc, dump_flags_t flags) +print_declaration (pretty_printer *pp, tree t, int spc, dump_flags_t flags, bool is_stmt) { INDENT (spc); @@ -4162,7 +4164,8 @@ print_declaration (pretty_printer *pp, tree t, int spc, dump_flags_t flags) { pp_string(pp, "namelist "); dump_decl_name (pp, t, flags); - pp_semicolon (pp); + if (is_stmt) + pp_semicolon (pp); return; } @@ -4231,7 +4234,7 @@ print_declaration (pretty_printer *pp, tree t, int spc, dump_flags_t flags) if (TREE_CODE (t) != FUNCTION_DECL) { /* Print the initial value. */ - if (DECL_INITIAL (t)) + if (DECL_INITIAL (t) && is_stmt) { pp_space (pp); pp_equal (pp); @@ -4250,7 +4253,8 @@ print_declaration (pretty_printer *pp, tree t, int spc, dump_flags_t flags) pp_right_bracket (pp); } - pp_semicolon (pp); + if (is_stmt) + pp_semicolon (pp); } diff --git a/gcc/tree-pretty-print.h b/gcc/tree-pretty-print.h index 0da6242629b..660c17410a9 100644 --- a/gcc/tree-pretty-print.h +++ b/gcc/tree-pretty-print.h @@ -47,7 +47,7 @@ extern void dump_omp_loop_non_rect_expr (pretty_printer *, tree, int, dump_flags_t); extern void print_omp_context_selector (FILE *, tree, dump_flags_t); extern int dump_generic_node (pretty_printer *, tree, int, dump_flags_t, bool); -extern void print_declaration (pretty_printer *, tree, int, dump_flags_t); +extern void print_declaration (pretty_printer *, tree, int, dump_flags_t, bool = true); extern int op_code_prio (enum tree_code); extern int op_prio (const_tree); extern const char *op_symbol_code (enum tree_code, dump_flags_t = TDF_NONE); From patchwork Thu May 2 21:39:18 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Andrew Pinski X-Patchwork-Id: 1930885 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@legolas.ozlabs.org Authentication-Results: legolas.ozlabs.org; dkim=pass (2048-bit key; unprotected) header.d=quicinc.com header.i=@quicinc.com header.a=rsa-sha256 header.s=qcppdkim1 header.b=CFRuyMfz; dkim-atps=neutral Authentication-Results: legolas.ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=gcc.gnu.org (client-ip=8.43.85.97; helo=server2.sourceware.org; envelope-from=gcc-patches-bounces+incoming=patchwork.ozlabs.org@gcc.gnu.org; receiver=patchwork.ozlabs.org) Received: from server2.sourceware.org (server2.sourceware.org [8.43.85.97]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (secp384r1) server-digest SHA384) (No client certificate requested) by legolas.ozlabs.org (Postfix) with ESMTPS id 4VVnQm5bg6z20fb for ; Fri, 3 May 2024 07:40:00 +1000 (AEST) Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id 7E1BB3846070 for ; Thu, 2 May 2024 21:39:57 +0000 (GMT) X-Original-To: gcc-patches@gcc.gnu.org Delivered-To: gcc-patches@gcc.gnu.org Received: from mx0b-0031df01.pphosted.com (mx0b-0031df01.pphosted.com [205.220.180.131]) by sourceware.org (Postfix) with ESMTPS id 999EF384AB69 for ; Thu, 2 May 2024 21:39:31 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 999EF384AB69 Authentication-Results: sourceware.org; dmarc=pass (p=none dis=none) header.from=quicinc.com Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=quicinc.com ARC-Filter: OpenARC Filter v1.0.0 sourceware.org 999EF384AB69 Authentication-Results: server2.sourceware.org; arc=none smtp.remote-ip=205.220.180.131 ARC-Seal: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1714685973; cv=none; b=uUAWwcfDJCGAHaB3LEChz4yKH5oOuP3tIZKDYNUO6xwFThG67iavkTczX9NuFe5Lvf/MZ/cbedjZ/E2sX9StXYz2V3k2qJP/N48NEJl9vHmjCT0DHGTzW5nuPUmFKiWh0BfqPtTDdCkWT/+5frvhdPKOQVGAu+so/59SnCbmF6Q= ARC-Message-Signature: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1714685973; c=relaxed/simple; bh=TucGQFlMcO+AihQ/eAF1VQFD3ySWcZgSjBxC7SI4naI=; h=DKIM-Signature:From:To:Subject:Date:Message-ID:MIME-Version; b=ZLdPrICyyMEe7OaRE0D6eMkxjX9VK5Xf2BcPrnqrFP4YoGMVMzsivYZD/YLMqTDZDaeibesYZkt0JwZSb4rnSGWFMH+hrz1GXYiRkN57F85VvaCzkDWfKncbWxjjMcCbOOutLKhr6tnZNR6hQoTzw9zs9iyRDLbKOKpvjARZZwQ= ARC-Authentication-Results: i=1; server2.sourceware.org Received: from pps.filterd (m0279873.ppops.net [127.0.0.1]) by mx0a-0031df01.pphosted.com (8.18.1.2/8.18.1.2) with ESMTP id 442LScvs010479 for ; Thu, 2 May 2024 21:39:31 GMT DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=quicinc.com; h= from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding:content-type; s= qcppdkim1; bh=Zb1PAaxPhDdXdCz4XKOINftLdVWDlVmeL0EDdi2xlZo=; b=CF RuyMfzC/AsLivwmACZA2Keul5KlOvAGiAh+bFop+QWd4REwmSYp9t9LYPiqB5qSX +skVkqsSAbldrxP/fIoEj0d0a5G2Sa01xMcPXILkNs6kd1l0rcLHW1H6w2gM5FJt ql1QThcpPKIhjNJ+5+vu2d144/j2i2r8L2jiSLQsl+Or0nbxP7/hYiasRk2en+Np AGc5ThvHjRU04XYHfZ1kYRQJ4TMse8zT4wCMPBtdzwUzQN4XytOM5DJpPIq5QvZq q6l3HEudW2x5HCeV4bcjaaDGffMjXbpKz+FQ4fQ0sS/Hkp+09UeMhBNTWwdtQ2KZ OpwjXC+lKqdM0fofZJaA== Received: from nasanppmta02.qualcomm.com (i-global254.qualcomm.com [199.106.103.254]) by mx0a-0031df01.pphosted.com (PPS) with ESMTPS id 3xurt736fa-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT) for ; Thu, 02 May 2024 21:39:31 +0000 (GMT) Received: from nasanex01c.na.qualcomm.com (nasanex01c.na.qualcomm.com [10.45.79.139]) by NASANPPMTA02.qualcomm.com (8.17.1.5/8.17.1.5) with ESMTPS id 442LdTHt028756 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT) for ; Thu, 2 May 2024 21:39:29 GMT Received: from hu-apinski-lv.qualcomm.com (10.49.16.6) by nasanex01c.na.qualcomm.com (10.45.79.139) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.1544.9; Thu, 2 May 2024 14:39:29 -0700 From: Andrew Pinski To: CC: Andrew Pinski Subject: [PATCH 3/3] Add parentheses around DECL_INIT for .original [PR23872] Date: Thu, 2 May 2024 14:39:18 -0700 Message-ID: <20240502213918.2029860-3-quic_apinski@quicinc.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20240502213918.2029860-1-quic_apinski@quicinc.com> References: <20240502213918.2029860-1-quic_apinski@quicinc.com> MIME-Version: 1.0 X-Originating-IP: [10.49.16.6] X-ClientProxiedBy: nalasex01b.na.qualcomm.com (10.47.209.197) To nasanex01c.na.qualcomm.com (10.45.79.139) X-QCInternal: smtphost X-Proofpoint-Virus-Version: vendor=nai engine=6200 definitions=5800 signatures=585085 X-Proofpoint-GUID: vxlG_Ocs7Sa1FXF16yVcgS7xP68DImPj X-Proofpoint-ORIG-GUID: vxlG_Ocs7Sa1FXF16yVcgS7xP68DImPj X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.293,Aquarius:18.0.1011,Hydra:6.0.650,FMLib:17.11.176.26 definitions=2024-05-02_13,2024-05-02_03,2023-05-22_02 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 mlxlogscore=678 clxscore=1015 suspectscore=0 priorityscore=1501 mlxscore=0 lowpriorityscore=0 phishscore=0 spamscore=0 bulkscore=0 malwarescore=0 impostorscore=0 adultscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.19.0-2404010003 definitions=main-2405020143 X-Spam-Status: No, score=-13.3 required=5.0 tests=BAYES_00, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, DKIM_VALID_EF, GIT_PATCH_0, SPF_HELO_NONE, SPF_PASS, TXREP autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on server2.sourceware.org X-BeenThere: gcc-patches@gcc.gnu.org X-Mailman-Version: 2.1.30 Precedence: list List-Id: Gcc-patches mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: gcc-patches-bounces+incoming=patchwork.ozlabs.org@gcc.gnu.org When we have : `void f (int y, int z) { int x = ( z++,y); }` This would have printed the decl's initializer without parentheses which can confusion if you think that is defining another variable rather than the compound expression. This adds parenthese around DECL_INIT if it was a COMPOUND_EXPR. Bootstrapped and tested on x86_64-linux-gnu. gcc/ChangeLog: * tree-pretty-print.cc (print_declaration): Add parenthese around DECL_INIT if it was a COMPOUND_EXPR. Signed-off-by: Andrew Pinski --- gcc/tree-pretty-print.cc | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/gcc/tree-pretty-print.cc b/gcc/tree-pretty-print.cc index 825ba74443b..8b766dcd2b8 100644 --- a/gcc/tree-pretty-print.cc +++ b/gcc/tree-pretty-print.cc @@ -4240,7 +4240,14 @@ print_declaration (pretty_printer *pp, tree t, int spc, dump_flags_t flags, bool pp_equal (pp); pp_space (pp); if (!(flags & TDF_SLIM)) - dump_generic_node (pp, DECL_INITIAL (t), spc, flags, false); + { + bool need_paren = TREE_CODE (DECL_INITIAL (t)) == COMPOUND_EXPR; + if (need_paren) + pp_left_paren (pp); + dump_generic_node (pp, DECL_INITIAL (t), spc, flags, false); + if (need_paren) + pp_right_paren (pp); + } else pp_string (pp, "<<< omitted >>>"); }