From patchwork Mon Oct 30 14:38:19 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jan Beulich X-Patchwork-Id: 78754 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 D45AF385772B for ; Mon, 30 Oct 2023 14:38:37 +0000 (GMT) X-Original-To: binutils@sourceware.org Delivered-To: binutils@sourceware.org Received: from EUR01-DB5-obe.outbound.protection.outlook.com (mail-db5eur01on2088.outbound.protection.outlook.com [40.107.15.88]) by sourceware.org (Postfix) with ESMTPS id E5A2D3858D20 for ; Mon, 30 Oct 2023 14:38:20 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org E5A2D3858D20 Authentication-Results: sourceware.org; dmarc=pass (p=quarantine dis=none) header.from=suse.com Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=suse.com ARC-Filter: OpenARC Filter v1.0.0 sourceware.org E5A2D3858D20 Authentication-Results: server2.sourceware.org; arc=pass smtp.remote-ip=40.107.15.88 ARC-Seal: i=2; a=rsa-sha256; d=sourceware.org; s=key; t=1698676702; cv=pass; b=hkAohD/cCRmp6TNuiJ6Z6vK2xZqVmIu+52w6ZZrypQtsQCJQvVbuUjXOWNCUIZfOo5EJdOcIceclPext9QFfYM5NgEdyHGCGP05CdL3+AD/6dW8ELBQ8AnuUuqmXSzSt1KC1FMaH5eOdNXcimScJ0CxfGNpd/U3AwAHO54KqTsA= ARC-Message-Signature: i=2; a=rsa-sha256; d=sourceware.org; s=key; t=1698676702; c=relaxed/simple; bh=hIJPqmcgV62kiz/UQh+4+cilp1FkWWfmBk+hNUj/SHU=; h=DKIM-Signature:Message-ID:Date:To:From:Subject:MIME-Version; b=K3dH8z9ePoVwGfrPaLcFFLvzcTiCEYreZJJjY9wKM9I1h2XlgTOdwffKH/yRlxCd/pIW11ArhuUJMgYE7JJL0TyLiDgIor2EcwDoYoj24yen341ze/o4SMsuN2EvD9JbEfEFUf8pCGatnaZnLGymXac9idNRdlcnymOjIm7BySs= ARC-Authentication-Results: i=2; server2.sourceware.org ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=ez9YpmARZ81wenMN09ZA6GMOmoZy2d+jM8TIk3RrUGclL9F7k3GeQ5R/y3uQu/hNdg5c4ZsOfIm46slFIabQT2dmlItZMuNFTm0RcQcOGsG9dlg4pdop6RnC04v73azXTw2eg3UAWE6oMe3t/I6HLxr4wrg9965RBzez7hstrx3i84QV/Uvdz0qRCqCZ4MnofK9gexCPnwgv9C8tYUeNC6aPCts0WaH0CP9efrtuVIRwzCv4zpiiFWBXswP2ZQAVn1A2aXqLnqBGmQR8DOndJu4mfYD0S1Qr7mCF0s05omYvxSce9rFLMmqB/m6PH5/4K7HUJsTbrg5p221hF6yEPg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=cXqW10Za9nwvd8MGnsid1o5bMIDzqHnLL+JnIbDOkS4=; b=T7NOsJUsViwfWpoYlg5hLNYJRQQfADSHt1HLIRWfOC2s9l4mIJmAT3jmvCpXLut936O495vBoXmXMSqrJKwXiW9gnyqlJJHQCPY8DUy/21efz3UB+abGtKBlXDY9ArQhrq2tAYUrZ0YA4nr5CZ3wY7v3LXofTQF7XaCLODMSI849kC+QjOnsZc6Ok32pf51AazWwa8EaMeE0cXq3d/o6+s1AYYBKKUNjvOy+RhdWpIZwZEgk6WakVABM9bwAfy3SjY6nOwcKxi0foyxnIAeK4uOPCW03BUWjUxaI7qImMhopVtncJpxunfNJpcBWItj5F5JywXeIudJgQWHigzKIVA== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=suse.com; dmarc=pass action=none header.from=suse.com; dkim=pass header.d=suse.com; arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.com; s=selector1; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=cXqW10Za9nwvd8MGnsid1o5bMIDzqHnLL+JnIbDOkS4=; b=BS4FYw/V7Vos/pm/bciWkF0cC3+tnoCMpIxQGYB4E5eoeoObFAVOQwog4IUObfDjXXrvROBYcFBb/0f/txV/C9tZPSyAWUY8/bMWt3hCDvCU13BJt32j/ip8BU3FmufZ56SOkLmNHfHAn1ZUiA9oaD/P6VdoVQwin+nKb6MzmApW5KV2cbBAIAaUa5gmSG4qNs1QNUi9tfdEiprXXIDWqNMjg39y62WDTlSbSDOvg+E7TMlcfM4pFa9J4K6rRrgXMP+vbxeGxUq6Fttmh8978UEGJdmCRHvbsxPxc8kCMba8uyl9kxEdUjGXJpqv3f07oyYwPI3TJc/N5TqQXfruqg== Authentication-Results: dkim=none (message not signed) header.d=none;dmarc=none action=none header.from=suse.com; Received: from DU2PR04MB8790.eurprd04.prod.outlook.com (2603:10a6:10:2e1::23) by DB9PR04MB8300.eurprd04.prod.outlook.com (2603:10a6:10:243::22) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6933.14; Mon, 30 Oct 2023 14:38:17 +0000 Received: from DU2PR04MB8790.eurprd04.prod.outlook.com ([fe80::d924:b650:a2ad:7b25]) by DU2PR04MB8790.eurprd04.prod.outlook.com ([fe80::d924:b650:a2ad:7b25%3]) with mapi id 15.20.6954.016; Mon, 30 Oct 2023 14:38:17 +0000 Message-ID: <05210620-3cfc-d254-1e35-35a0bad179e7@suse.com> Date: Mon, 30 Oct 2023 15:38:19 +0100 User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:102.0) Gecko/20100101 Thunderbird/102.15.1 Content-Language: en-US To: Binutils Cc: Neal Frager From: Jan Beulich Subject: [PATCH] gas: correct ignoring of C-style number suffixes X-ClientProxiedBy: FR4P281CA0100.DEUP281.PROD.OUTLOOK.COM (2603:10a6:d10:cb::14) To DU2PR04MB8790.eurprd04.prod.outlook.com (2603:10a6:10:2e1::23) MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: DU2PR04MB8790:EE_|DB9PR04MB8300:EE_ X-MS-Office365-Filtering-Correlation-Id: c687aec0-5b51-46eb-f07c-08dbd955db4d X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: JCmT5gP3YSa8pkvjriaFbRiJDK+BO/SW96F2rYbZaNIVnjOQNTWffwzrY+MWrkLdqXgfT0DoVLpVlBy09bTS3e8+dau0CreZrZI78iDJCwqnOf/dt9sBnWvGFcCz0q42YuYiajQJ35BSkDEaeiSQZoOU7CM+lTU/kqKsV2DYrrgMuT7XpRETXteK+48A6lH7DYPVchEMND4HaROn1SNKBWDPcbrjlOALeoe/5Ka5eWweYskb4ZkT1NIVNYr0lZTlGcTpnIskbBJKqYpJaS52+9jYA305I9JLj2AtDpSVVEVprlEHNxF48wSDq8SkgoQsCYkz/6bgOyJCZXtvC3ZpNPNdUnTUQf/Dtx59s9h7M1kYAdSj21ZMaqeq/7t1IbSm/JApxb4cQUjpVaV4e4MDeo0nFT1czBEOEauAKJp3DeHlOb6GQLEVW/U5Hb6Zko3X8SPBEq7PV2YojJnga8fQsBQg7FY0DGH1ZPfPYhXTBbEcF/33PuR0bYmf61qjuBzsCJE+mQs1ZRa4sw2Syr57FlwrSbSL1bK0NyAmNBRK0zm2l0sYMPGD6wnrdg53EH+dhh5OefepOyFWrpw9sSy3DMs9fXhqji2dqmHpOPPVLzDeW38XZ8bCgv5MbvCL4ZEDenTtgdvmPO399ldDCmcCSA== X-Forefront-Antispam-Report: CIP:255.255.255.255; CTRY:; LANG:en; SCL:1; SRV:; IPV:NLI; SFV:NSPM; H:DU2PR04MB8790.eurprd04.prod.outlook.com; PTR:; CAT:NONE; SFS:(13230031)(346002)(396003)(136003)(366004)(376002)(39860400002)(230922051799003)(451199024)(186009)(1800799009)(64100799003)(4326008)(8936002)(41300700001)(8676002)(2906002)(5660300002)(66899024)(31686004)(36756003)(6506007)(83380400001)(6512007)(38100700002)(2616005)(86362001)(66946007)(66556008)(31696002)(316002)(26005)(6486002)(6916009)(66476007)(478600001)(45980500001)(43740500002); DIR:OUT; SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: =?utf-8?q?HAMoeIz9porp1iSKA9xttR3bsiYf?= =?utf-8?q?/iIxhqZ5e/ExHhhI8NMJ4QFt64NwyadIhrxPzBMq8ZNZopXoBJOuRiJSt7Mkd/GXM?= =?utf-8?q?pW4Bj5zH2VyhJNfEjb8BjB2NBEZ4HGZ5/6akjQrXBH0BbrtMrhNXw3pkLxQ8dtTyz?= =?utf-8?q?GEo1zk2jHKuwAxO30FhBP/2ARWaf2KKmZI4smFSyjZQhLwugnLAl8VBZ3ZEOZdzCH?= =?utf-8?q?SC0ze2/FRwyb085YXJJhjql+MYB++8bLENfFORWXiN41ySklA/d5QGSbVjoF8tvz3?= =?utf-8?q?526a8Y0y4UuhU3A36bSYjginDzex/ZrRxYyX/0w03N+fY4FTnJKLR24dijw0nuuBw?= =?utf-8?q?Lpzs3tnsyqh6ni8MBXR6UYFtKB4GFzDQTrnYWvygK0/Ktx7vfS/b5YZO1ycvaN3P1?= =?utf-8?q?uEiahpsdyAiK2tYYc8MVBmChzz2YTsjacKBO31HRU6Iylkh8im8VppaBN6kfwdbt6?= =?utf-8?q?bCk3dEbdTm+jTpu5Y6oZ5wuNE0kXBPi1NZQWgmTQS+ghpFUJ0gw/2+wkceI2xtdXS?= =?utf-8?q?ho/C/rFkbYssKM5T8CyTmKaxkjfmGtOIZ5FB1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xcG+NDZ5G1Npp8HXN2ujsh3?= =?utf-8?q?3e9LyroOmetJSav/ocjCVyoRX56W/jkRSqcN3s4Mt3qGP/YVd77W6ZyiAk3OmNAEo?= =?utf-8?q?eWFQf65urjMR?= X-OriginatorOrg: suse.com X-MS-Exchange-CrossTenant-Network-Message-Id: c687aec0-5b51-46eb-f07c-08dbd955db4d X-MS-Exchange-CrossTenant-AuthSource: DU2PR04MB8790.eurprd04.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 30 Oct 2023 14:38:17.8898 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: f7a17af6-1c5c-4a36-aa8b-f5be247aa4ba X-MS-Exchange-CrossTenant-MailboxType: HOSTED X-MS-Exchange-CrossTenant-UserPrincipalName: HZMIfOhGFARM9gsnI7EY5M35B46/Jq6OWt6xdcPgb1Cy/rHGcIpgJkvbAHPClLV3EkTvgxDQGkjuGZA0ad2XEQ== X-MS-Exchange-Transport-CrossTenantHeadersStamped: DB9PR04MB8300 X-Spam-Status: No, score=-3026.7 required=5.0 tests=BAYES_00, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, DKIM_VALID_EF, RCVD_IN_DNSWL_NONE, RCVD_IN_MSPIKE_H2, SPF_HELO_PASS, 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: binutils@sourceware.org X-Mailman-Version: 2.1.30 Precedence: list List-Id: Binutils mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: binutils-bounces+patchwork=sourceware.org@sourceware.org First of all the respective original changes didn't deal with just 0 having such a suffix - this needs additional logic outside of integer_constant(). Further bogus suffixes having more than two L-s were accepted, while valid suffixes with U following the L(s) weren't. Finally respective tests were introduced for Sparc only. Reviewed-by: Neal Frager --- Instead of disabling the test for tic{,5}4x an alternative might be to use .dc.b. What I'm unclear about is whether that then really results in rubbish for those two targets (i.e. I'm uncertain whether they really shouldn't also override those directives). --- a/gas/expr.c +++ b/gas/expr.c @@ -538,17 +538,26 @@ integer_constant (int radix, expressionS #ifndef tc_allow_U_suffix #define tc_allow_U_suffix 1 #endif + bool u_seen = !tc_allow_U_suffix; /* PR 19910: Look for, and ignore, a U suffix to the number. */ - if (tc_allow_U_suffix && (c == 'U' || c == 'u')) - c = * input_line_pointer++; + if (!u_seen && (c == 'U' || c == 'u')) + { + c = *input_line_pointer++; + u_seen = true; + } #ifndef tc_allow_L_suffix #define tc_allow_L_suffix 1 #endif /* PR 20732: Look for, and ignore, a L or LL suffix to the number. */ - if (tc_allow_L_suffix) - while (c == 'L' || c == 'l') + if (tc_allow_L_suffix && (c == 'L' || c == 'l')) + { c = * input_line_pointer++; + if (c == 'L' || c == 'l') + c = *input_line_pointer++; + if (!u_seen && (c == 'U' || c == 'u')) + c = *input_line_pointer++; + } if (small) { @@ -888,6 +897,19 @@ operand (expressionS *expressionP, enum input_line_pointer++; goto default_case; + case 'l': + case 'L': + /* Accept an L suffix to the zero. */ + if (tc_allow_L_suffix) + goto numeric; + goto default_case; + + case 'u': + case 'U': + /* Accept a U suffix to the zero. */ + if (!tc_allow_U_suffix) + goto default_case; + /* Fall through. */ case '0': case '1': case '2': @@ -896,6 +918,7 @@ operand (expressionS *expressionP, enum case '5': case '6': case '7': + numeric: integer_constant ((flag_m68k_mri || NUMBERS_WITH_SUFFIX) ? 0 : 8, expressionP); --- /dev/null +++ b/gas/testsuite/gas/all/const-1.l @@ -0,0 +1,64 @@ +# This should match the output of gas -alm const-1.s. +.*: Assembler messages: +.*:5: Error: .*`l' +.*:18: Info: .* +.*:6: Error: .*`l' +.*:18: Info: .* +.*:7: Error: .*`l' +.*:18: Info: .* +.*:8: Error: .*`l' +.*:18: Info: .* +.*:5: Error: .*`u' +.*:19: Info: .* +.*:6: Error: .*`u' +.*:19: Info: .* +.*:7: Error: .*`u' +.*:19: Info: .* +.*:8: Error: .*`u' +.*:19: Info: .* +.*:5: Error: .*`l' +.*:20: Info: .* +.*:6: Error: .*`l' +.*:20: Info: .* +.*:7: Error: .*`l' +.*:20: Info: .* +.*:8: Error: .*`l' +.*:20: Info: .* +.*GAS .*/const-1\.s[ ].* +#... +[ ]*[0-9]*[ ]+const u +[ ]*[0-9]*[ ]+\?\?\?\? 00[ ]+> \.byte 0u +[ ]*[0-9]*[ ]+\?\?\?\? 00[ ]+> \.byte 00u +[ ]*[0-9]*[ ]+\?\?\?\? 00[ ]+> \.byte 0x0u +[ ]*[0-9]*[ ]+\?\?\?\? 01[ ]+> \.byte 1u +[ ]*[0-9]*[ ]+const l +[ ]*[0-9]*[ ]+\?\?\?\? 00[ ]+> \.byte 0l +[ ]*[0-9]*[ ]+\?\?\?\? 00[ ]+> \.byte 00l +[ ]*[0-9]*[ ]+\?\?\?\? 00[ ]+> \.byte 0x0l +[ ]*[0-9]*[ ]+\?\?\?\? 01[ ]+> \.byte 1l +[ ]*[0-9]*[ ]+const ul +[ ]*[0-9]*[ ]+\?\?\?\? 00[ ]+> \.byte 0ul +[ ]*[0-9]*[ ]+\?\?\?\? 00[ ]+> \.byte 00ul +[ ]*[0-9]*[ ]+\?\?\?\? 00[ ]+> \.byte 0x0ul +[ ]*[0-9]*[ ]+\?\?\?\? 01[ ]+> \.byte 1ul +[ ]*[0-9]*[ ]+const lu +[ ]*[0-9]*[ ]+\?\?\?\? 00[ ]+> \.byte 0lu +[ ]*[0-9]*[ ]+\?\?\?\? 00[ ]+> \.byte 00lu +[ ]*[0-9]*[ ]+\?\?\?\? 00[ ]+> \.byte 0x0lu +[ ]*[0-9]*[ ]+\?\?\?\? 01[ ]+> \.byte 1lu +[ ]*[0-9]*[ ]+const ll +[ ]*[0-9]*[ ]+\?\?\?\? 00[ ]+> \.byte 0ll +[ ]*[0-9]*[ ]+\?\?\?\? 00[ ]+> \.byte 00ll +[ ]*[0-9]*[ ]+\?\?\?\? 00[ ]+> \.byte 0x0ll +[ ]*[0-9]*[ ]+\?\?\?\? 01[ ]+> \.byte 1ll +[ ]*[0-9]*[ ]+const llu +[ ]*[0-9]*[ ]+\?\?\?\? 00[ ]+> \.byte 0llu +[ ]*[0-9]*[ ]+\?\?\?\? 00[ ]+> \.byte 00llu +[ ]*[0-9]*[ ]+\?\?\?\? 00[ ]+> \.byte 0x0llu +[ ]*[0-9]*[ ]+\?\?\?\? 01[ ]+> \.byte 1llu +[ ]*[0-9]*[ ]+const ull +[ ]*[0-9]*[ ]+\?\?\?\? 00[ ]+> \.byte 0ull +[ ]*[0-9]*[ ]+\?\?\?\? 00[ ]+> \.byte 00ull +[ ]*[0-9]*[ ]+\?\?\?\? 00[ ]+> \.byte 0x0ull +[ ]*[0-9]*[ ]+\?\?\?\? 01[ ]+> \.byte 1ull +#pass --- /dev/null +++ b/gas/testsuite/gas/all/const-1.s @@ -0,0 +1,20 @@ + .data +data: + + .macro const, sfx + .byte 0\sfx + .byte 00\sfx + .byte 0x0\sfx + .byte 1\sfx + .endm + + const u + const l + const ul + const lu + const ll + const llu + const ull + const lll + const ulu + const lul --- a/gas/testsuite/gas/all/gas.exp +++ b/gas/testsuite/gas/all/gas.exp @@ -469,6 +469,11 @@ run_list_test cond-2 "-al" setup_xfail "tic30-*-*" run_list_test linefile "" +# Again, .byte does not emit 8 bits on either tic4x or tic54x. +if { ![istarget "tic4x*-*-*"] && ![istarget "tic54x*-*-*"] } { + run_list_test const-1 "-alm" +} + run_list_test macro "-alm" run_list_test pr20312