From patchwork Wed Nov 6 11:46:12 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Tejas Belagod X-Patchwork-Id: 2007447 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@legolas.ozlabs.org Authentication-Results: legolas.ozlabs.org; dkim=pass (1024-bit key; unprotected) header.d=arm.com header.i=@arm.com header.a=rsa-sha256 header.s=selector1 header.b=NLKSiLvw; dkim=pass (1024-bit key) header.d=arm.com header.i=@arm.com header.a=rsa-sha256 header.s=selector1 header.b=NLKSiLvw; 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 4Xk3NZ3KlBz1xxf for ; Wed, 6 Nov 2024 22:47:42 +1100 (AEDT) Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id A66B53857BAF for ; Wed, 6 Nov 2024 11:47:40 +0000 (GMT) X-Original-To: gcc-patches@gcc.gnu.org Delivered-To: gcc-patches@gcc.gnu.org Received: from EUR03-AM7-obe.outbound.protection.outlook.com (mail-am7eur03on20600.outbound.protection.outlook.com [IPv6:2a01:111:f403:260e::600]) by sourceware.org (Postfix) with ESMTPS id 1DD293858CD1 for ; Wed, 6 Nov 2024 11:46:54 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 1DD293858CD1 Authentication-Results: sourceware.org; dmarc=pass (p=none dis=none) header.from=arm.com Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=arm.com ARC-Filter: OpenARC Filter v1.0.0 sourceware.org 1DD293858CD1 Authentication-Results: server2.sourceware.org; arc=pass smtp.remote-ip=2a01:111:f403:260e::600 ARC-Seal: i=3; a=rsa-sha256; d=sourceware.org; s=key; t=1730893617; cv=pass; b=uWLazJwmz51Dz9QzR9azEW1Yoe2GfDksb5URVqMCKE5Waet3ePBEgbdDCwAFW+mq6YDuAGhizuJefCl4DzK2ZzNlNT8edS4sMIKjBuiYlRANZy5igDgmOMeA7EVzBR182zKU+QA7t89YpGoDWaMp8RyOD6kyhJDJR4P1x4hxrzc= ARC-Message-Signature: i=3; a=rsa-sha256; d=sourceware.org; s=key; t=1730893617; c=relaxed/simple; bh=9JYR/ENQJImLb7gCb5NIzYseo5CdDCZ5u08qWKmj6b8=; h=DKIM-Signature:DKIM-Signature:From:To:Subject:Date:Message-ID: MIME-Version; b=XjpvCDLu45rCcD82yhif/fU80l7y/UsPptuDeKEr5rEDl9ouGj2ZcKqaOIf6UQedGX5dJ+pdqKrmyodgT1rc/C9OJGQskk6K1b8BX2A8Ux09A56YWgGlQYxGhCtTwMA2L/Y1OOZXCvJhR177cKj1V/9ducLsBLwI+i5T3sLsyOw= ARC-Authentication-Results: i=3; server2.sourceware.org ARC-Seal: i=2; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=pass; b=t9ZtS1WGZ9qey0icSw84pAoB7xqlD7CH2HAe2wWM6Bo1y5TUwkQyyqdyDXIsePqKCae/KWNXGwlzHh1CVSRp++N6hSpawWvZSu5mFtvYCXoTjwpSqmd+5VE3TjGBT3kQD72uRKQK6u8DP7+az2Y2kbSaVxMhBoH2/IBYZkyCRbMTETYb2PtMu7tMfuk5Vp/jtEYxBcaxT6irEmC4MaU1oyQEXd5GUx1Ns7CAKVKz2PljseSHjtE22CG53Vhava3fnzkHgfskeGeyypdKxt3dGDQ1enZhVRazPQD7xc3kZ6LVfu0ddkI4Jz1AP2JeCU4JQaTwLAUJkUWvQfQVoGgEmw== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector10001; 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=JaVb6AQg0NgB47eYPCaLc85h6KFycHuHrpPjqWxu8qE=; b=zAId+0xxkD8elJ6vyLfZ6wDQLJ1B2wLzukzXoXyVFCJTTa7aKvYLXqUTkP5o0fzFnVuD8zpCWWUfozNFpd9ctgqsmz75PVK1MsPk84UajM733w5/dn0aOQ1QCHjgvn0EoO5ydoS4BiB/txLgESQc+KSphaYIkKBsIQZpmDvTTTmTlfBFRLp3tGsN9N2kghux2hzjERuLomaYctXZ4Gn1RlogU7oKFlmyt5s4nX6CHUwnN3sS2357DIKH9etQ3B8gFIHjv00xlaQHMkBuvUVWqSL9EZ3LPG084hAR5oxWBm/7BYwAc2EEv9Qdis7cwqhsixKBlsBF60NH0pH3oLxVWQ== ARC-Authentication-Results: i=2; mx.microsoft.com 1; spf=pass (sender ip is 63.35.35.123) smtp.rcpttodomain=gcc.gnu.org smtp.mailfrom=arm.com; dmarc=pass (p=none sp=none pct=100) action=none header.from=arm.com; dkim=pass (signature was verified) header.d=arm.com; arc=pass (0 oda=1 ltdi=1 spf=[1,1,smtp.mailfrom=arm.com] dmarc=[1,1,header.from=arm.com]) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=arm.com; s=selector1; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=JaVb6AQg0NgB47eYPCaLc85h6KFycHuHrpPjqWxu8qE=; b=NLKSiLvw9Zx06iPWM/sTFA60VYRfbcuIF0YFGImcB2XPXiCTT180TOe5J0d7gswFgthxbV1t2j1lagHJDschFISCMGQBhHV9/oxZt3oRQ8OUd86aCEk5lZx6GyAjXj35fl1TxsDlsDZX/CkIoLQZ0hdasVpKEOB3/vkFa6dYkBk= Received: from DUZPR01CA0150.eurprd01.prod.exchangelabs.com (2603:10a6:10:4bd::7) by PAVPR08MB9697.eurprd08.prod.outlook.com (2603:10a6:102:31c::15) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.8114.31; Wed, 6 Nov 2024 11:46:48 +0000 Received: from DB5PEPF00014B95.eurprd02.prod.outlook.com (2603:10a6:10:4bd:cafe::9) by DUZPR01CA0150.outlook.office365.com (2603:10a6:10:4bd::7) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.8137.18 via Frontend Transport; Wed, 6 Nov 2024 11:46:48 +0000 X-MS-Exchange-Authentication-Results: spf=pass (sender IP is 63.35.35.123) smtp.mailfrom=arm.com; dkim=pass (signature was verified) header.d=arm.com;dmarc=pass action=none header.from=arm.com; Received-SPF: Pass (protection.outlook.com: domain of arm.com designates 63.35.35.123 as permitted sender) receiver=protection.outlook.com; client-ip=63.35.35.123; helo=64aa7808-outbound-1.mta.getcheckrecipient.com; pr=C Received: from 64aa7808-outbound-1.mta.getcheckrecipient.com (63.35.35.123) by DB5PEPF00014B95.mail.protection.outlook.com (10.167.8.233) with Microsoft SMTP Server (version=TLS1_3, cipher=TLS_AES_256_GCM_SHA384) id 15.20.8137.17 via Frontend Transport; Wed, 6 Nov 2024 11:46:47 +0000 Received: ("Tessian outbound 4f9bb016c0c5:v490"); Wed, 06 Nov 2024 11:46:46 +0000 X-CheckRecipientChecked: true X-CR-MTA-CID: 012de7e0faa46473 X-TessianGatewayMetadata: YwjBGLSCCLHuOzJAFrp0yeAs/Q3LEEWbiyoTiyoOsxpO4Sf6fNw8MTHKJs0Buu+J2QXDVodQTVHmetoZ/ShVYjee3bBJ2VySihgKKTNWiqpsQU5HR1357Ze1kJqSXWwo/LJ7sAuC2WzazvABltN84n9Pw33AdPh8O2sGLpps/lk= X-CR-MTA-TID: 64aa7808 Received: from La67a9ed4c39f.1 by 64aa7808-outbound-1.mta.getcheckrecipient.com id AA828AF4-D930-45F3-BC3E-9CD423C6B59D.1; Wed, 06 Nov 2024 11:46:40 +0000 Received: from EUR05-AM6-obe.outbound.protection.outlook.com by 64aa7808-outbound-1.mta.getcheckrecipient.com with ESMTPS id La67a9ed4c39f.1 (version=TLSv1.3 cipher=TLS_AES_256_GCM_SHA384); Wed, 06 Nov 2024 11:46:40 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=HZhWDLxXd4o7cImWuv/333u5NwgLjrYNPcpVAlf+UayPGfC3sNlYAipLzaZMm0iubxSky5L9J8F5LZxkORuhnIhpOGSu6vxRuc05tVbaAKyEhGv+5ujxDOwrcaopzlvC0sxfcUcGIe5YzB5M/Hx6sNSPdO8kDoFiy7Hk9yJH0g/4TG+o+I/EgAZvmuZ1mMzVuCKZSDAUvABHjMc1zDyk6QgePDb8afT8dBSegCVzuAZMrYsSCXlIMwKkRSNZmPKukCP7E6A9ZnxLhd9KymXwKPPfF51Pvy9+RcylVvoRDUqHLyj3tIanJnAB9vV8c9A10QZsiI1FlyOB0Vg1pg2Upw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector10001; 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=JaVb6AQg0NgB47eYPCaLc85h6KFycHuHrpPjqWxu8qE=; b=M0a4/C+Mo21a5UhCzMy6p+mQBVsgTADx0UBXrHRZHXD10iVzngtyxJQJPS5FL0xWvJ2RHwwNXpKbO8IQtWmGrSAqJcJADteYsujyEQjFQuUR1HeIE5PeYGt8EZ8Fu8+nHQQR5yrgvugp+0WVUVEkWD9nJuaTsv7khfDu0oHljf7kms5sqq+typPzRqFh0sniaSKuKVyOzsGg1z3FUAyBbGgo6erYTSS8SN5f6wcNWd2RMhnMdRPiJlgGWIEfDceTUa/6k0hQIJl6rsRyrwJx/bryrPNZc2PlZgCA+bjWVQ24AMSPigdpqhh0UwHw6uYSNwX0SiqtXwXtgOUyIsVw8Q== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass (sender ip is 40.67.248.234) smtp.rcpttodomain=gcc.gnu.org smtp.mailfrom=arm.com; dmarc=pass (p=none sp=none pct=100) action=none header.from=arm.com; dkim=none (message not signed); arc=none (0) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=arm.com; s=selector1; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=JaVb6AQg0NgB47eYPCaLc85h6KFycHuHrpPjqWxu8qE=; b=NLKSiLvw9Zx06iPWM/sTFA60VYRfbcuIF0YFGImcB2XPXiCTT180TOe5J0d7gswFgthxbV1t2j1lagHJDschFISCMGQBhHV9/oxZt3oRQ8OUd86aCEk5lZx6GyAjXj35fl1TxsDlsDZX/CkIoLQZ0hdasVpKEOB3/vkFa6dYkBk= Received: from AS9PR06CA0407.eurprd06.prod.outlook.com (2603:10a6:20b:461::14) by GV1PR08MB10501.eurprd08.prod.outlook.com (2603:10a6:150:163::11) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.8137.19; Wed, 6 Nov 2024 11:46:37 +0000 Received: from AMS0EPF00000190.eurprd05.prod.outlook.com (2603:10a6:20b:461:cafe::67) by AS9PR06CA0407.outlook.office365.com (2603:10a6:20b:461::14) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.8137.19 via Frontend Transport; Wed, 6 Nov 2024 11:46:37 +0000 X-MS-Exchange-Authentication-Results: spf=pass (sender IP is 40.67.248.234) smtp.mailfrom=arm.com; dkim=none (message not signed) header.d=none;dmarc=pass action=none header.from=arm.com; Received-SPF: Pass (protection.outlook.com: domain of arm.com designates 40.67.248.234 as permitted sender) receiver=protection.outlook.com; client-ip=40.67.248.234; helo=nebula.arm.com; pr=C Received: from nebula.arm.com (40.67.248.234) by AMS0EPF00000190.mail.protection.outlook.com (10.167.16.213) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.20.8137.17 via Frontend Transport; Wed, 6 Nov 2024 11:46:37 +0000 Received: from AZ-NEU-EX06.Arm.com (10.240.25.134) by AZ-NEU-EX04.Arm.com (10.251.24.32) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2507.39; Wed, 6 Nov 2024 11:46:34 +0000 Received: from AZ-NEU-EX04.Arm.com (10.251.24.32) by AZ-NEU-EX06.Arm.com (10.240.25.134) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2507.39; Wed, 6 Nov 2024 11:46:33 +0000 Received: from a078660.blr.arm.com (10.162.46.14) by mail.arm.com (10.251.24.32) with Microsoft SMTP Server id 15.1.2507.39 via Frontend Transport; Wed, 6 Nov 2024 11:46:32 +0000 From: Tejas Belagod To: CC: Tejas Belagod , , , , Subject: [PATCH 09/10] c: Fix bounds checking for VLA and construct VLA vector constants Date: Wed, 6 Nov 2024 17:16:12 +0530 Message-ID: <20241106114613.2972987-10-tejas.belagod@arm.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20241106114613.2972987-1-tejas.belagod@arm.com> References: <20241106114613.2972987-1-tejas.belagod@arm.com> MIME-Version: 1.0 X-EOPAttributedMessage: 1 X-MS-TrafficTypeDiagnostic: AMS0EPF00000190:EE_|GV1PR08MB10501:EE_|DB5PEPF00014B95:EE_|PAVPR08MB9697:EE_ X-MS-Office365-Filtering-Correlation-Id: 7f83b8f7-dfc8-4ebc-4e52-08dcfe58b1a6 x-checkrecipientrouted: true NoDisclaimer: true X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam-Untrusted: BCL:0; ARA:13230040|376014|1800799024|36860700013|82310400026; X-Microsoft-Antispam-Message-Info-Original: c5bw6FlRiPBmbYMPmQsy6caTv+OHs58bRspMt7c0bAeI6Q8mc0EEbiH3ZU80jXMsI2Eq3RFtuaZTZCESzUQD5LbiMAe26Q7sXRAdU2Y4o3krhJhnH6H6Q79bie8RCh5Rk3JxJ3KjSz3ripHlf79tHjOefJEMXaM3b7+Ob3DThOzRAJDNW++j4cxzIaQ6Vs3sbD4Wu8uxuaU/3ugGxgaOjiMdX1s/k9YNUeSkjBCl6xVYj7GqQ3CPJHGN2FNSs/gnjyrA9fQ4ec2e21cLoZ43H+j88O4S/i41uuC549Df2kO0bvLnOnxjEqnaCLEZId8D6w1b9RCiUtpQNuDjqzgc02dwKZQcCc/KLaMplhLOtKWQ9cp0nR/+hAlkWc/J6ncR0LgxaK6tVMViitTM8JHruRzQXa/1OxbjgPE4yDaXwWlK3aPDQK1RVZsWMdoePnEQ2AAgyhcxHfFSEnNc0nuCBv7MauQBIS9I4v799MC3RR1OPVZV4qct8t3pfOgexVlnsEHdJNjl3c/IEhwhvBji/gA/6QD2uVcttd0fmOItAj75fioZYnVl1vVKDhCCdK1lAe3AebtM40iP3s5A9ziF+coC4SrjP7NIE9KT4tOLaAAFfca/VjB2ON0XfI/KXU53umx0I98IKhz5D7g79CvD137G77nA/60LDRdSmYyb51vLiCCCTPbJOcbiL9h/qfyo2paQyDYfskhWBoZ/Mxa/HN5JiTw5RZC0VZVQXsG0EsqxpejeFfOwnXA+dbbXfxZWutvroFTx2aLC1MuLaNKh0WcHDnN7GUXCdDc+ACiRS+jyRM6IxjpRDhJbggOkH3KQxt+x1dKXVOU9N9bvYRmsLlcW3P1t78uKPIsRvMsW7TUVJMBu5Rzlt7Wo3zpe10pfJ/vpPoT439I8BOCmtH2uMX7TmIWca+Vj3W6QmiDJyULqbDFf35gFbK7ZtB5vNH6uygljgQkWJO7txF4mfxX4ZaD2ICoQLGapUY/iGQ6Ote6amy6ouKuFBHa6uppAE/ajwxr9l3ceRPFQnCbEruZmmsH3GlsCvsPKgrU0q6fV9VXRRFc2ZeTwqAfpuoOLYg4Y1aLrrMcS0NGTfKpUyffUK8hIrSTYOgG6S6+VkfM6w/UFL7Vm6db+dUHQfssVElI72LoE/Vy74GEa0z8XWaq/hjD3L0h4G87YeW63qjcGRigFZSVl8fRZQPo6yhh6znMzTVNiSYiDk4xvi/7bRP7IWmvEiSTpmji9CWHqi1EBnNror/9gsetcvhMIhee4ZGhYf9tflqXlsLZN5GCSVljNmR3PFe5hKhVp9W1vScINUOhmgQTG/XqpdfWyVo0nF+xdj9dC7qsK1Zudq3c7YAZH8hdf9qmYRXsydKljZ5RbSwQ= X-Forefront-Antispam-Report-Untrusted: CIP:40.67.248.234; CTRY:IE; LANG:en; SCL:1; SRV:; IPV:NLI; SFV:NSPM; H:nebula.arm.com; PTR:InfoDomainNonexistent; CAT:NONE; SFS:(13230040)(376014)(1800799024)(36860700013)(82310400026); DIR:OUT; SFP:1101; X-MS-Exchange-Transport-CrossTenantHeadersStamped: GV1PR08MB10501 X-MS-Exchange-SkipListedInternetSender: ip=[2603:10a6:20b:461::14]; domain=AS9PR06CA0407.eurprd06.prod.outlook.com X-MS-Exchange-Transport-CrossTenantHeadersStripped: DB5PEPF00014B95.eurprd02.prod.outlook.com X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id-Prvs: 5c4f39a7-4c7f-4319-c989-08dcfe58abf6 X-Microsoft-Antispam: BCL:0; ARA:13230040|36860700013|376014|1800799024|82310400026|35042699022|14060799003; X-Microsoft-Antispam-Message-Info: mc7mFor2CsQucgjSii3F0HibSrS1/WoQ3C2nrM0PU9g8E9UWumWXOQZa1lWEFdcWl//EssgIvegqfvP7aqXQ35n8Fj6OUNuVO68yslrNNvdvYrEhNkz0Ulsf5Nz6ynOBx7wj14bYCwmJ+8fttyOoGt72tTDJvMid3527Talg6uA/feFPgwaujcU68LPdnHYfGEYPqy+3hyUtyHxU7RL9rg3llAPjuiyOWW79EftOu7G4EiRcexBrATeBuoOfOr8yoyhmiuYZ6jZt4r4YfFGwSlvXPO9pUM7e1z5QKBN3LV/fyZZgPaobRQTgzt3PGMbY96T1EyiZOf8/UmPXtXQzmC3vLzZIqFzissHNtWRwvgNlIusI454b+kaZh/nYf+afErrvRH0M87zubDZtuakDUcKaIzh6yxov3ZHTn5a5mO2bWNSWy0UD/0fuI9jHUoVDQbmT5A3dhHykNMFK7hFnKSO5ydqBl736YkBjPY+IDdR80FNpJe5nba1YpyyNC7fsmnVjAmBv20Gnqw9em71ge4SN1gp4C34xOXwNE/LAJDmNoaxCxtwpcAlzimQGygdLi3u0o6UAH9tR7/J6vF147X9uDZaa8Za25+1IP72h1ozyU1MqOeb4LP+GahL1+yj/sMk1o4KVYCrlnD+FTQl78pkmXihgf4MJFiWjHcsIf601+bfUM5Cn3DAuEKhcoivlk+utC6HlxyxbzPv7Xg8A+ITz7r3aS/qMjKHsfjf/gsbD3PDst7ynodyMAoBKsEjt72giL6YXqoxrVn5/Rk9CpGGmSII7ShVycPhMeorCYEiFv2khqtRL2453JfumzqhOrLXWy0ZJ3osXQBdb/OfUhe5oC3oYevviJof23syx1D+jj5MYHJR7XMxpiHcPi2Hup6IGf43125kHA+uy0OeRylVxgPtIIu0u9BG5vRdhJUYgBRbTf+Cwfnn1+NMwpS8Y+UIvF5+QLCdGbwE5qHlQlPKbcxvMM8+jX7r6Fu1gfJaIwa42bJ0N3wJCfRJszBGE90uO7AlGrKDqHZiwWRh9QJgq8B/CawdX1raqZFru6u3dYbmtTW/zt24Ubh8+sCbp1bX9w95QH01VQpRKiPyR517NkM/hmgI6pIzyvb+P52WsTAXAHQUuCNjguq0NE1MtLwVJsEl75kL2oWaYSEdDXur+P1Zi2V90sWD99yQ0wSVLa69JCdlymAoBR7CpxYdHbofdfMSMXoD57Uag6gIrrAmehf/UXs7N33yPIc1MSbYilVtnaeGKD6SSmSMtI+Akiv2v4uU/lCyqg4yqpjP5GZVDsR7ycV0o37bT51ldr2NDH+gN2ACXHGVxLGJCpea5kPKyVxsxKeH1R5P8SfeTawaHUCTzr+sBWJQqNhZP4tw= X-Forefront-Antispam-Report: CIP:63.35.35.123; CTRY:IE; LANG:en; SCL:1; SRV:; IPV:CAL; SFV:NSPM; H:64aa7808-outbound-1.mta.getcheckrecipient.com; PTR:ec2-63-35-35-123.eu-west-1.compute.amazonaws.com; CAT:NONE; SFS:(13230040)(36860700013)(376014)(1800799024)(82310400026)(35042699022)(14060799003); DIR:OUT; SFP:1101; X-OriginatorOrg: arm.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 06 Nov 2024 11:46:47.0811 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 7f83b8f7-dfc8-4ebc-4e52-08dcfe58b1a6 X-MS-Exchange-CrossTenant-Id: f34e5979-57d9-4aaa-ad4d-b122a662184d X-MS-Exchange-CrossTenant-OriginalAttributedTenantConnectingIp: TenantId=f34e5979-57d9-4aaa-ad4d-b122a662184d; Ip=[63.35.35.123]; Helo=[64aa7808-outbound-1.mta.getcheckrecipient.com] X-MS-Exchange-CrossTenant-AuthSource: DB5PEPF00014B95.eurprd02.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: PAVPR08MB9697 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 This patch adds support for checking bounds of SVE ACLE vector initialization constructors. It also adds support to construct vector constant from init constructors. gcc/ChangeLog: * c/c-typeck.cc (process_init_element): Add check to restrict constructor length to the minimum vector length allowed. * tree.cc (build_vector_from_ctor): Add support to construct VLA vector constants from init constructors. gcc/testsuite/ChangeLog: * gcc.target/aarch64/sve/acle/general-c/sizeless-1.c: Update test to test initialize error. * gcc.target/aarch64/sve/acle/general-c/sizeless-2.c: Likewise. --- gcc/c/c-typeck.cc | 15 ++++++++++----- .../aarch64/sve/acle/general-c/sizeless-1.c | 1 + .../aarch64/sve/acle/general-c/sizeless-2.c | 1 + gcc/tree.cc | 16 +++++++++++----- 4 files changed, 23 insertions(+), 10 deletions(-) diff --git a/gcc/c/c-typeck.cc b/gcc/c/c-typeck.cc index 94959f7b8ad..7742b443780 100644 --- a/gcc/c/c-typeck.cc +++ b/gcc/c/c-typeck.cc @@ -11968,13 +11968,18 @@ retry: { tree elttype = TYPE_MAIN_VARIANT (TREE_TYPE (constructor_type)); - /* Do a basic check of initializer size. Note that vectors - may not always have a fixed size derived from their type. */ - if (known_lt (tree_to_poly_uint64 (constructor_max_index), + /* Do a basic check of initializer size. Note that vectors + may not always have a fixed size derived from their type. */ + if (maybe_lt (tree_to_poly_uint64 (constructor_max_index), tree_to_poly_uint64 (constructor_index))) { - pedwarn_init (loc, 0, - "excess elements in vector initializer"); + /* Diagose VLA out-of-bounds as errors. */ + if (tree_to_poly_uint64 (constructor_max_index).is_constant()) + pedwarn_init (loc, 0, + "excess elements in vector initializer"); + else + error_init (loc, "excess elements in vector initializer"); + break; } diff --git a/gcc/testsuite/gcc.target/aarch64/sve/acle/general-c/sizeless-1.c b/gcc/testsuite/gcc.target/aarch64/sve/acle/general-c/sizeless-1.c index f6823a498ab..20eecdad767 100644 --- a/gcc/testsuite/gcc.target/aarch64/sve/acle/general-c/sizeless-1.c +++ b/gcc/testsuite/gcc.target/aarch64/sve/acle/general-c/sizeless-1.c @@ -69,6 +69,7 @@ statements (int n) int initi_a = sve_sc1; /* { dg-error {incompatible types when initializing type 'int' using type 'svint8_t'} } */ int initi_b = { sve_sc1 }; /* { dg-error {incompatible types when initializing type 'int' using type 'svint8_t'} } */ + svint32_t init_sve_vc1 = { 0, 1, 2, 3, 4 }; /* { dg-error {excess elements in vector initializer} } */ /* Compound literals. */ diff --git a/gcc/testsuite/gcc.target/aarch64/sve/acle/general-c/sizeless-2.c b/gcc/testsuite/gcc.target/aarch64/sve/acle/general-c/sizeless-2.c index 63a2d7130e1..d3eb8a3727f 100644 --- a/gcc/testsuite/gcc.target/aarch64/sve/acle/general-c/sizeless-2.c +++ b/gcc/testsuite/gcc.target/aarch64/sve/acle/general-c/sizeless-2.c @@ -69,6 +69,7 @@ statements (int n) int initi_a = sve_sc1; /* { dg-error {incompatible types when initializing type 'int' using type 'svint8_t'} } */ int initi_b = { sve_sc1 }; /* { dg-error {incompatible types when initializing type 'int' using type 'svint8_t'} } */ + svint32_t init_sve_vc1 = { 0, 1, 2, 3, 4, 5, 6, 7, 8 }; /* { dg-warning {excess elements in vector initializer} } */ /* Compound literals. */ diff --git a/gcc/tree.cc b/gcc/tree.cc index b4c059d3b0d..0c524be4a9a 100644 --- a/gcc/tree.cc +++ b/gcc/tree.cc @@ -2072,12 +2072,18 @@ build_vector_from_ctor (tree type, const vec *v) if (vec_safe_length (v) == 0) return build_zero_cst (type); - unsigned HOST_WIDE_INT idx, nelts; + unsigned HOST_WIDE_INT idx, nelts, step = 1; tree value; - /* We can't construct a VECTOR_CST for a variable number of elements. */ - nelts = TYPE_VECTOR_SUBPARTS (type).to_constant (); - tree_vector_builder vec (type, nelts, 1); + /* If the vector is a VLA, build a VLA constant vector. */ + if (!TYPE_VECTOR_SUBPARTS (type).is_constant (&nelts)) + { + nelts = constant_lower_bound (TYPE_VECTOR_SUBPARTS (type)); + gcc_assert (vec_safe_length (v) <= nelts); + step = 2; + } + + tree_vector_builder vec (type, nelts, step); FOR_EACH_CONSTRUCTOR_VALUE (v, idx, value) { if (TREE_CODE (value) == VECTOR_CST) @@ -2090,7 +2096,7 @@ build_vector_from_ctor (tree type, const vec *v) else vec.quick_push (value); } - while (vec.length () < nelts) + while (vec.length () < nelts * step) vec.quick_push (build_zero_cst (TREE_TYPE (type))); return vec.build ();