From patchwork Mon May 9 10:19:45 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jiufu Guo X-Patchwork-Id: 53650 Return-Path: X-Original-To: patchwork@sourceware.org Delivered-To: patchwork@sourceware.org Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id 2E406385380D for ; Mon, 9 May 2022 10:20:27 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 2E406385380D DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gcc.gnu.org; s=default; t=1652091627; bh=2GXLLJBSxm5tHk2KYzf7K7YcAKucTV53ytywhb3NSbo=; h=To:Subject:Date:List-Id:List-Unsubscribe:List-Archive:List-Post: List-Help:List-Subscribe:From:Reply-To:Cc:From; b=aTZVfdUc7RkwKvlRdnhITx9fzdNynPLUie6NxQ3bh++XtLwmiS9UeM7ImqqZGccO1 Dnu2D+R/V2lzijab+Gg+U6347oiFr+iXW2I5VtdzdXU6B8nTG8mNOmAjDu44gOWFmP FNZBZtqC4T8zEFPKNNzxXAMP+EY36OxKxZ2i29Eg= X-Original-To: gcc-patches@gcc.gnu.org Delivered-To: gcc-patches@gcc.gnu.org Received: from mx0a-001b2d01.pphosted.com (mx0a-001b2d01.pphosted.com [148.163.156.1]) by sourceware.org (Postfix) with ESMTPS id D66FB3857419; Mon, 9 May 2022 10:19:53 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.1 sourceware.org D66FB3857419 Received: from pps.filterd (m0098399.ppops.net [127.0.0.1]) by mx0a-001b2d01.pphosted.com (8.17.1.5/8.17.1.5) with ESMTP id 249ABoUa006919; Mon, 9 May 2022 10:19:52 GMT Received: from pps.reinject (localhost [127.0.0.1]) by mx0a-001b2d01.pphosted.com (PPS) with ESMTPS id 3fy10684m3-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Mon, 09 May 2022 10:19:52 +0000 Received: from m0098399.ppops.net (m0098399.ppops.net [127.0.0.1]) by pps.reinject (8.17.1.5/8.17.1.5) with ESMTP id 249AJqAs004338; Mon, 9 May 2022 10:19:52 GMT Received: from ppma03ams.nl.ibm.com (62.31.33a9.ip4.static.sl-reverse.com [169.51.49.98]) by mx0a-001b2d01.pphosted.com (PPS) with ESMTPS id 3fy10684k7-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Mon, 09 May 2022 10:19:51 +0000 Received: from pps.filterd (ppma03ams.nl.ibm.com [127.0.0.1]) by ppma03ams.nl.ibm.com (8.16.1.2/8.16.1.2) with SMTP id 249AISjl030211; Mon, 9 May 2022 10:19:49 GMT Received: from b06cxnps3075.portsmouth.uk.ibm.com (d06relay10.portsmouth.uk.ibm.com [9.149.109.195]) by ppma03ams.nl.ibm.com with ESMTP id 3fwgd8tbqu-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Mon, 09 May 2022 10:19:49 +0000 Received: from d06av23.portsmouth.uk.ibm.com (d06av23.portsmouth.uk.ibm.com [9.149.105.59]) by b06cxnps3075.portsmouth.uk.ibm.com (8.14.9/8.14.9/NCO v10.0) with ESMTP id 249AJlId45547992 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Mon, 9 May 2022 10:19:47 GMT Received: from d06av23.portsmouth.uk.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 4012DA4051; Mon, 9 May 2022 10:19:47 +0000 (GMT) Received: from d06av23.portsmouth.uk.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 54550A4053; Mon, 9 May 2022 10:19:46 +0000 (GMT) Received: from genoa.aus.stglabs.ibm.com (unknown [9.40.192.157]) by d06av23.portsmouth.uk.ibm.com (Postfix) with ESMTP; Mon, 9 May 2022 10:19:46 +0000 (GMT) To: gcc-patches@gcc.gnu.org Subject: [PATCH] rs6000: avoid peeking eof after __vector Date: Mon, 9 May 2022 18:19:45 +0800 Message-Id: <20220509101945.3132344-1-guojiufu@linux.ibm.com> X-Mailer: git-send-email 2.25.1 X-TM-AS-GCONF: 00 X-Proofpoint-GUID: E69YDMWWuBVIOF9q_n9u_Q4mn8wUE1jg X-Proofpoint-ORIG-GUID: SC1ywYe8qB5vg0mYXVWXsQGSy-I2IlNm X-Proofpoint-UnRewURL: 0 URL was un-rewritten MIME-Version: 1.0 X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.205,Aquarius:18.0.858,Hydra:6.0.486,FMLib:17.11.64.514 definitions=2022-05-09_03,2022-05-09_01,2022-02-23_01 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 impostorscore=0 suspectscore=0 bulkscore=0 adultscore=0 mlxscore=0 malwarescore=0 mlxlogscore=999 phishscore=0 lowpriorityscore=0 clxscore=1015 priorityscore=1501 spamscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2202240000 definitions=main-2205090057 X-Spam-Status: No, score=-11.1 required=5.0 tests=BAYES_00, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_EF, GIT_PATCH_0, KAM_SHORT, RCVD_IN_MSPIKE_H2, SPF_HELO_NONE, SPF_PASS, TXREP, T_SCC_BODY_TEXT_LINE autolearn=ham autolearn_force=no version=3.4.4 X-Spam-Checker-Version: SpamAssassin 3.4.4 (2020-01-24) on server2.sourceware.org X-BeenThere: gcc-patches@gcc.gnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Gcc-patches mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-Patchwork-Original-From: Jiufu Guo via Gcc-patches From: Jiufu Guo Reply-To: Jiufu Guo Cc: dje.gcc@gmail.com, segher@kernel.crashing.org, linkw@gcc.gnu.org Errors-To: gcc-patches-bounces+patchwork=sourceware.org@gcc.gnu.org Sender: "Gcc-patches" Hi! This patch is based on: https://gcc.gnu.org/pipermail/gcc-patches/2022-March/592102.html And update the 'function comment' to make it consistent with code. There is a rare corner case: where vector is followed only by one valid identifer and the ";" which is near the end of the file. Like the case in PR101168: using vdbl = __vector double; #define BREAK 1 For this case, "vector double" is followed by CPP_SEMICOLON and then EOF. There is no more tokens need to check for this case. This patch pass bootstrap and regtest on ppc64 and ppc64le. BR, Jiufu PR preprocessor/101168 gcc/ChangeLog: * config/rs6000/rs6000-c.cc (rs6000_macro_to_expand): Avoid empty identifier. gcc/testsuite/ChangeLog: * g++.target/powerpc/pr101168.C: New test. --- gcc/config/rs6000/rs6000-c.cc | 9 +++++---- gcc/testsuite/g++.target/powerpc/pr101168.C | 6 ++++++ 2 files changed, 11 insertions(+), 4 deletions(-) create mode 100644 gcc/testsuite/g++.target/powerpc/pr101168.C diff --git a/gcc/config/rs6000/rs6000-c.cc b/gcc/config/rs6000/rs6000-c.cc index 84bb98f94fb..9c8cbd7a66e 100644 --- a/gcc/config/rs6000/rs6000-c.cc +++ b/gcc/config/rs6000/rs6000-c.cc @@ -178,9 +178,8 @@ rid_int128(void) return RID_MAX + 1; } -/* Called to decide whether a conditional macro should be expanded. - Since we have exactly one such macro (i.e, 'vector'), we do not - need to examine the 'tok' parameter. */ +/* Called to decide whether a conditional macro should be expanded + by peeking two or more tokens(_bool/_pixel/int/long/double/...). */ static cpp_hashnode * rs6000_macro_to_expand (cpp_reader *pfile, const cpp_token *tok) @@ -282,7 +281,9 @@ rs6000_macro_to_expand (cpp_reader *pfile, const cpp_token *tok) expand_bool_pixel = __pixel_keyword; else if (ident == C_CPP_HASHNODE (__bool_keyword)) expand_bool_pixel = __bool_keyword; - else + + /* If there are more tokens to check. */ + else if (ident) { /* Try two tokens down, too. */ do diff --git a/gcc/testsuite/g++.target/powerpc/pr101168.C b/gcc/testsuite/g++.target/powerpc/pr101168.C new file mode 100644 index 00000000000..284e77fdc88 --- /dev/null +++ b/gcc/testsuite/g++.target/powerpc/pr101168.C @@ -0,0 +1,6 @@ +/* { dg-do compile } */ +/* { dg-require-effective-target powerpc_altivec_ok } */ +/* { dg-options "-maltivec" } */ + +using vdbl = __vector double; +#define BREAK 1