From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: by sourceware.org (Postfix, from userid 48) id 5ADA63858D39; Wed, 8 Feb 2023 13:08:34 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 5ADA63858D39 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=sourceware.org; s=default; t=1675861714; bh=UdszUfG3IdygcoPbIowjahF1BE1WsIbzW0468gQPlgA=; h=From:To:Subject:Date:In-Reply-To:References:From; b=SjOlh8JdKzNgCP0cLZNSalxKQtkjKUFlyxKrBeM4Abu13ahg3nRmhfOq8R1LLzAgb Ja7/fBOKZYyJzLANtoSCi4jX/ZWL382T2ZiwaaUd9NNq1ZBbLhyPLWxhzs48BK3EAe Xe/atIoGGVfiaIrYt0cD6il5VTRIrA8OOWh41kE8= From: "gprocida at google dot com" To: libabigail@sourceware.org Subject: [Bug default/30048] incorrect qualifiers within compound types Date: Wed, 08 Feb 2023 13:08:33 +0000 X-Bugzilla-Reason: CC X-Bugzilla-Type: changed X-Bugzilla-Watch-Reason: None X-Bugzilla-Product: libabigail X-Bugzilla-Component: default X-Bugzilla-Version: unspecified X-Bugzilla-Keywords: X-Bugzilla-Severity: normal X-Bugzilla-Who: gprocida at google dot com X-Bugzilla-Status: ASSIGNED X-Bugzilla-Resolution: X-Bugzilla-Priority: P2 X-Bugzilla-Assigned-To: dodji at redhat dot com X-Bugzilla-Target-Milestone: --- X-Bugzilla-Flags: X-Bugzilla-Changed-Fields: Message-ID: In-Reply-To: References: Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable X-Bugzilla-URL: http://sourceware.org/bugzilla/ Auto-Submitted: auto-generated MIME-Version: 1.0 List-Id: https://sourceware.org/bugzilla/show_bug.cgi?id=3D30048 --- Comment #7 from gprocida at google dot com --- Hi Dodji. I don't feel qualified to review the code change and I haven't had the chan= ce to patch and test it (but I'm sure you have!). However, I can offer some test case suggestions. Firstly, printing out C types is a hard problem! I worked on an implementat= ion that seems to have mostly survived over a year or so of use: https://android.googlesource.com/platform/external/stg/+/refs/heads/master/= naming.h https://android.googlesource.com/platform/external/stg/+/refs/heads/master/= naming.cc The important code here is Name, which consolidates precedence handling, and the Describe function object, which works recursively on the type graph. I documented the original design approach here: https://android.googlesource.com/platform/external/stg/+/refs/heads/master/= doc/NAMES.md I think the main takeaway is that qualifiers can be "tacked on" without disturbing the rest of the code too much but some contextual awareness is needed to make sure the qualifiers end up on the correct side with appropri= ate whitespace. It would have been significantly easier if the world (or C itse= lf) just had "int const" and not "const int". In terms of testing... this is my torture test for naming and diffs. The comments are (or at least were at one point) valid input for cdecl(1). Please feel free to use or adapt this for libabigail. If you need copyright= / licence attribution it's: Google Inc. 2020, LLVM licence (Apache + LLVM exception), same as libabigail. struct amusement { // declare A as array 7 of int int A[7]; // declare B as pointer to int int *B; // declare C as pointer to function (void) returning int int (*C)(void ); // declare D as array 7 of array 7 of int int D[7][7]; // declare E as array 7 of pointer to int int *E[7]; // declare F as array 7 of pointer to function (void) returning int int (*F[7])(void ); // declare G as pointer to array 7 of int int (*G)[7]; // declare H as pointer to pointer to int int **H; // declare I as pointer to function (void) returning int int (*I)(void ); // declare J as pointer to function (void) returning pointer to array 7 of int int (*(*J)(void ))[7]; // declare K as pointer to function (void) returning pointer to int int *(*K)(void ); // declare L as pointer to function (void) returning pointer to function (void) returning int int (*(*L)(void ))(void ); // declare a as array 7 of volatile int volatile int a[7]; // declare b as const pointer to volatile int volatile int * const b; // declare c as const pointer to function (void) returning int int (* const c)(void ); // declare d as array 7 of array 7 of volatile int volatile int d[7][7]; // declare e as array 7 of const pointer to volatile int volatile int * const e[7]; // declare f as array 7 of const pointer to function (void) returning int int (* const f[7])(void ); // declare g as const pointer to array 7 of volatile int volatile int (* const g)[7]; // declare h as const pointer to const pointer to volatile int volatile int * const * const h; // declare i as const pointer to function (void) returning int int (* const i)(void ); // declare j as const pointer to function (void) returning pointer to arr= ay 7 of volatile int volatile int (*(* const j)(void ))[7]; // declare k as const pointer to function (void) returning pointer to volatile int volatile int *(* const k)(void ); // declare l as const pointer to function (void) returning pointer to function (void) returning int int (*(* const l)(void ))(void ); }; struct amusement * fun(void) { return 0; } // declare M as function (void) returning int int M(void ) { return 0; } // declare N as function (void) returning pointer to array 7 of int int (*N(void ))[7] { return 0; } // declare O as function (void) returning pointer to int int *O(void ) { return 0; } // declare P as function (void) returning pointer to function (void) return= ing int int (*P(void ))(void ) { return 0; } // declare m as function (void) returning int int m(void ) { return 0; } // declare n as function (void) returning pointer to array 7 of volatile int volatile int (*n(void ))[7] { return 0; } // declare o as function (void) returning pointer to volatile int volatile int *o(void ) { return 0; } // declare p as function (void) returning pointer to function (void) return= ing int int (*p(void ))(void ) { return 0; } This can be abidiff'd against: struct amusement { int A; int B; int C; int D; int E; int F; int G; int H; int I; int J; int K; int L; int a; int b; int c; int d; int e; int f; int g; int h; int i; int j; int k; int l; }; struct amusement * fun() { return 0; } int M() { return 0; } int N() { return 0; } int O() { return 0; } int P() { return 0; } int m() { return 0; } int n() { return 0; } int o() { return 0; } int p() { return 0; } Regards, Giuliano. --=20 You are receiving this mail because: You are on the CC list for the bug.=