From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: by sourceware.org (Postfix, from userid 2205) id BF9153858C50; Mon, 2 May 2022 20:27:06 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org BF9153858C50 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable From: Tom de Vries To: gdb-cvs@sourceware.org Subject: [binutils-gdb] [gdb/testsuite] Fix gdb.cp/align.exp with gcc 12.1 / 11.3 X-Act-Checkin: binutils-gdb X-Git-Author: Tom de Vries X-Git-Refname: refs/heads/master X-Git-Oldrev: 95929abb498786d9dce36bb94b6c3f1d63178956 X-Git-Newrev: 5335b0439c3df66f43123d83fcbab16ea3b3ecba Message-Id: <20220502202706.BF9153858C50@sourceware.org> Date: Mon, 2 May 2022 20:27:06 +0000 (GMT) X-BeenThere: gdb-cvs@sourceware.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Gdb-cvs mailing list List-Unsubscribe: , List-Archive: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 02 May 2022 20:27:06 -0000 https://sourceware.org/git/gitweb.cgi?p=3Dbinutils-gdb.git;h=3D5335b0439c3d= f66f43123d83fcbab16ea3b3ecba commit 5335b0439c3df66f43123d83fcbab16ea3b3ecba Author: Tom de Vries Date: Mon May 2 22:27:03 2022 +0200 [gdb/testsuite] Fix gdb.cp/align.exp with gcc 12.1 / 11.3 =20 Starting with gcc 12.1 / gcc 11.3, for test-case gdb.cp/align.exp we ru= n into: ... align.cc:29:23: error: invalid application of 'alignof' to a void type^M 29 | unsigned a_void =3D alignof (void);^M | ^~~~~~~~~~~~~~^M ... =20 Fix this by using __alignof__ instead. =20 Tested on x86_64-linux, with gcc 7.5.0, gcc 12.1 and clang 12.0.1. Diff: --- 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 { =20 unsigned a_int3 =3D alignof (int[3]); =20 -#if !defined (__clang__) - unsigned a_void =3D alignof (void); +#if defined __GNUC__ && !defined __clang__ + /* As a GNU C extension, GCC allows void pointer arithmetic, with + sizeof (void) =3D=3D 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=3Dgnu++11 does not prevent the error). + So we avoid using alignof, and use __alignof__ instead. */ + unsigned a_void =3D __alignof__ (void); +#else + /* No support for __alignof__ (void), hardcode value. */ + unsigned a_void =3D 1; #endif =20 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\])" " =3D $expected" =20 -# 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)" " =3D $expected"