From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mail-ed1-x52f.google.com (mail-ed1-x52f.google.com [IPv6:2a00:1450:4864:20::52f]) by sourceware.org (Postfix) with ESMTPS id 33160385C6D2 for ; Mon, 10 Jun 2024 09:08:25 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 33160385C6D2 Authentication-Results: sourceware.org; dmarc=pass (p=quarantine dis=none) header.from=adacore.com Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=adacore.com ARC-Filter: OpenARC Filter v1.0.0 sourceware.org 33160385C6D2 Authentication-Results: server2.sourceware.org; arc=none smtp.remote-ip=2a00:1450:4864:20::52f ARC-Seal: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1718010507; cv=none; b=PbNwBaPtkNa+xsaTTT9DCFZdmQLy2Mf378sBpTYMpswE5J4rHT9c4JuGGFGtXQfO1p4RKWMnnrDLPbhXAmxgWWHKmz87SAoiOEbiwT9FXnDJsSiDJl9QKHKvrO18jmAISzcFr8H3quX3upPXcb2Coy3boiFI7ak6jhEp01wxDaI= ARC-Message-Signature: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1718010507; c=relaxed/simple; bh=pmkpaSqKGH6aV8RIH10qmBMc+XxyzzMczmmLZbufkSA=; h=DKIM-Signature:From:To:Subject:Date:Message-ID:MIME-Version; b=jTRHo22t6uJB5gbv39fijwgFfV8ukmduVzAe66yI7/SRu7XyrXq6sefFZDhmfNitpXTi4kcfxFsEj4U1T7gQUPDvO5llBdS2bTJzHMxm4UDWfGCOBw/hCcxGdngZ8ONc/dDfAL1yU1t8imYC4sWfo0tMLAmajbCwxjIybF+KBlE= ARC-Authentication-Results: i=1; server2.sourceware.org Received: by mail-ed1-x52f.google.com with SMTP id 4fb4d7f45d1cf-57a31d63b6bso6071639a12.0 for ; Mon, 10 Jun 2024 02:08:25 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=adacore.com; s=google; t=1718010504; x=1718615304; darn=gcc.gnu.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=p7h4NqPIkCu2FT0ODM0hkVhgXzSArcEGs4+zhsSGZl0=; b=Uw8sGYohk5K5lQkpFnHLwiOiex6oAfa8pxhhud9fIgFbJTlL9agvjteWKr61hTPLL8 5TAEiZzHLSQUwS8PHRf5R6paDbaVcCuosmiFjFY8aTu3h9zDvfaKnT61+UQ3mc6g8Oh2 d7Ya6t3+hhuun2c/uKS9gtBE/GJ6KvXYSQvvqYsSA9AhZMjij3NrKgKhCWf4hfrRkzmL sQCj4Dno80NzTKNvIwrlDDydtjh74cflHvSvrgtqfZrtKkLsxaVkepRCNRg0k7lk58KU 7eUWY11vU7btXoXBuA7YRmZYg39MQyyLCcwx1d1jzEAOTLst8JUai/vEtvxe4VJpzM8/ u/5A== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1718010504; x=1718615304; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=p7h4NqPIkCu2FT0ODM0hkVhgXzSArcEGs4+zhsSGZl0=; b=IvL2Oazs3LU0fd7jTCp/kDQMSpyyBQgy0r6jAKZ57dHliOWgbLz3Nb69cZZTH2QW7e CoCShf+7dXNTEAGhD3Ssuti6U3UyqvuhLYxAYAK4xlCnPxslaiqFasA/kGqDfRjvmH/8 +F+QiYeKqkEHqOzEFAMLYZRHEOMVjSNbIdYrna02NWR3M0YR7cXCp9LKkF92q5XPQukN 1O7BT0lpxTDdCIv1I+PS6uon8a+xzRpGVABQfU/GEuJN5dgbsStEwRqlAmJwEADRwqL3 Eck2p3ppObndl5f8AB2qH+b2jfDHvCQX6eUAHC6795gIgtBDzsPRt5e7njN3QyyY50UX Eskg== X-Gm-Message-State: AOJu0Yy2nCIH9yRRUYmL2uOli1W+IiN8gx/kIh8ReuVjCokXjKXy5LGU yJfeclpYeK9ce6QWnF5C3xnPoLGnkho2ajsxqIgNjd0FU+bXRPvgcdwdB838hwV9TTnTIAI2CMw = X-Google-Smtp-Source: AGHT+IEJWc+GePSa80pKLsfD6IkOmnSjjiaVE/BftmuVnqUkBgH93Fx310S3cvqyysfFhT2f3Gb2eQ== X-Received: by 2002:a17:906:3e56:b0:a6f:233:3b66 with SMTP id a640c23a62f3a-a6f023346ffmr298094566b.59.1718010503760; Mon, 10 Jun 2024 02:08:23 -0700 (PDT) Received: from poulhies-Precision-5550.telnowedge.local (lmontsouris-659-1-24-67.w81-250.abo.wanadoo.fr. [81.250.175.67]) by smtp.gmail.com with ESMTPSA id ffacd0b85a97d-35f0f551c20sm6454970f8f.69.2024.06.10.02.08.23 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 10 Jun 2024 02:08:23 -0700 (PDT) From: =?UTF-8?q?Marc=20Poulhi=C3=A8s?= To: gcc-patches@gcc.gnu.org Cc: Gary Dismukes Subject: [COMMITTED 28/30] ada: Derived type with convention C must override convention C_Pass_By_Copy Date: Mon, 10 Jun 2024 11:07:44 +0200 Message-ID: <20240610090747.1557638-28-poulhies@adacore.com> X-Mailer: git-send-email 2.45.1 In-Reply-To: <20240610090747.1557638-1-poulhies@adacore.com> References: <20240610090747.1557638-1-poulhies@adacore.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-13.7 required=5.0 tests=BAYES_00,DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,GIT_PATCH_0,RCVD_IN_DNSWL_NONE,SPF_HELO_NONE,SPF_PASS,TXREP,T_SCC_BODY_TEXT_LINE autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on server2.sourceware.org List-Id: From: Gary Dismukes If a type DT is derived from a record type T with convention C_Pass_By_Copy and explicitly specifies convention C (via aspect or pragma), then type DT should not be treated as a type with convention C_Pass_By_Copy. Any parameters of the derived type should be passed by reference rather than by copy. The compiler was incorrectly inheriting convention C_Pass_By_Copy, by inheriting the flag set on the parent type, but that flag needs to be unset in the case where the convention is overridden. gcc/ada/ * sem_prag.adb (Set_Convention_From_Pragma): If the specified convention on a record type is not C_Pass_By_Copy, then force the C_Pass_By_Copy flag to False, to ensure that it's overridden. Tested on x86_64-pc-linux-gnu, committed on master. --- gcc/ada/sem_prag.adb | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/gcc/ada/sem_prag.adb b/gcc/ada/sem_prag.adb index 9ccf1b9cf65..671b2a542ea 100644 --- a/gcc/ada/sem_prag.adb +++ b/gcc/ada/sem_prag.adb @@ -8498,6 +8498,15 @@ package body Sem_Prag is end if; end if; + -- If the convention of a record type is changed (such as to C), + -- this must override C_Pass_By_Copy if that flag was inherited + -- from a parent type where the latter convention was specified, + -- so we force the flag to False. + + if Cname /= Name_C_Pass_By_Copy and then Is_Record_Type (E) then + Set_C_Pass_By_Copy (Base_Type (E), False); + end if; + -- If the entity is a derived boolean type, check for the special -- case of convention C, C++, or Fortran, where we consider any -- nonzero value to represent true. -- 2.45.1