From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from simark.ca by simark.ca with LMTP id bfAgFBf0b2L+1AMAWB0awg (envelope-from ) for ; Mon, 02 May 2022 11:09:11 -0400 Received: by simark.ca (Postfix, from userid 112) id 437121E058; Mon, 2 May 2022 11:09:11 -0400 (EDT) Authentication-Results: simark.ca; dkim=pass (1024-bit key; secure) header.d=sourceware.org header.i=@sourceware.org header.a=rsa-sha256 header.s=default header.b=VyxQiNfI; dkim-atps=neutral X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on simark.ca X-Spam-Level: X-Spam-Status: No, score=-2.0 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,MAILING_LIST_MULTI,RDNS_DYNAMIC,URIBL_BLOCKED autolearn=ham autolearn_force=no version=3.4.6 Received: from sourceware.org (ip-8-43-85-97.sourceware.org [8.43.85.97]) (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 simark.ca (Postfix) with ESMTPS id C6BA21E00E for ; Mon, 2 May 2022 11:09:10 -0400 (EDT) Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id 1FA9A3858010 for ; Mon, 2 May 2022 15:09:10 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 1FA9A3858010 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=sourceware.org; s=default; t=1651504150; bh=uHPgKiMZ9WVgmokGk7XCcSIMpla8Qn8RUq8r8vrdmMg=; h=Date:To:Subject:List-Id:List-Unsubscribe:List-Archive:List-Post: List-Help:List-Subscribe:From:Reply-To:From; b=VyxQiNfII2h4QRRSuhABgmv3hkIsF4J+i7JqshjakiELe98Y8oOBFLD4VaHKrxZjx sLR/6/5dJXEjAz6ZPvE0zRVcG89b8h9awV4MARsXHvo1xF+NtQkPsOL4/y+mTKVCGe NWu8atzCvUGDc5zuaNKIuIjV6bANa2r1uNytMYVM= Received: from smtp-out1.suse.de (smtp-out1.suse.de [195.135.220.28]) by sourceware.org (Postfix) with ESMTPS id 7EC313858D3C for ; Mon, 2 May 2022 15:08:51 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.1 sourceware.org 7EC313858D3C Received: from imap2.suse-dmz.suse.de (imap2.suse-dmz.suse.de [192.168.254.74]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (P-521) server-digest SHA512) (No client certificate requested) by smtp-out1.suse.de (Postfix) with ESMTPS id 8997A210EB for ; Mon, 2 May 2022 15:08:50 +0000 (UTC) Received: from imap2.suse-dmz.suse.de (imap2.suse-dmz.suse.de [192.168.254.74]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (P-521) server-digest SHA512) (No client certificate requested) by imap2.suse-dmz.suse.de (Postfix) with ESMTPS id 76EAE133E5 for ; Mon, 2 May 2022 15:08:50 +0000 (UTC) Received: from dovecot-director2.suse.de ([192.168.254.65]) by imap2.suse-dmz.suse.de with ESMTPSA id dGrlGwL0b2KqRgAAMHmgww (envelope-from ) for ; Mon, 02 May 2022 15:08:50 +0000 Date: Mon, 2 May 2022 17:08:48 +0200 To: gdb-patches@sourceware.org Subject: [PATCH][gdb/testsuite] Fix gdb.cp/align.exp with gcc 12.1 / 11.3 Message-ID: <20220502150847.GA12665@delia.home> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline User-Agent: Mutt/1.10.1 (2018-07-13) X-BeenThere: gdb-patches@sourceware.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Gdb-patches mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , From: Tom de Vries via Gdb-patches Reply-To: Tom de Vries Errors-To: gdb-patches-bounces+public-inbox=simark.ca@sourceware.org Sender: "Gdb-patches" Hi, Starting with gcc 12.1 / gcc 11.3, for test-case gdb.cp/align.exp we run into: ... align.cc:29:23: error: invalid application of 'alignof' to a void type^M 29 | unsigned a_void = alignof (void);^M | ^~~~~~~~~~~~~~^M ... Fix this by using __alignof__ instead. Tested on x86_64-linux, with gcc 7.5.0, gcc 12.1 and clang 12.0.1. Any comments? Thanks, - Tom [gdb/testsuite] Fix gdb.cp/align.exp with gcc 12.1 / 11.3 --- gdb/testsuite/gdb.cp/align.exp | 25 ++++++++++++++----------- 1 file changed, 14 insertions(+), 11 deletions(-) diff --git a/gdb/testsuite/gdb.cp/align.exp b/gdb/testsuite/gdb.cp/align.exp index 6cda04798e8..018a297cde9 100644 --- a/gdb/testsuite/gdb.cp/align.exp +++ b/gdb/testsuite/gdb.cp/align.exp @@ -80,8 +80,19 @@ puts $outfile { unsigned a_int3 = alignof (int[3]); -#if !defined (__clang__) - unsigned a_void = alignof (void); +#if defined __GNUC__ && !defined __clang__ + /* As a GNU C extension, GCC allows void pointer arithmetic, with + sizeof (void) == 1. + Another GNU C extension is __alignof__, which can be used to get + __alignof__ (void), which is also 1. This is unavailabe on clang. + GCC used to only warn for alignof (void), but starting with GCC 12.1, + as well as GCC 11.3, it will generate an error (note that using + -std=gnu++11 does not prevent the error). + So we avoid using alignof, and use __alignof__ instead. */ + unsigned a_void = __alignof__ (void); +#else + /* No support for __alignof__ (void), hardcode value. */ + unsigned a_void = 1; #endif struct base { char c; }; @@ -173,13 +184,5 @@ foreach type $typelist { set expected [get_integer_valueof a_int3 0] gdb_test "print alignof(int\[3\])" " = $expected" -# As an extension, GCC allows void pointer arithmetic, with -# sizeof(void) and alignof(void) both 1. This test checks -# GDB's support of GCC's extension. -if [test_compiler_info clang*] { - # Clang doesn't support GCC's extension. - set expected 1 -} else { - set expected [get_integer_valueof a_void 0] -} +set expected [get_integer_valueof a_void 0] gdb_test "print alignof(void)" " = $expected"