From patchwork Fri Dec 4 16:55:24 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Giuliano Procida X-Patchwork-Id: 41307 Return-Path: X-Original-To: patchwork@sourceware.org Delivered-To: patchwork@sourceware.org Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id 6131B3858001; Fri, 4 Dec 2020 16:55:43 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 6131B3858001 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=sourceware.org; s=default; t=1607100943; bh=hm3yQfT7yY/bD6QM73K+dLbq9rPdDE/jr56bX8qYUsM=; h=Date:Subject:To:List-Id:List-Unsubscribe:List-Archive:List-Help: List-Subscribe:From:Reply-To:Cc:From; b=hUVl+OSWIXx516EqoEK31YiRZ9WpejLfe1W6FAmyuo/EymU0HrgvZlROruWA9XXc5 v80iOIU7prlcNI2duPYCOZQYiaMPyh2dm6EQ2LChUPBltH/4PWyiU85aoprau3ObuH 2G+ryyDc33oHsmJKZjwvYxcDVFU3hv8MQUZ/Ec64= X-Original-To: libabigail@sourceware.org Delivered-To: libabigail@sourceware.org Received: from mail-qk1-x74a.google.com (mail-qk1-x74a.google.com [IPv6:2607:f8b0:4864:20::74a]) by sourceware.org (Postfix) with ESMTPS id 4E56B3858001 for ; Fri, 4 Dec 2020 16:55:39 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.3.2 sourceware.org 4E56B3858001 Received: by mail-qk1-x74a.google.com with SMTP id b11so5705971qkk.10 for ; Fri, 04 Dec 2020 08:55:39 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:sender:date:message-id:mime-version:subject:from :to:cc; bh=hm3yQfT7yY/bD6QM73K+dLbq9rPdDE/jr56bX8qYUsM=; b=gxEeJDpfwfYqurGmN4TR/AXOW8QW8iKni0M5fkRIUt1kYf1hJBa+hXzJ13YZU+p/UJ sazoEZ7N9K0Kt4IYSpGDLZ9FJaQWx664tdZ8fljSZegERSsfoQlkOSw2kYzU4B6eT91d PJr4OtK5DgY4OopDJMmEqFef1IWXriyrH+b+buyGVIroCUUWRrWJ37OXv6E+BD08ljmb t7FWqRt56bNZl/5/AmVY/lCsEgOyiDDzjNdcspCmyUsSdJewu0rrEtHoHZGeXvEGTESo Vxp8W4wsMFagJRqz/RnJm0nE3rGfANR5JPxwLB6YIv01hbGOYXuP/CfyblMBFirKaH/y 48lQ== X-Gm-Message-State: AOAM533eQDqC5kBzr6YkTXbF0Qy2P6/vCHM/z5oyDxcSfWjHeoAs4wyW oJ/PxvAH83aB5nfh7UQTc5AXJQFGRsvGbgxQX9ZhCtg9/ZR12Bw6MQKMCMsTBkcFDyhj2vP57E2 r+Q1cixaz+j2Iic1xH1YgL4zdZFUJ2DmT4FysUVvAPhfnNH4l6IpTrP3JplWNVI1uuQLVTeo= X-Google-Smtp-Source: ABdhPJwfF2fuiPiazS2CpSvCnJmF4ozSfRvqe56hBkiibkJey4J1AFDgW8iRftuJDCbjiNCbwBk2nGsosR0Bmw== X-Received: from tef.lon.corp.google.com ([2a00:79e0:d:110:a6ae:11ff:fe11:4f04]) (user=gprocida job=sendgmr) by 2002:ad4:5523:: with SMTP id ba3mr6040487qvb.41.1607100938815; Fri, 04 Dec 2020 08:55:38 -0800 (PST) Date: Fri, 4 Dec 2020 16:55:24 +0000 Message-Id: <20201204165524.319806-1-gprocida@google.com> Mime-Version: 1.0 X-Mailer: git-send-email 2.29.2.576.ga3fc446d84-goog Subject: [RFC PATCH] Add qualifier / typedef / array / pointer test To: libabigail@sourceware.org X-Spam-Status: No, score=-22.2 required=5.0 tests=BAYES_00, DKIMWL_WL_MED, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, DKIM_VALID_EF, GIT_PATCH_0, NORMAL_HTTP_TO_IP, NUMERIC_HTTP_ADDR, RCVD_IN_DNSWL_NONE, SPF_HELO_NONE, SPF_PASS, TXREP, USER_IN_DEF_DKIM_WL autolearn=ham autolearn_force=no version=3.4.2 X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on server2.sourceware.org X-BeenThere: libabigail@sourceware.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Mailing list of the Libabigail project List-Unsubscribe: , List-Archive: List-Help: List-Subscribe: , X-Patchwork-Original-From: Giuliano Procida via Libabigail From: Giuliano Procida Reply-To: Giuliano Procida Cc: maennich@google.com, kernel-team@android.com Errors-To: libabigail-bounces@sourceware.org Sender: "Libabigail" This change adds a test which exercises libabigail's handling of qualified typedefs of arrays. The base type in the test case is an array of pointers (chosen so we can also use restrict). Various typedefs and (indirect) qualifications of this type are created. In all cases, the resulting type should be an array of qualified pointers. However, abidiff reports things like 'const volatile void* const' changed to 'restrict const volatile volatile void* const' I've not attempted to check whether DWARF and ABI XML faithfully reflect the source types. There may be trouble there as well. For the record, these are the expected v0 types: A = void *[7] B = void *[7] C = void *const[7] D = void *const[7] E = void *const volatile[7] F = void *const volatile[7] G = void *const volatile restrict[7] H = void *const volatile restrict[7] The v1 types should be these plus others with extra pointer qualifiers. * tests/data/Makefile.am: Add new test files * tests/data/test-abidiff-exit/qualifier-typedef-array-v0.c: New test file. * tests/data/test-abidiff-exit/qualifier-typedef-array-v0.o: New test file. * tests/data/test-abidiff-exit/qualifier-typedef-array-v1.c: New test file. * tests/data/test-abidiff-exit/qualifier-typedef-array-v1.o: New test file. * tests/data/test-abidiff-exit/qualifier-typedef-array-report-0.txt: Plain diff report. * tests/data/test-abidiff-exit/qualifier-typedef-array-report-1.txt: Harmless diff report. * tests/data/test-abidiff-exit/qualifier-typedef-array-report-2.txt: Leaf changes report. * tests/data/test-abidiff-exit/qualifier-typedef-array-report-3.txt: Harmless leaf changes report. * tests/test-abidiff-exit.cc: Run new test. Signed-off-by: Giuliano Procida --- tests/data/Makefile.am | 8 ++ .../qualifier-typedef-array-report-0.txt | 3 + .../qualifier-typedef-array-report-1.txt | 81 ++++++++++++++++++ .../qualifier-typedef-array-report-2.txt | 5 ++ .../qualifier-typedef-array-report-3.txt | 5 ++ .../qualifier-typedef-array-v0.c | 37 ++++++++ .../qualifier-typedef-array-v0.o | Bin 0 -> 3352 bytes .../qualifier-typedef-array-v1.c | 37 ++++++++ .../qualifier-typedef-array-v1.o | Bin 0 -> 3408 bytes tests/test-abidiff-exit.cc | 44 ++++++++++ 10 files changed, 220 insertions(+) create mode 100644 tests/data/test-abidiff-exit/qualifier-typedef-array-report-0.txt create mode 100644 tests/data/test-abidiff-exit/qualifier-typedef-array-report-1.txt create mode 100644 tests/data/test-abidiff-exit/qualifier-typedef-array-report-2.txt create mode 100644 tests/data/test-abidiff-exit/qualifier-typedef-array-report-3.txt create mode 100644 tests/data/test-abidiff-exit/qualifier-typedef-array-v0.c create mode 100644 tests/data/test-abidiff-exit/qualifier-typedef-array-v0.o create mode 100644 tests/data/test-abidiff-exit/qualifier-typedef-array-v1.c create mode 100644 tests/data/test-abidiff-exit/qualifier-typedef-array-v1.o diff --git a/tests/data/Makefile.am b/tests/data/Makefile.am index 84447185..516a7f4d 100644 --- a/tests/data/Makefile.am +++ b/tests/data/Makefile.am @@ -184,6 +184,14 @@ test-abidiff-exit/test-headers-dirs/test-headers-dir-v0.c \ test-abidiff-exit/test-headers-dirs/test-headers-dir-v0.o \ test-abidiff-exit/test-headers-dirs/test-headers-dir-v1.c \ test-abidiff-exit/test-headers-dirs/test-headers-dir-v1.o \ +test-abidiff-exit/qualifier-typedef-array-v0.c \ +test-abidiff-exit/qualifier-typedef-array-v0.o \ +test-abidiff-exit/qualifier-typedef-array-v1.c \ +test-abidiff-exit/qualifier-typedef-array-v1.o \ +test-abidiff-exit/qualifier-typedef-array-report0.txt \ +test-abidiff-exit/qualifier-typedef-array-report1.txt \ +test-abidiff-exit/qualifier-typedef-array-report2.txt \ +test-abidiff-exit/qualifier-typedef-array-report3.txt \ \ test-diff-dwarf/test0-v0.cc \ test-diff-dwarf/test0-v0.o \ diff --git a/tests/data/test-abidiff-exit/qualifier-typedef-array-report-0.txt b/tests/data/test-abidiff-exit/qualifier-typedef-array-report-0.txt new file mode 100644 index 00000000..9666a8fd --- /dev/null +++ b/tests/data/test-abidiff-exit/qualifier-typedef-array-report-0.txt @@ -0,0 +1,3 @@ +Functions changes summary: 0 Removed, 0 Changed (1 filtered out), 0 Added function +Variables changes summary: 0 Removed, 0 Changed, 0 Added variable + diff --git a/tests/data/test-abidiff-exit/qualifier-typedef-array-report-1.txt b/tests/data/test-abidiff-exit/qualifier-typedef-array-report-1.txt new file mode 100644 index 00000000..0d73ae03 --- /dev/null +++ b/tests/data/test-abidiff-exit/qualifier-typedef-array-report-1.txt @@ -0,0 +1,81 @@ +Functions changes summary: 0 Removed, 1 Changed, 0 Added function +Variables changes summary: 0 Removed, 0 Changed, 0 Added variable + +1 function with some indirect sub-type change: + + [C] 'function void fun(S*)' at qualifier-typedef-array-v1.c:37:1 has some indirect sub-type changes: + parameter 1 of type 'S*' has sub-type changes: + in pointed to type 'struct S' at qualifier-typedef-array-v1.c:10:1: + type size hasn't changed + 12 data member changes: + type of 'A S::c_a' changed: + entity changed from 'typedef A' to compatible type 'void* const[7]' + array element type 'void*' changed: + entity changed from 'void*' to 'void* const' + type size hasn't changed + type size hasn't changed + type of 'A S::v_a' changed: + entity changed from 'typedef A' to compatible type 'void* volatile[7]' + array element type 'void*' changed: + entity changed from 'void*' to 'void* volatile' + type size hasn't changed + type size hasn't changed + type of 'A S::r_a' changed: + entity changed from 'typedef A' to compatible type 'void*[7]' + type of 'B S::c_b' changed: + typedef name changed from B to A at qualifier-typedef-array-v1.c:1:1 + underlying type 'typedef A' at qualifier-typedef-array-v0.c:1:1 changed: + entity changed from 'typedef A' to compatible type 'void* const[7]' + array element type 'void*' changed: + entity changed from 'void*' to 'void* const' + type size hasn't changed + type size hasn't changed + type of 'B S::v_b' changed: + typedef name changed from B to A at qualifier-typedef-array-v1.c:1:1 + underlying type 'typedef A' at qualifier-typedef-array-v0.c:1:1 changed: + entity changed from 'typedef A' to compatible type 'void* volatile[7]' + array element type 'void*' changed: + entity changed from 'void*' to 'void* volatile' + type size hasn't changed + type size hasn't changed + type of 'B S::r_b' changed: + typedef name changed from B to A at qualifier-typedef-array-v1.c:1:1 + underlying type 'typedef A' at qualifier-typedef-array-v0.c:1:1 changed: + entity changed from 'typedef A' to compatible type 'void*[7]' + type of 'C S::v_c' changed: + entity changed from 'typedef C' to compatible type 'const volatile void* const[7]' + array element type 'void* const' changed: + 'void* const' changed to 'const volatile void* const' + type name changed from 'void*[7]' to 'volatile void* const[7]' + type size hasn't changed + type of 'C S::r_c' changed: + entity changed from 'typedef C' to compatible type 'restrict void* const[7]' + array element type 'void* const' changed: + 'void* const' changed to 'restrict const void* const' + type name changed from 'void*[7]' to 'restrict void* const[7]' + type size hasn't changed + type of 'D S::v_d' changed: + entity changed from 'typedef D' to compatible type 'const volatile void* const[7]' + array element type 'void* const' changed: + 'void* const' changed to 'const volatile void* const' + type name changed from 'void*[7]' to 'volatile void* const[7]' + type size hasn't changed + type of 'D S::r_d' changed: + entity changed from 'typedef D' to compatible type 'restrict void* const[7]' + array element type 'void* const' changed: + 'void* const' changed to 'restrict const void* const' + type name changed from 'void*[7]' to 'restrict void* const[7]' + type size hasn't changed + type of 'E S::r_e' changed: + entity changed from 'typedef E' to compatible type 'restrict const volatile void* const[7]' + array element type 'const volatile void* const' changed: + 'const volatile void* const' changed to 'restrict const volatile volatile void* const' + type name changed from 'volatile void* const[7]' to 'restrict volatile void* const[7]' + type size hasn't changed + type of 'F S::r_f' changed: + entity changed from 'typedef F' to compatible type 'restrict const volatile void* const[7]' + array element type 'const volatile void* const' changed: + 'const volatile void* const' changed to 'restrict const volatile volatile void* const' + type name changed from 'volatile void* const[7]' to 'restrict volatile void* const[7]' + type size hasn't changed + diff --git a/tests/data/test-abidiff-exit/qualifier-typedef-array-report-2.txt b/tests/data/test-abidiff-exit/qualifier-typedef-array-report-2.txt new file mode 100644 index 00000000..b5b84c71 --- /dev/null +++ b/tests/data/test-abidiff-exit/qualifier-typedef-array-report-2.txt @@ -0,0 +1,5 @@ +Leaf changes summary: 0 artifact changed +Changed leaf types summary: 0 leaf type changed +Removed/Changed/Added functions summary: 0 Removed, 0 Changed, 0 Added function +Removed/Changed/Added variables summary: 0 Removed, 0 Changed, 0 Added variable + diff --git a/tests/data/test-abidiff-exit/qualifier-typedef-array-report-3.txt b/tests/data/test-abidiff-exit/qualifier-typedef-array-report-3.txt new file mode 100644 index 00000000..b5b84c71 --- /dev/null +++ b/tests/data/test-abidiff-exit/qualifier-typedef-array-report-3.txt @@ -0,0 +1,5 @@ +Leaf changes summary: 0 artifact changed +Changed leaf types summary: 0 leaf type changed +Removed/Changed/Added functions summary: 0 Removed, 0 Changed, 0 Added function +Removed/Changed/Added variables summary: 0 Removed, 0 Changed, 0 Added variable + diff --git a/tests/data/test-abidiff-exit/qualifier-typedef-array-v0.c b/tests/data/test-abidiff-exit/qualifier-typedef-array-v0.c new file mode 100644 index 00000000..939a968e --- /dev/null +++ b/tests/data/test-abidiff-exit/qualifier-typedef-array-v0.c @@ -0,0 +1,37 @@ +typedef void * A[7]; +typedef A B; +typedef const B C; +typedef C D; +typedef volatile D E; +typedef E F; +typedef restrict F G; +typedef G H; + +struct S { + A c_a; + A v_a; + A r_a; + B c_b; + B v_b; + B r_b; + C c_c; + C v_c; + C r_c; + D c_d; + D v_d; + D r_d; + E c_e; + E v_e; + E r_e; + F c_f; + F v_f; + F r_f; + G c_g; + G v_g; + G r_g; + H c_h; + H v_h; + H r_h; +}; + +void fun(struct S * s) { (void) s; } diff --git a/tests/data/test-abidiff-exit/qualifier-typedef-array-v0.o b/tests/data/test-abidiff-exit/qualifier-typedef-array-v0.o new file mode 100644 index 0000000000000000000000000000000000000000..9be7f99d5c271a5db02b6df590bac41031804916 GIT binary patch literal 3352 zcmbtWU1%It6h3!mZ+4Q|-E6W+n>4lEme#i5Zc~5S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/data/test-abidiff-exit/qualifier-typedef-array-v1.c b/tests/data/test-abidiff-exit/qualifier-typedef-array-v1.c new file mode 100644 index 00000000..67e3e83c --- /dev/null +++ b/tests/data/test-abidiff-exit/qualifier-typedef-array-v1.c @@ -0,0 +1,37 @@ +typedef void * A[7]; +typedef A B; +typedef const B C; +typedef C D; +typedef volatile D E; +typedef E F; +typedef restrict F G; +typedef G H; + +struct S { + const A c_a; // +const + volatile A v_a; // +volatile + restrict A r_a; // +restrict + const B c_b; // +const + volatile B v_b; // +volatile + restrict B r_b; // +restrict + const C c_c; // same + volatile C v_c; // +volatile + restrict C r_c; // +restrict + const D c_d; // same + volatile D v_d; // +volatile + restrict D r_d; // +restrict + const E c_e; // same + volatile E v_e; // same + restrict E r_e; // +restrict + const F c_f; // same + volatile F v_f; // same + restrict F r_f; // +restrict + const G c_g; // same + volatile G v_g; // same + restrict G r_g; // same + const H c_h; // same + volatile H v_h; // same + restrict H r_h; // same +}; + +void fun(struct S * s) { (void) s; } diff --git a/tests/data/test-abidiff-exit/qualifier-typedef-array-v1.o b/tests/data/test-abidiff-exit/qualifier-typedef-array-v1.o new file mode 100644 index 0000000000000000000000000000000000000000..f9e2188c346a65dbe2e8315d20f987970735987f GIT binary patch literal 3408 zcmbtWU2GIp6h3!;+NHCdZvUXA2n#6!i8HjKP|#va`6-c@s=*hdb#{05C$`f%yIWd~ zkr1Qs28r=6K9Cp_!;6pdCW)Hpi{X*PXbg$bNAW>Pc+l_6-dm>ADGz#+Irn_$eCM2d z&)m7YZ=E=EQWJvI5OkF8BV{GJoVl-0MCt_fQV*S-zVz$#r8n+{!o&;C~tw6%I4gq`)8bFu*B)~7(kU`Go#tevTakfaJ+qwWWBeF}3dhBn2 zE($P#dhKf{dxM!J5`ESc`0g?jsNen`XhZ`OXmiA@YGC>#wpgFRcU1!uXu!S(bc>ll zgZ5TzFsFlACb8A}3BG9^OrRnAHqdz;OrUM{4lu7XvqIt_>o55JU?$LZ`yS9<15BVD zHXqPe3^1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