From patchwork Thu Oct 3 15:26:49 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Dodji Seketeli X-Patchwork-Id: 98329 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 9DA40384A81A for ; Thu, 3 Oct 2024 15:27:02 +0000 (GMT) X-Original-To: libabigail@sourceware.org Delivered-To: libabigail@sourceware.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 2FA8E3858CDB for ; Thu, 3 Oct 2024 15:26:55 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 2FA8E3858CDB 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 2FA8E3858CDB 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=1727969217; cv=none; b=MdCaiuucxhLAd1MPdLMspZkYib9qNowtMDmZrgSheB0KOAeEjlfJJRjO/QMIpqOTqx1eC7yzWsmYBZbsme0hpRW3a1HPF+MU6OphwHvDagjE7KzFdsE40u9ZyPwG0hBfOb3BF3AaVaF/vmsIUQnpgFq5fJAGjZVTIy2Ad49xT3M= ARC-Message-Signature: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1727969217; c=relaxed/simple; bh=Eyf2fVceKXlVf56cpK4yrGuuIqKTvTk4JZqXio3vaL0=; h=DKIM-Signature:From:To:Subject:Date:Message-ID:MIME-Version; b=m/VskTV3JyB80Y0l3A4bCagRra53fwj/WDKUnYuvJa30Ni/GVjN3LsJ3157av0+XxRxU3AZjCwSqfJ+9nBf5r7cx7/l3j5f8ne+7KLOF0TflMNhe+obVnnshViKtr7fCpgX8uUrk7wRa7vkefdUPveqU7c9H1IFaATVIEjY9mBw= ARC-Authentication-Results: i=1; server2.sourceware.org DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1727969214; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:mime-version:mime-version:content-type:content-type; bh=JZmA/vxJgZhEdRaXcS9ZK9DztlI5Pqe/Cvh0C/7W1tQ=; b=PR1wimF2dV22zd0QQ0ndOX/VVFRIT4/imGWMZdqTdJnekSrphvKI045PxWlE+VXn6ep0hF Vg6Mt2GG7GBoXbFV2qO5rl7wweV9IpQLLOcTS7NtNEpc2/9tEVfNQDtjRHQXPkpQLP3NJh 7u4KfQhWOPif8AjzxaJC9QdM38ExCKE= Received: from mail-wr1-f70.google.com (mail-wr1-f70.google.com [209.85.221.70]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-601-8q_Bn3S7MSiqV6o-mMH3UA-1; Thu, 03 Oct 2024 11:26:53 -0400 X-MC-Unique: 8q_Bn3S7MSiqV6o-mMH3UA-1 Received: by mail-wr1-f70.google.com with SMTP id ffacd0b85a97d-37cc4f28e88so754776f8f.3 for ; Thu, 03 Oct 2024 08:26:53 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1727969212; x=1728574012; h=mime-version:user-agent:message-id:date:organization:subject:to :from:x-gm-message-state:from:to:cc:subject:date:message-id:reply-to; bh=JZmA/vxJgZhEdRaXcS9ZK9DztlI5Pqe/Cvh0C/7W1tQ=; b=Bl50WJJTI45td1EYNIbMJSO9CuI+PhyD1EaWN09svyU3dtNs/GNV+rsq7S/myji1u1 G196lhllqBHgejhQLtsqnd+njiPom2A+31wv+aveMz1V2tRnA38svnfL/ijLIbusZFGN B6SXxe99DDCYSx9rKMshPDOCaKzimiGk5uPnnwIWDJ0ulVVsgEex7mZ35hhEfNU1gkvh rPfd4ar7Lwv9ylc3G3QEsY2uOjqQVsCAjPWoI2NJF8LxQ24L+QUevjZwsE1ekQjotAwH 67SlGqpquwWdVgNi90PAmr99hX0FaxYv1oH4MiJc3TLYurVg2R5Z6cRFRndiBBUzFxP8 tyrw== X-Gm-Message-State: AOJu0Yx/QQV77qAcu/prsmQunxENmOKwQj2bv7h9vea8/TYkOFLnr7V1 ql0v8UitYqpIUcHMpDpS0X8H+vU/Tk35Ye0h/Xe2igIdZzGWgXOqR5IjCTLPCzEb6md6A1Zp8Bv yW2qYb/Vk9wKyf5YuUxm/WwlMXeZ/WGLc/MT0CdqCeJCQY4yk3uKLwD0Dpz1X8V3sSVuxYddBg4 fWQxm1f0J9iGFg1/1L8YyWCnp3GY11aEBVujPwzg== X-Received: by 2002:a05:6000:2808:b0:37c:fd43:fbd5 with SMTP id ffacd0b85a97d-37cfd440177mr6558208f8f.52.1727969212040; Thu, 03 Oct 2024 08:26:52 -0700 (PDT) X-Google-Smtp-Source: AGHT+IEAWCC+APOq8RrfVe+/2mMOoTCD98oj3bJ8eqRabSMJN6bhore+2e5lzILC9jw8PTp23ob7qA== X-Received: by 2002:a05:6000:2808:b0:37c:fd43:fbd5 with SMTP id ffacd0b85a97d-37cfd440177mr6558182f8f.52.1727969211465; Thu, 03 Oct 2024 08:26:51 -0700 (PDT) Received: from localhost (88-120-130-27.subs.proxad.net. [88.120.130.27]) by smtp.gmail.com with ESMTPSA id ffacd0b85a97d-37d082a6a71sm1503560f8f.73.2024.10.03.08.26.50 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 03 Oct 2024 08:26:50 -0700 (PDT) Received: by localhost (Postfix, from userid 1000) id F2D35B4FC3; Thu, 3 Oct 2024 17:26:49 +0200 (CEST) From: Dodji Seketeli To: libabigail@sourceware.org Subject: [PATCH, applied] writer: Fix emitting of some member types within their scope Organization: Red Hat / France X-Operating-System: CentOS Stream release 9 X-URL: http://www.redhat.com Date: Thu, 03 Oct 2024 17:26:49 +0200 Message-ID: <8734ldmcli.fsf@redhat.com> User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/27.2 (gnu/linux) MIME-Version: 1.0 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com X-Spam-Status: No, score=-12.0 required=5.0 tests=BAYES_00, DKIMWL_WL_HIGH, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, DKIM_VALID_EF, GIT_PATCH_0, 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: libabigail@sourceware.org X-Mailman-Version: 2.1.30 Precedence: list List-Id: Mailing list of the Libabigail project List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: libabigail-bounces~patchwork=sourceware.org@sourceware.org Hello, When the canonical type of the scope type T of a member type MT doesn't contain MT, then emitting T (obviously) doesn't emit MT. The ABIXML writer detects that MT wasn't emitted, but then mistakenly emits MT in the global scope, making MT lose its T scope. When the ABIXML is read back again, MT mistakenly becomes a non-qualified type, leading to a self-comparison error. This issue appears when self-comparing gcc-gnat on fc36 on armv7hl at least. This patch fixes the issue by making write_decl_in_scope detect that emitting T hasn't emitted MT. In that case, the function still needs to emit the tags of the scope of MT and then emit MT. Note that libabigail-test will now have contain a self-comparison test for that gcc-gnat package of fc36. * src/abg-writer.cc (write_decl_in_scope): Detect that emitting a scope type T doesn't emit a particular member type MT that we are looking at. In that case, the function still needs to emit the tags of the scope of MT and then emit MT even though T was just emitted. Signed-off-by: Dodji Seketeli --- src/abg-writer.cc | 28 ++++++++++++++++++++++++++-- 1 file changed, 26 insertions(+), 2 deletions(-) diff --git a/src/abg-writer.cc b/src/abg-writer.cc index b0bd095e..f938cdd3 100644 --- a/src/abg-writer.cc +++ b/src/abg-writer.cc @@ -2104,12 +2104,33 @@ write_decl_in_scope(const decl_base_sptr& decl, { c = is_class_type(look_through_decl_only_class(c)); class_decl_sptr class_type(c, noop_deleter()); + bool do_break = false; if (!ctxt.type_is_emitted(c)) { write_type(class_type, ctxt, initial_indent); - break; + // So, we've written class_type, which is a scope of + // 'decl'. So normally, decl should have been emitted + // by the emitting of class_type. + // + // But there can be times where 'decl' is not emitted. + // + // 'decl' can still be not emitted if the canonical type + // of class_type (the one that is emitted) is not the + // variant that contains the member type 'decl'. In + // that case, 'decl' still needs to be emitted after + // emitting tags for its scope. That is done by the + // 'if' block below. + do_break = true; } - else + + if (!do_break + // if decl/type is still not emitted, then it means the + // canonical type for 'class_type' above was emitted but + // wasn't the variant containing the member type + // 'decl/type'. In that case, we'll need to emit the + // tags for the scope of decl and then emit decl. + || (type && !ctxt.type_is_emitted(type)) + || (!type && !ctxt.decl_is_emitted(decl))) { write_class_decl_opening_tag(class_type, "", ctxt, indent, /*prepare_to_handle_empty=*/false); @@ -2122,6 +2143,9 @@ write_decl_in_scope(const decl_base_sptr& decl, closing_tags.push(""); closing_indents.push(nb_ws); } + + if (do_break) + break; } else if (union_decl *u = is_union_type(*i)) {