From patchwork Fri Aug 9 07:38:17 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jakub Jelinek X-Patchwork-Id: 1970831 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=redhat.com header.i=@redhat.com header.a=rsa-sha256 header.s=mimecast20190719 header.b=O+bA7LEw; 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 4WgG4R4Ytvz1ydk for ; Fri, 9 Aug 2024 17:38:47 +1000 (AEST) Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id 32632385840F for ; Fri, 9 Aug 2024 07:38:45 +0000 (GMT) X-Original-To: gcc-patches@gcc.gnu.org Delivered-To: gcc-patches@gcc.gnu.org Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.129.124]) by sourceware.org (Postfix) with ESMTP id 3A2443858D20 for ; Fri, 9 Aug 2024 07:38:25 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 3A2443858D20 Authentication-Results: sourceware.org; dmarc=pass (p=none dis=none) header.from=redhat.com Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=redhat.com ARC-Filter: OpenARC Filter v1.0.0 sourceware.org 3A2443858D20 Authentication-Results: server2.sourceware.org; arc=none smtp.remote-ip=170.10.129.124 ARC-Seal: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1723189106; cv=none; b=oSwtMswItrfOWJyy1jc/M2p7ZSMboiu3NNhUGo5qAZN6E5q96DA1Di1EwKK/IfcLWEtxhpt1kwAeD4uHal0rLMlUI0Zt1UnbZpx8JglZ/8noPqT9nqH24lDbndHgL3wol793iiJ7IJdBdJUPk7x/3vTfWzlXYSBaNKY1Bp+IWvA= ARC-Message-Signature: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1723189106; c=relaxed/simple; bh=Ps0XDreT1REF+84qk+aGSGosUZoGIQN7vqlvaeA3Lps=; h=DKIM-Signature:Date:From:To:Subject:Message-ID:MIME-Version; b=pgvbQe28ldnmp28IfsqPUs+Sc91iCoRpwN8qxFKEyLw1tvDdDkFMszMV3FY0ny9qHO0qStm4+gfc4Mx5+ozAooUBgbo7igUHCLkT8HP4KvSqEKQktaCdovux8McbvQ8yjizfgxABQxNM8P+QdKvL3pE8/cy2ho75oRPrFKQcbyo= ARC-Authentication-Results: i=1; server2.sourceware.org DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1723189105; h=from:from:reply-to:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:mime-version:mime-version: content-type:content-type; bh=UmVCNwUS0use7MrkWgMY6VL9oGY9HVkk0DaUhiqUf5M=; b=O+bA7LEwS+NcfxvZDnLiQtH+/3RAYsgy3ngWtvXMqyLfVhjnsAiKX5k8Q/w0e6C6getS1S PkTX2eYUR8E4LfXRZ5D6K0q0rXp6vRF6XoZJlWZDY8WOWC4PMvXrPaL7x0RiF3LdIXTzzc XcUjFAIZ7umolMW5UFIra0aiOjEjLkU= Received: from mx-prod-mc-01.mail-002.prod.us-west-2.aws.redhat.com (ec2-54-186-198-63.us-west-2.compute.amazonaws.com [54.186.198.63]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-1-Hmcvz34zNZOVAcS8V7NV9Q-1; Fri, 09 Aug 2024 03:38:22 -0400 X-MC-Unique: Hmcvz34zNZOVAcS8V7NV9Q-1 Received: from mx-prod-int-05.mail-002.prod.us-west-2.aws.redhat.com (mx-prod-int-05.mail-002.prod.us-west-2.aws.redhat.com [10.30.177.17]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by mx-prod-mc-01.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTPS id B0C361944D36 for ; Fri, 9 Aug 2024 07:38:21 +0000 (UTC) Received: from tucnak.zalov.cz (unknown [10.45.224.25]) by mx-prod-int-05.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTPS id 47CA81956052 for ; Fri, 9 Aug 2024 07:38:20 +0000 (UTC) Received: from tucnak.zalov.cz (localhost [127.0.0.1]) by tucnak.zalov.cz (8.17.1/8.17.1) with ESMTPS id 4797cHis1426162 (version=TLSv1.3 cipher=TLS_AES_256_GCM_SHA384 bits=256 verify=NOT) for ; Fri, 9 Aug 2024 09:38:17 +0200 Received: (from jakub@localhost) by tucnak.zalov.cz (8.17.1/8.17.1/Submit) id 4797cHQ51426161 for gcc-patches@gcc.gnu.org; Fri, 9 Aug 2024 09:38:17 +0200 Date: Fri, 9 Aug 2024 09:38:17 +0200 From: Jakub Jelinek To: gcc-patches@gcc.gnu.org Subject: [committed] c-family: Add some more ARRAY_SIZE uses Message-ID: MIME-Version: 1.0 X-Scanned-By: MIMEDefang 3.0 on 10.30.177.17 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Disposition: inline X-Spam-Status: No, score=-3.6 required=5.0 tests=BAYES_00, DKIMWL_WL_HIGH, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, DKIM_VALID_EF, RCVD_IN_DNSWL_NONE, RCVD_IN_MSPIKE_H3, RCVD_IN_MSPIKE_WL, SPF_HELO_NONE, SPF_NONE, 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: , Reply-To: Jakub Jelinek Errors-To: gcc-patches-bounces~incoming=patchwork.ozlabs.org@gcc.gnu.org Hi! These two spots were just non-standard, because they divided sizeof (omp_pragmas_simd) by sizeof (*omp_pragmas) and not the expected sizeof (*omp_pragmas_simd) and so weren't converted into ARRAY_SIZE. Both of the latter sizes are the same though, as both arrays have the same type, so this patch doesn't change anything but readability. Bootstrapped/regtested on x86_64-linux and i686-linux, committed to trunk. 2024-08-09 Jakub Jelinek * c-pragma.cc (c_pp_lookup_pragma): Use ARRAY_SIZE in n_omp_pragmas_simd initializer. (init_pragmas): Likewise. Jakub --- gcc/c-family/c-pragma.cc.jj 2024-06-05 19:09:54.054616902 +0200 +++ gcc/c-family/c-pragma.cc 2024-08-09 00:44:58.913489987 +0200 @@ -1565,8 +1565,7 @@ c_pp_lookup_pragma (unsigned int id, con { const int n_oacc_pragmas = ARRAY_SIZE (oacc_pragmas); const int n_omp_pragmas = ARRAY_SIZE (omp_pragmas); - const int n_omp_pragmas_simd = sizeof (omp_pragmas_simd) - / sizeof (*omp_pragmas); + const int n_omp_pragmas_simd = ARRAY_SIZE (omp_pragmas_simd); int i; for (i = 0; i < n_oacc_pragmas; ++i) @@ -1807,8 +1806,7 @@ init_pragma (void) } if (flag_openmp || flag_openmp_simd) { - const int n_omp_pragmas_simd - = sizeof (omp_pragmas_simd) / sizeof (*omp_pragmas); + const int n_omp_pragmas_simd = ARRAY_SIZE (omp_pragmas_simd); int i; for (i = 0; i < n_omp_pragmas_simd; ++i)