From patchwork Fri Jul 30 11:01:00 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Iain Buclaw X-Patchwork-Id: 1511601 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=gcc.gnu.org (client-ip=2620:52:3:1:0:246e:9693:128c; helo=sourceware.org; envelope-from=gcc-patches-bounces+incoming=patchwork.ozlabs.org@gcc.gnu.org; receiver=) Authentication-Results: ozlabs.org; dkim=pass (1024-bit key; unprotected) header.d=gcc.gnu.org header.i=@gcc.gnu.org header.a=rsa-sha256 header.s=default header.b=RtNiBHlQ; dkim-atps=neutral Received: from sourceware.org (server2.sourceware.org [IPv6:2620:52:3:1:0:246e:9693:128c]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 4Gbkx34JZtz9sXk for ; Fri, 30 Jul 2021 21:01:43 +1000 (AEST) Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id 06CE4393F807 for ; Fri, 30 Jul 2021 11:01:41 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 06CE4393F807 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gcc.gnu.org; s=default; t=1627642901; bh=G4Wofx+hdkI7P7/Pzog++IWv3V5RFtc4mX4VYEL9cIQ=; h=To:Subject:Date:List-Id:List-Unsubscribe:List-Archive:List-Post: List-Help:List-Subscribe:From:Reply-To:From; b=RtNiBHlQKDJD25pA+aMLHnW8WvumQ7wkRHFl5AcADMp1iSSkOkF+mq0Fe3O1NOQqu c0R8SDd9xQJd4/Jvv5aq9O+zBg5q71GgQ6EGUcdTLHWmkEX1e+Zucaq51FtfLNs+HG saE1J+k28vwanu6gsYnQ0V9POG/dAscyswBJ1HOU= X-Original-To: gcc-patches@gcc.gnu.org Delivered-To: gcc-patches@gcc.gnu.org Received: from mout-p-201.mailbox.org (mout-p-201.mailbox.org [80.241.56.171]) by sourceware.org (Postfix) with ESMTPS id 928CE3861812 for ; Fri, 30 Jul 2021 11:01:18 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.1 sourceware.org 928CE3861812 Received: from smtp2.mailbox.org (smtp2.mailbox.org [80.241.60.241]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange ECDHE (P-384) server-signature RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) by mout-p-201.mailbox.org (Postfix) with ESMTPS id 4GbkwY4Rs2zQjhX; Fri, 30 Jul 2021 13:01:17 +0200 (CEST) X-Virus-Scanned: amavisd-new at heinlein-support.de Received: from smtp2.mailbox.org ([80.241.60.241]) by hefe.heinlein-support.de (hefe.heinlein-support.de [91.198.250.172]) (amavisd-new, port 10030) with ESMTP id mZMpEfhFQOxj; Fri, 30 Jul 2021 13:01:14 +0200 (CEST) To: gcc-patches@gcc.gnu.org Subject: [committed 01/12] d: Factor d_nested_class and d_nested_struct into single function. Date: Fri, 30 Jul 2021 13:01:00 +0200 Message-Id: <20210730110111.569140-1-ibuclaw@gdcproject.org> MIME-Version: 1.0 X-Rspamd-Queue-Id: CBE861842 X-Rspamd-UID: 856887 X-Spam-Status: No, score=-15.7 required=5.0 tests=BAYES_00, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, DKIM_VALID_EF, GIT_PATCH_0, RCVD_IN_DNSWL_LOW, SPF_HELO_NONE, SPF_PASS, TXREP autolearn=ham autolearn_force=no version=3.4.4 X-Spam-Checker-Version: SpamAssassin 3.4.4 (2020-01-24) on server2.sourceware.org X-BeenThere: gcc-patches@gcc.gnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Gcc-patches mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-Patchwork-Original-From: Iain Buclaw via Gcc-patches From: Iain Buclaw Reply-To: Iain Buclaw Errors-To: gcc-patches-bounces+incoming=patchwork.ozlabs.org@gcc.gnu.org Sender: "Gcc-patches" Both do the exact same operation, just on different AST nodes. gcc/d/ChangeLog: * d-codegen.cc (d_nested_class): Rename to ... (get_outer_function): ... this. Handle all aggregate declarations. (d_nested_struct): Remove. (find_this_tree): Use get_outer_function. (get_framedecl): Likewise. --- gcc/d/d-codegen.cc | 54 ++++++++++++---------------------------------- 1 file changed, 14 insertions(+), 40 deletions(-) diff --git a/gcc/d/d-codegen.cc b/gcc/d/d-codegen.cc index f35de90b54c..fe2ad98e60a 100644 --- a/gcc/d/d-codegen.cc +++ b/gcc/d/d-codegen.cc @@ -2354,41 +2354,24 @@ get_frame_for_symbol (Dsymbol *sym) return null_pointer_node; } -/* Return the parent function of a nested class CD. */ +/* Return the parent function of a nested class or struct AD. */ static FuncDeclaration * -d_nested_class (ClassDeclaration *cd) +get_outer_function (AggregateDeclaration *ad) { FuncDeclaration *fd = NULL; - while (cd && cd->isNested ()) + while (ad && ad->isNested ()) { - Dsymbol *dsym = cd->toParent2 (); + Dsymbol *dsym = ad->toParent2 (); if ((fd = dsym->isFuncDeclaration ())) return fd; else - cd = dsym->isClassDeclaration (); + ad = dsym->isAggregateDeclaration (); } - return NULL; -} - -/* Return the parent function of a nested struct SD. */ -static FuncDeclaration * -d_nested_struct (StructDeclaration *sd) -{ - FuncDeclaration *fd = NULL; - while (sd && sd->isNested ()) - { - Dsymbol *dsym = sd->toParent2 (); - if ((fd = dsym->isFuncDeclaration ())) - return fd; - else - sd = dsym->isStructDeclaration (); - } return NULL; } - /* Starting from the current function FD, try to find a suitable value of `this' in nested function instances. A suitable `this' value is an instance of OCD or a class that has OCD as a base. */ @@ -2411,18 +2394,17 @@ find_this_tree (ClassDeclaration *ocd) return convert_expr (get_decl_tree (fd->vthis), cd->type, ocd->type); - fd = d_nested_class (cd); + fd = get_outer_function (cd); + continue; } - else - { - if (fd->isNested ()) - { - fd = fd->toParent2 ()->isFuncDeclaration (); - continue; - } - fd = NULL; + if (fd->isNested ()) + { + fd = fd->toParent2 ()->isFuncDeclaration (); + continue; } + + fd = NULL; } return NULL_TREE; @@ -2760,10 +2742,6 @@ get_framedecl (FuncDeclaration *inner, FuncDeclaration *outer) while (fd && fd != outer) { - AggregateDeclaration *ad; - ClassDeclaration *cd; - StructDeclaration *sd; - /* Parent frame link is the first field. */ if (FRAMEINFO_CREATES_FRAME (get_frameinfo (fd))) result = indirect_ref (ptr_type_node, result); @@ -2773,12 +2751,8 @@ get_framedecl (FuncDeclaration *inner, FuncDeclaration *outer) /* The frame/closure record always points to the outer function's frame, even if there are intervening nested classes or structs. So, we can just skip over these. */ - else if ((ad = fd->isThis ()) && (cd = ad->isClassDeclaration ())) - fd = d_nested_class (cd); - else if ((ad = fd->isThis ()) && (sd = ad->isStructDeclaration ())) - fd = d_nested_struct (sd); else - break; + fd = get_outer_function (fd->isThis ()); } if (fd != outer) From patchwork Fri Jul 30 11:01:01 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Iain Buclaw X-Patchwork-Id: 1511602 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=gcc.gnu.org (client-ip=2620:52:3:1:0:246e:9693:128c; helo=sourceware.org; envelope-from=gcc-patches-bounces+incoming=patchwork.ozlabs.org@gcc.gnu.org; receiver=) Authentication-Results: ozlabs.org; dkim=pass (1024-bit key; unprotected) header.d=gcc.gnu.org header.i=@gcc.gnu.org header.a=rsa-sha256 header.s=default header.b=bIxOEOMj; dkim-atps=neutral Received: from sourceware.org (server2.sourceware.org [IPv6:2620:52:3:1:0:246e:9693:128c]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 4GbkyB75bNz9sj1 for ; Fri, 30 Jul 2021 21:02:42 +1000 (AEST) Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id B4D0F393CC3F for ; Fri, 30 Jul 2021 11:02:40 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org B4D0F393CC3F DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gcc.gnu.org; s=default; t=1627642960; bh=+KBnyEX/jw2c+pXAUHQL7Tcuhr5xucCpPsWkVB2EaeE=; h=To:Subject:Date:In-Reply-To:References:List-Id:List-Unsubscribe: List-Archive:List-Post:List-Help:List-Subscribe:From:Reply-To: From; b=bIxOEOMjPTLySeRi9kti1Mdvm4XtsNdAYi0txDYE3mAFXgGckpHd73A40dWhv4YHR avYihLrOOntR9XUCjL+zgjaDk3ea8LyR6N1zpSDih7e8zq4UHq45OzWOnq11FkQtLL TapKmFno96/YgNYJK8BRKrFUHQEPbbPXKOvgE8l4= X-Original-To: gcc-patches@gcc.gnu.org Delivered-To: gcc-patches@gcc.gnu.org Received: from mout-p-102.mailbox.org (mout-p-102.mailbox.org [IPv6:2001:67c:2050::465:102]) by sourceware.org (Postfix) with ESMTPS id 77CCB393D01E for ; Fri, 30 Jul 2021 11:01:24 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.1 sourceware.org 77CCB393D01E Received: from smtp2.mailbox.org (smtp2.mailbox.org [80.241.60.241]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange ECDHE (P-384) server-signature RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) by mout-p-102.mailbox.org (Postfix) with ESMTPS id 4Gbkwg2DPzzQk3L; Fri, 30 Jul 2021 13:01:23 +0200 (CEST) X-Virus-Scanned: amavisd-new at heinlein-support.de Received: from smtp2.mailbox.org ([80.241.60.241]) by gerste.heinlein-support.de (gerste.heinlein-support.de [91.198.250.173]) (amavisd-new, port 10030) with ESMTP id 3UCTINf0_w8K; Fri, 30 Jul 2021 13:01:20 +0200 (CEST) To: gcc-patches@gcc.gnu.org Subject: [committed 02/12] d: Drop any field or parameter types that got cached before conversion failed. Date: Fri, 30 Jul 2021 13:01:01 +0200 Message-Id: <20210730110111.569140-2-ibuclaw@gdcproject.org> In-Reply-To: <20210730110111.569140-1-ibuclaw@gdcproject.org> References: <20210730110111.569140-1-ibuclaw@gdcproject.org> MIME-Version: 1.0 X-Rspamd-Queue-Id: 7CC171842 X-Rspamd-UID: b260e7 X-Spam-Status: No, score=-15.7 required=5.0 tests=BAYES_00, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, DKIM_VALID_EF, GIT_PATCH_0, RCVD_IN_DNSWL_LOW, SPF_HELO_NONE, SPF_PASS, TXREP autolearn=ham autolearn_force=no version=3.4.4 X-Spam-Checker-Version: SpamAssassin 3.4.4 (2020-01-24) on server2.sourceware.org X-BeenThere: gcc-patches@gcc.gnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Gcc-patches mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-Patchwork-Original-From: Iain Buclaw via Gcc-patches From: Iain Buclaw Reply-To: Iain Buclaw Errors-To: gcc-patches-bounces+incoming=patchwork.ozlabs.org@gcc.gnu.org Sender: "Gcc-patches" This ensures there are no dangling references to AST members that have been freed, either explcitly or by the garbage collector. gcc/d/ChangeLog: * d-builtins.cc (build_frontend_type): Restore builtin_converted_decls length on conversion failure. --- gcc/d/d-builtins.cc | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/gcc/d/d-builtins.cc b/gcc/d/d-builtins.cc index ff2a5776dc5..9db46c0c5ca 100644 --- a/gcc/d/d-builtins.cc +++ b/gcc/d/d-builtins.cc @@ -80,7 +80,8 @@ build_frontend_type (tree type) mod |= MODshared; /* If we've seen the type before, re-use the converted decl. */ - for (size_t i = 0; i < builtin_converted_decls.length (); ++i) + unsigned saved_builtin_decls_length = builtin_converted_decls.length (); + for (size_t i = 0; i < saved_builtin_decls_length; ++i) { tree t = builtin_converted_decls[i].ctype; if (TYPE_MAIN_VARIANT (t) == TYPE_MAIN_VARIANT (type)) @@ -249,6 +250,9 @@ build_frontend_type (tree type) Type *ftype = build_frontend_type (TREE_TYPE (field)); if (!ftype) { + /* Drop any field types that got cached before the conversion + of this record type failed. */ + builtin_converted_decls.truncate (saved_builtin_decls_length); delete sdecl->members; return NULL; } @@ -307,6 +311,9 @@ build_frontend_type (tree type) Type *targ = build_frontend_type (argtype); if (!targ) { + /* Drop any parameter types that got cached before the + conversion of this function type failed. */ + builtin_converted_decls.truncate (saved_builtin_decls_length); delete args; return NULL; } From patchwork Fri Jul 30 11:01:02 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Iain Buclaw X-Patchwork-Id: 1511603 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=gcc.gnu.org (client-ip=8.43.85.97; helo=sourceware.org; envelope-from=gcc-patches-bounces+incoming=patchwork.ozlabs.org@gcc.gnu.org; receiver=) Authentication-Results: ozlabs.org; dkim=pass (1024-bit key; unprotected) header.d=gcc.gnu.org header.i=@gcc.gnu.org header.a=rsa-sha256 header.s=default header.b=Pj1/0tOZ; dkim-atps=neutral Received: from sourceware.org (server2.sourceware.org [8.43.85.97]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 4Gbkzn1Gv8z9sXk for ; Fri, 30 Jul 2021 21:04:05 +1000 (AEST) Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id 8545F393D00F for ; Fri, 30 Jul 2021 11:04:02 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 8545F393D00F DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gcc.gnu.org; s=default; t=1627643042; bh=D/cksQXdXN+8KL1C+6N7RpFx0qs+Ch+cv0KN+zIDa8s=; h=To:Subject:Date:In-Reply-To:References:List-Id:List-Unsubscribe: List-Archive:List-Post:List-Help:List-Subscribe:From:Reply-To: From; b=Pj1/0tOZkkev9cqxw1FSLe2kNEzXAqB0A8rrhwCkD3PY16r5wxIdN/xJC4piDGQLO niAD4d+OXdR13nV9k7er/BRr8U3GztqRMSQZuikpqjfb7g5u1ZVZigICD9LNtdIqGT WoWubezpM4DkvonRVMRhhPXzEcGaovdmq0xaBb4w= X-Original-To: gcc-patches@gcc.gnu.org Delivered-To: gcc-patches@gcc.gnu.org Received: from mout-p-202.mailbox.org (mout-p-202.mailbox.org [IPv6:2001:67c:2050::465:202]) by sourceware.org (Postfix) with ESMTPS id 5D627393D000 for ; Fri, 30 Jul 2021 11:01:25 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.1 sourceware.org 5D627393D000 Received: from smtp2.mailbox.org (smtp2.mailbox.org [IPv6:2001:67c:2050:105:465:1:2:0]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange ECDHE (P-384) server-signature RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) by mout-p-202.mailbox.org (Postfix) with ESMTPS id 4Gbkwh2ZYFzQk8f; Fri, 30 Jul 2021 13:01:24 +0200 (CEST) X-Virus-Scanned: amavisd-new at heinlein-support.de Received: from smtp2.mailbox.org ([80.241.60.241]) by spamfilter06.heinlein-hosting.de (spamfilter06.heinlein-hosting.de [80.241.56.125]) (amavisd-new, port 10030) with ESMTP id dXp14ZDUqo9Z; Fri, 30 Jul 2021 13:01:21 +0200 (CEST) To: gcc-patches@gcc.gnu.org Subject: [committed 03/12] d: Insert null terminator in obstack buffers Date: Fri, 30 Jul 2021 13:01:02 +0200 Message-Id: <20210730110111.569140-3-ibuclaw@gdcproject.org> In-Reply-To: <20210730110111.569140-1-ibuclaw@gdcproject.org> References: <20210730110111.569140-1-ibuclaw@gdcproject.org> MIME-Version: 1.0 X-Rspamd-Queue-Id: 9975B1849 X-Rspamd-UID: 9e604e X-Spam-Status: No, score=-15.7 required=5.0 tests=BAYES_00, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, DKIM_VALID_EF, GIT_PATCH_0, RCVD_IN_DNSWL_LOW, SPF_HELO_NONE, SPF_PASS, TXREP autolearn=ham autolearn_force=no version=3.4.4 X-Spam-Checker-Version: SpamAssassin 3.4.4 (2020-01-24) on server2.sourceware.org X-BeenThere: gcc-patches@gcc.gnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Gcc-patches mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-Patchwork-Original-From: Iain Buclaw via Gcc-patches From: Iain Buclaw Reply-To: Iain Buclaw Errors-To: gcc-patches-bounces+incoming=patchwork.ozlabs.org@gcc.gnu.org Sender: "Gcc-patches" Covers cases where functions that handle the extracted strings ignore the explicit length. This isn't something that's known to happen in the current front-end, but the self-hosted front-end has been observed to do this in its conversions between D and C-style strings. gcc/d/ChangeLog: * d-lang.cc (deps_add_target): Insert null terminator in buffer. (deps_write): Likewise. (d_parse_file): Likewise. --- gcc/d/d-lang.cc | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/gcc/d/d-lang.cc b/gcc/d/d-lang.cc index ac0945b1f34..4386a489ff2 100644 --- a/gcc/d/d-lang.cc +++ b/gcc/d/d-lang.cc @@ -108,7 +108,7 @@ deps_add_target (const char *target, bool quoted) if (!quoted) { - obstack_grow (&buffer, target, strlen (target)); + obstack_grow0 (&buffer, target, strlen (target)); d_option.deps_target.safe_push ((const char *) obstack_finish (&buffer)); return; } @@ -149,6 +149,7 @@ deps_add_target (const char *target, bool quoted) obstack_1grow (&buffer, *p); } + obstack_1grow (&buffer, '\0'); d_option.deps_target.safe_push ((const char *) obstack_finish (&buffer)); } @@ -278,6 +279,8 @@ deps_write (Module *module, obstack *buffer) obstack_grow (buffer, str, strlen (str)); obstack_grow (buffer, ":\n", 2); } + + obstack_1grow (buffer, '\0'); } /* Implements the lang_hooks.init_options routine for language D. @@ -884,6 +887,7 @@ d_parse_file (void) obstack_grow (&buffer, str, strlen (str)); } + obstack_1grow (&buffer, '\0'); message ("%s", (char *) obstack_finish (&buffer)); } } From patchwork Fri Jul 30 11:01:03 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Iain Buclaw X-Patchwork-Id: 1511606 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=gcc.gnu.org (client-ip=8.43.85.97; helo=sourceware.org; envelope-from=gcc-patches-bounces+incoming=patchwork.ozlabs.org@gcc.gnu.org; receiver=) Authentication-Results: ozlabs.org; dkim=pass (1024-bit key; unprotected) header.d=gcc.gnu.org header.i=@gcc.gnu.org header.a=rsa-sha256 header.s=default header.b=i2FOa/kg; dkim-atps=neutral Received: from sourceware.org (ip-8-43-85-97.sourceware.org [8.43.85.97]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 4Gbl0V1fMlz9sXk for ; Fri, 30 Jul 2021 21:04:42 +1000 (AEST) Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id 8EEA4393F80A for ; Fri, 30 Jul 2021 11:04:39 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 8EEA4393F80A DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gcc.gnu.org; s=default; t=1627643079; bh=fSIsm3FZ3LrjVtsXCSWNvxVHZGmM1Fhz5FIA2wIoZMw=; h=To:Subject:Date:In-Reply-To:References:List-Id:List-Unsubscribe: List-Archive:List-Post:List-Help:List-Subscribe:From:Reply-To: From; b=i2FOa/kgEdzvLQ/D7uCOsV6yhfd07sp36/VomYG5kGjbSNJ6GhR9K8V3Tl99Gpo2U eb5TyByXcco9O1YGdPozU2woxQ5ik1i1M79oQkUUJlKgWM3c9QH3joDjyYRz8uyMcW 2rZvQupFCzYkoD6CowSb/GMpcL/ruQ2LhVKWY+Ic= X-Original-To: gcc-patches@gcc.gnu.org Delivered-To: gcc-patches@gcc.gnu.org Received: from mout-p-201.mailbox.org (mout-p-201.mailbox.org [IPv6:2001:67c:2050::465:201]) by sourceware.org (Postfix) with ESMTPS id DC8AC393F828 for ; Fri, 30 Jul 2021 11:01:26 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.1 sourceware.org DC8AC393F828 Received: from smtp2.mailbox.org (smtp2.mailbox.org [IPv6:2001:67c:2050:105:465:1:2:0]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange ECDHE (P-384) server-signature RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) by mout-p-201.mailbox.org (Postfix) with ESMTPS id 4Gbkwj517SzQjhX; Fri, 30 Jul 2021 13:01:25 +0200 (CEST) X-Virus-Scanned: amavisd-new at heinlein-support.de Received: from smtp2.mailbox.org ([80.241.60.241]) by spamfilter03.heinlein-hosting.de (spamfilter03.heinlein-hosting.de [80.241.56.117]) (amavisd-new, port 10030) with ESMTP id CnJVonfqXl5s; Fri, 30 Jul 2021 13:01:22 +0200 (CEST) To: gcc-patches@gcc.gnu.org Subject: [committed 04/12] d: Use hasMonitor to determine whether to emit a __monitor field in D classes Date: Fri, 30 Jul 2021 13:01:03 +0200 Message-Id: <20210730110111.569140-4-ibuclaw@gdcproject.org> In-Reply-To: <20210730110111.569140-1-ibuclaw@gdcproject.org> References: <20210730110111.569140-1-ibuclaw@gdcproject.org> MIME-Version: 1.0 X-Rspamd-Queue-Id: E353F182F X-Rspamd-UID: 651b92 X-Spam-Status: No, score=-15.7 required=5.0 tests=BAYES_00, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, DKIM_VALID_EF, GIT_PATCH_0, RCVD_IN_DNSWL_LOW, SPF_HELO_NONE, SPF_PASS, TXREP autolearn=ham autolearn_force=no version=3.4.4 X-Spam-Checker-Version: SpamAssassin 3.4.4 (2020-01-24) on server2.sourceware.org X-BeenThere: gcc-patches@gcc.gnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Gcc-patches mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-Patchwork-Original-From: Iain Buclaw via Gcc-patches From: Iain Buclaw Reply-To: Iain Buclaw Errors-To: gcc-patches-bounces+incoming=patchwork.ozlabs.org@gcc.gnu.org Sender: "Gcc-patches" This helper introduced by the front-end is a better gate, and allows the front-end to change rules for what gets a monitor in the future. gcc/d/ChangeLog: * types.cc (layout_aggregate_type): Call hasMonitor. * typeinfo.cc (TypeInfoVisitor::layout_base): Likewise. (layout_cpp_typeinfo): Likewise. Don't emit vtable unless have_typeinfo_p. --- gcc/d/typeinfo.cc | 21 ++++++++++++++------- gcc/d/types.cc | 2 +- 2 files changed, 15 insertions(+), 8 deletions(-) diff --git a/gcc/d/typeinfo.cc b/gcc/d/typeinfo.cc index a1f0543d58e..c9126f4c6b5 100644 --- a/gcc/d/typeinfo.cc +++ b/gcc/d/typeinfo.cc @@ -423,7 +423,8 @@ class TypeInfoVisitor : public Visitor else this->layout_field (null_pointer_node); - this->layout_field (null_pointer_node); + if (cd->hasMonitor ()) + this->layout_field (null_pointer_node); } /* Write out the interfaces field of class CD. @@ -1457,9 +1458,17 @@ layout_cpp_typeinfo (ClassDeclaration *cd) /* Use the vtable of __cpp_type_info_ptr, the EH personality routine expects this, as it uses .classinfo identity comparison to test for C++ catch handlers. */ - tree vptr = get_vtable_decl (ClassDeclaration::cpp_type_info_ptr); - CONSTRUCTOR_APPEND_ELT (init, NULL_TREE, build_address (vptr)); - CONSTRUCTOR_APPEND_ELT (init, NULL_TREE, null_pointer_node); + ClassDeclaration *cppti = ClassDeclaration::cpp_type_info_ptr; + if (have_typeinfo_p (cppti)) + { + tree vptr = get_vtable_decl (cppti); + CONSTRUCTOR_APPEND_ELT (init, NULL_TREE, build_address (vptr)); + } + else + CONSTRUCTOR_APPEND_ELT (init, NULL_TREE, null_pointer_node); + + if (cppti->hasMonitor ()) + CONSTRUCTOR_APPEND_ELT (init, NULL_TREE, null_pointer_node); /* Let C++ do the RTTI generation, and just reference the symbol as extern, knowing the underlying type is not required. */ @@ -1471,9 +1480,7 @@ layout_cpp_typeinfo (ClassDeclaration *cd) /* Build the initializer and emit. */ DECL_INITIAL (decl) = build_struct_literal (TREE_TYPE (decl), init); - DECL_EXTERNAL (decl) = 0; - d_pushdecl (decl); - rest_of_decl_compilation (decl, 1, 0); + d_finish_decl (decl); } /* Get the VAR_DECL of the __cpp_type_info_ptr for DECL. If this does not yet diff --git a/gcc/d/types.cc b/gcc/d/types.cc index ba2d6d4dc66..8e674618004 100644 --- a/gcc/d/types.cc +++ b/gcc/d/types.cc @@ -469,7 +469,7 @@ layout_aggregate_type (AggregateDeclaration *decl, tree type, insert_aggregate_field (type, field, 0); } - if (!id && !cd->isCPPclass ()) + if (!id && cd->hasMonitor ()) { tree field = create_field_decl (ptr_type_node, "__monitor", 1, inherited_p); From patchwork Fri Jul 30 11:01:04 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Iain Buclaw X-Patchwork-Id: 1511608 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=gcc.gnu.org (client-ip=2620:52:3:1:0:246e:9693:128c; helo=sourceware.org; envelope-from=gcc-patches-bounces+incoming=patchwork.ozlabs.org@gcc.gnu.org; receiver=) Authentication-Results: ozlabs.org; dkim=pass (1024-bit key; unprotected) header.d=gcc.gnu.org header.i=@gcc.gnu.org header.a=rsa-sha256 header.s=default header.b=Z+U60y1N; dkim-atps=neutral Received: from sourceware.org (server2.sourceware.org [IPv6:2620:52:3:1:0:246e:9693:128c]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 4Gbl235J4Zz9sXk for ; Fri, 30 Jul 2021 21:06:03 +1000 (AEST) Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id 94E9F393D03F for ; Fri, 30 Jul 2021 11:06:01 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 94E9F393D03F DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gcc.gnu.org; s=default; t=1627643161; bh=PxvhAPVjGWetlorBH4syYYpGOi9kkea0h1B/vhg0JMo=; h=To:Subject:Date:In-Reply-To:References:List-Id:List-Unsubscribe: List-Archive:List-Post:List-Help:List-Subscribe:From:Reply-To: From; b=Z+U60y1NUtxYIjcMjPEThFrHVL6gUtCLuqa662YExyfjLzO+out7yoo646lUZBDAf 3bZ5FYfPqRHbs3rFHI9kZNjDCAr2hgvosGgOr2eMLJjWNR1GlWQ2d+l1IZ+OfuZFto eKX4dnADDfTaKcZ2kq8GbF7o+NK9Ox9Z7djj7OyM= X-Original-To: gcc-patches@gcc.gnu.org Delivered-To: gcc-patches@gcc.gnu.org Received: from mout-p-102.mailbox.org (mout-p-102.mailbox.org [80.241.56.152]) by sourceware.org (Postfix) with ESMTPS id EEBB4393F801 for ; Fri, 30 Jul 2021 11:01:27 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.1 sourceware.org EEBB4393F801 Received: from smtp2.mailbox.org (smtp2.mailbox.org [IPv6:2001:67c:2050:105:465:1:2:0]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange ECDHE (P-384) server-signature RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) by mout-p-102.mailbox.org (Postfix) with ESMTPS id 4Gbkwl0BNczQk3S; Fri, 30 Jul 2021 13:01:27 +0200 (CEST) X-Virus-Scanned: amavisd-new at heinlein-support.de Received: from smtp2.mailbox.org ([80.241.60.241]) by gerste.heinlein-support.de (gerste.heinlein-support.de [91.198.250.173]) (amavisd-new, port 10030) with ESMTP id YS5jq6ZpXakA; Fri, 30 Jul 2021 13:01:24 +0200 (CEST) To: gcc-patches@gcc.gnu.org Subject: [committed 05/12] d: Use Identifier::idPool to generate anonymous field name. Date: Fri, 30 Jul 2021 13:01:04 +0200 Message-Id: <20210730110111.569140-5-ibuclaw@gdcproject.org> In-Reply-To: <20210730110111.569140-1-ibuclaw@gdcproject.org> References: <20210730110111.569140-1-ibuclaw@gdcproject.org> MIME-Version: 1.0 X-Rspamd-Queue-Id: 3E6CA1823 X-Rspamd-UID: 73a85b X-Spam-Status: No, score=-15.7 required=5.0 tests=BAYES_00, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, DKIM_VALID_EF, GIT_PATCH_0, RCVD_IN_DNSWL_LOW, RCVD_IN_MSPIKE_H4, RCVD_IN_MSPIKE_WL, SPF_HELO_NONE, SPF_PASS, TXREP autolearn=ham autolearn_force=no version=3.4.4 X-Spam-Checker-Version: SpamAssassin 3.4.4 (2020-01-24) on server2.sourceware.org X-BeenThere: gcc-patches@gcc.gnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Gcc-patches mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-Patchwork-Original-From: Iain Buclaw via Gcc-patches From: Iain Buclaw Reply-To: Iain Buclaw Errors-To: gcc-patches-bounces+incoming=patchwork.ozlabs.org@gcc.gnu.org Sender: "Gcc-patches" The self-hosted implementation of the D front-end does not export Identifier::generateId, so handle name generation inline instead. gcc/d/ChangeLog: * d-builtins.cc (build_frontend_type): Use Identifier::idPool to generate anonymous field name. --- gcc/d/d-builtins.cc | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/gcc/d/d-builtins.cc b/gcc/d/d-builtins.cc index 9db46c0c5ca..328711fc745 100644 --- a/gcc/d/d-builtins.cc +++ b/gcc/d/d-builtins.cc @@ -241,8 +241,8 @@ build_frontend_type (tree type) sdecl->type->merge2 (); /* Add both named and anonymous fields as members of the struct. - Anonymous fields still need a name in D, so call them "__pad%d". */ - int anonfield_id = 0; + Anonymous fields still need a name in D, so call them "__pad%u". */ + unsigned anonfield_id = 0; sdecl->members = new Dsymbols; for (tree field = TYPE_FIELDS (type); field; field = DECL_CHAIN (field)) @@ -259,7 +259,11 @@ build_frontend_type (tree type) Identifier *fident; if (DECL_NAME (field) == NULL_TREE) - fident = Identifier::generateId ("__pad", anonfield_id++); + { + char name[16]; + snprintf (name, sizeof (name), "__pad%u", anonfield_id++); + fident = Identifier::idPool (name); + } else { const char *name = IDENTIFIER_POINTER (DECL_NAME (field)); From patchwork Fri Jul 30 11:01:05 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Iain Buclaw X-Patchwork-Id: 1511610 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=gcc.gnu.org (client-ip=8.43.85.97; helo=sourceware.org; envelope-from=gcc-patches-bounces+incoming=patchwork.ozlabs.org@gcc.gnu.org; receiver=) Authentication-Results: ozlabs.org; dkim=pass (1024-bit key; unprotected) header.d=gcc.gnu.org header.i=@gcc.gnu.org header.a=rsa-sha256 header.s=default header.b=aiA0D1N0; dkim-atps=neutral Received: from sourceware.org (ip-8-43-85-97.sourceware.org [8.43.85.97]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 4Gbl2z49v2z9sfG for ; Fri, 30 Jul 2021 21:06:51 +1000 (AEST) Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id A942D393F832 for ; Fri, 30 Jul 2021 11:06:48 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org A942D393F832 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gcc.gnu.org; s=default; t=1627643208; bh=isDfvs9OHaFZkG5ALVOI6s0wjZJzpsnbu/bPR+ZAPrA=; h=To:Subject:Date:In-Reply-To:References:List-Id:List-Unsubscribe: List-Archive:List-Post:List-Help:List-Subscribe:From:Reply-To: From; b=aiA0D1N0qVEWr2OU6+F3cEACHRNH+FwvJ3yNhv48iK0pz3aGhypSlPnRoBZS0hVVW 5eDic4ZYXVs2wzJ/QS+lF2aqJ8eoSos0EisuwUK8vXR5bHDsC4UbbFnExqYb/8SGli mI3fZEo6OK768MJ2jKQYGPIoQFLlC9scUPI/UDVk= X-Original-To: gcc-patches@gcc.gnu.org Delivered-To: gcc-patches@gcc.gnu.org Received: from mout-p-101.mailbox.org (mout-p-101.mailbox.org [IPv6:2001:67c:2050::465:101]) by sourceware.org (Postfix) with ESMTPS id 4686F393F82B for ; Fri, 30 Jul 2021 11:01:29 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.1 sourceware.org 4686F393F82B Received: from smtp2.mailbox.org (smtp2.mailbox.org [80.241.60.241]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange ECDHE (P-384) server-signature RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) by mout-p-101.mailbox.org (Postfix) with ESMTPS id 4Gbkwm27KPzQk3Q; Fri, 30 Jul 2021 13:01:28 +0200 (CEST) X-Virus-Scanned: amavisd-new at heinlein-support.de Received: from smtp2.mailbox.org ([80.241.60.241]) by spamfilter06.heinlein-hosting.de (spamfilter06.heinlein-hosting.de [80.241.56.125]) (amavisd-new, port 10030) with ESMTP id nYHfPKWRKpXN; Fri, 30 Jul 2021 13:01:25 +0200 (CEST) To: gcc-patches@gcc.gnu.org Subject: [committed 06/12] d: Factor aggregate_initializer_decl to set the sinit for aggregate declarations. Date: Fri, 30 Jul 2021 13:01:05 +0200 Message-Id: <20210730110111.569140-6-ibuclaw@gdcproject.org> In-Reply-To: <20210730110111.569140-1-ibuclaw@gdcproject.org> References: <20210730110111.569140-1-ibuclaw@gdcproject.org> MIME-Version: 1.0 X-Rspamd-Queue-Id: 8870B1838 X-Rspamd-UID: 3594b6 X-Spam-Status: No, score=-15.7 required=5.0 tests=BAYES_00, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, DKIM_VALID_EF, GIT_PATCH_0, RCVD_IN_DNSWL_LOW, SPF_HELO_NONE, SPF_PASS, TXREP autolearn=ham autolearn_force=no version=3.4.4 X-Spam-Checker-Version: SpamAssassin 3.4.4 (2020-01-24) on server2.sourceware.org X-BeenThere: gcc-patches@gcc.gnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Gcc-patches mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-Patchwork-Original-From: Iain Buclaw via Gcc-patches From: Iain Buclaw Reply-To: Iain Buclaw Errors-To: gcc-patches-bounces+incoming=patchwork.ozlabs.org@gcc.gnu.org Sender: "Gcc-patches" The self-hosted implementation of the D front-end changes the type of `sinit' to a void pointer, which requires an explicit cast to `tree'. gcc/d/ChangeLog: * decl.cc (DeclVisitor::visit (StructDeclaration *)): Don't use sinit for declaration directly. (DeclVisitor::visit (ClassDeclaration *)): Likewise. (aggregate_initializer_decl): Likewise. Set sinit after creating. --- gcc/d/decl.cc | 29 +++++++++++++++-------------- 1 file changed, 15 insertions(+), 14 deletions(-) diff --git a/gcc/d/decl.cc b/gcc/d/decl.cc index 7d1378255bd..59991c3c255 100644 --- a/gcc/d/decl.cc +++ b/gcc/d/decl.cc @@ -386,9 +386,9 @@ public: create_typeinfo (d->type, NULL); /* Generate static initializer. */ - d->sinit = aggregate_initializer_decl (d); - DECL_INITIAL (d->sinit) = layout_struct_initializer (d); - d_finish_decl (d->sinit); + tree sinit = aggregate_initializer_decl (d); + DECL_INITIAL (sinit) = layout_struct_initializer (d); + d_finish_decl (sinit); /* Put out the members. There might be static constructors in the members list, and they cannot be put in separate object files. */ @@ -496,11 +496,11 @@ public: /* Generate C symbols. */ d->csym = get_classinfo_decl (d); d->vtblsym = get_vtable_decl (d); - d->sinit = aggregate_initializer_decl (d); + tree sinit = aggregate_initializer_decl (d); /* Generate static initializer. */ - DECL_INITIAL (d->sinit) = layout_class_initializer (d); - d_finish_decl (d->sinit); + DECL_INITIAL (sinit) = layout_class_initializer (d); + d_finish_decl (sinit); /* Put out the TypeInfo. */ if (have_typeinfo_p (Type::dtypeinfo)) @@ -2151,7 +2151,7 @@ tree aggregate_initializer_decl (AggregateDeclaration *decl) { if (decl->sinit) - return decl->sinit; + return (tree) decl->sinit; /* Class is a reference, want the record type. */ tree type = build_ctype (decl->type); @@ -2161,20 +2161,21 @@ aggregate_initializer_decl (AggregateDeclaration *decl) tree ident = mangle_internal_decl (decl, "__init", "Z"); - decl->sinit = declare_extern_var (ident, type); - DECL_LANG_SPECIFIC (decl->sinit) = build_lang_decl (NULL); + tree sinit = declare_extern_var (ident, type); + DECL_LANG_SPECIFIC (sinit) = build_lang_decl (NULL); - DECL_CONTEXT (decl->sinit) = type; - TREE_READONLY (decl->sinit) = 1; + DECL_CONTEXT (sinit) = type; + TREE_READONLY (sinit) = 1; /* Honor struct alignment set by user. */ if (sd && sd->alignment != STRUCTALIGN_DEFAULT) { - SET_DECL_ALIGN (decl->sinit, sd->alignment * BITS_PER_UNIT); - DECL_USER_ALIGN (decl->sinit) = true; + SET_DECL_ALIGN (sinit, sd->alignment * BITS_PER_UNIT); + DECL_USER_ALIGN (sinit) = true; } - return decl->sinit; + decl->sinit = sinit; + return sinit; } /* Generate the data for the static initializer. */ From patchwork Fri Jul 30 11:01:06 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Iain Buclaw X-Patchwork-Id: 1511612 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=gcc.gnu.org (client-ip=2620:52:3:1:0:246e:9693:128c; helo=sourceware.org; envelope-from=gcc-patches-bounces+incoming=patchwork.ozlabs.org@gcc.gnu.org; receiver=) Authentication-Results: ozlabs.org; dkim=pass (1024-bit key; unprotected) header.d=gcc.gnu.org header.i=@gcc.gnu.org header.a=rsa-sha256 header.s=default header.b=LnwgeXei; dkim-atps=neutral Received: from sourceware.org (server2.sourceware.org [IPv6:2620:52:3:1:0:246e:9693:128c]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 4Gbl4Y1kmlz9sXk for ; Fri, 30 Jul 2021 21:08:13 +1000 (AEST) Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id A3D72393D022 for ; Fri, 30 Jul 2021 11:08:10 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org A3D72393D022 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gcc.gnu.org; s=default; t=1627643290; bh=o9Ij/nYZbLZvaq1fZzxv1xfgYKRFbGIda6FcKcOTPMc=; h=To:Subject:Date:In-Reply-To:References:List-Id:List-Unsubscribe: List-Archive:List-Post:List-Help:List-Subscribe:From:Reply-To: From; b=LnwgeXeikAvKWnHn9BqmVkI0B1pEDoX+GoCHjpzqnzCkUAlnDvdYbxRUIxP/59EAA RozKBal9el73U0XcWyeKsNbyMhscXUDPZZzmNq8bcKoZ0sIuphuVTx5VnxjXg/QdG0 0/B5SEmVijqzK6cVNWWiAxHwRvVz+QFEpF0oQ3lU= X-Original-To: gcc-patches@gcc.gnu.org Delivered-To: gcc-patches@gcc.gnu.org Received: from mout-p-201.mailbox.org (mout-p-201.mailbox.org [80.241.56.171]) by sourceware.org (Postfix) with ESMTPS id 795CD393FC34 for ; Fri, 30 Jul 2021 11:01:30 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.1 sourceware.org 795CD393FC34 Received: from smtp2.mailbox.org (smtp2.mailbox.org [80.241.60.241]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange ECDHE (P-384) server-signature RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) by mout-p-201.mailbox.org (Postfix) with ESMTPS id 4Gbkwn4PvJzQkBN; Fri, 30 Jul 2021 13:01:29 +0200 (CEST) X-Virus-Scanned: amavisd-new at heinlein-support.de Received: from smtp2.mailbox.org ([80.241.60.241]) by spamfilter01.heinlein-hosting.de (spamfilter01.heinlein-hosting.de [80.241.56.115]) (amavisd-new, port 10030) with ESMTP id ZMn8ruWT9Wja; Fri, 30 Jul 2021 13:01:26 +0200 (CEST) To: gcc-patches@gcc.gnu.org Subject: [committed 07/12] d: Set COMDAT and visibility of thunks only if they are public. Date: Fri, 30 Jul 2021 13:01:06 +0200 Message-Id: <20210730110111.569140-7-ibuclaw@gdcproject.org> In-Reply-To: <20210730110111.569140-1-ibuclaw@gdcproject.org> References: <20210730110111.569140-1-ibuclaw@gdcproject.org> MIME-Version: 1.0 X-Rspamd-Queue-Id: D80C31846 X-Rspamd-UID: 19fe25 X-Spam-Status: No, score=-15.7 required=5.0 tests=BAYES_00, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, DKIM_VALID_EF, GIT_PATCH_0, RCVD_IN_DNSWL_LOW, SPF_HELO_NONE, SPF_PASS, TXREP autolearn=ham autolearn_force=no version=3.4.4 X-Spam-Checker-Version: SpamAssassin 3.4.4 (2020-01-24) on server2.sourceware.org X-BeenThere: gcc-patches@gcc.gnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Gcc-patches mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-Patchwork-Original-From: Iain Buclaw via Gcc-patches From: Iain Buclaw Reply-To: Iain Buclaw Errors-To: gcc-patches-bounces+incoming=patchwork.ozlabs.org@gcc.gnu.org Sender: "Gcc-patches" It is not expected to have a member function that can be non-public, but this guards against any internal errors that might occur should that ever change in the front-end. gcc/d/ChangeLog: * decl.cc (make_thunk): Set COMDAT and visibility of thunks only if they are public. --- gcc/d/decl.cc | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/gcc/d/decl.cc b/gcc/d/decl.cc index 59991c3c255..cf61cd49159 100644 --- a/gcc/d/decl.cc +++ b/gcc/d/decl.cc @@ -1781,9 +1781,12 @@ make_thunk (FuncDeclaration *decl, int offset) DECL_ARTIFICIAL (thunk) = 1; DECL_DECLARED_INLINE_P (thunk) = 0; - DECL_VISIBILITY (thunk) = DECL_VISIBILITY (function); - DECL_COMDAT (thunk) = DECL_COMDAT (function); - DECL_WEAK (thunk) = DECL_WEAK (function); + if (TREE_PUBLIC (thunk)) + { + DECL_VISIBILITY (thunk) = DECL_VISIBILITY (function); + DECL_COMDAT (thunk) = DECL_COMDAT (function); + DECL_WEAK (thunk) = DECL_WEAK (function); + } /* When the thunk is for an extern C++ function, let C++ do the thunk generation and just reference the symbol as extern, instead of From patchwork Fri Jul 30 11:01:07 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Iain Buclaw X-Patchwork-Id: 1511613 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=gcc.gnu.org (client-ip=2620:52:3:1:0:246e:9693:128c; helo=sourceware.org; envelope-from=gcc-patches-bounces+incoming=patchwork.ozlabs.org@gcc.gnu.org; receiver=) Authentication-Results: ozlabs.org; dkim=pass (1024-bit key; unprotected) header.d=gcc.gnu.org header.i=@gcc.gnu.org header.a=rsa-sha256 header.s=default header.b=PJrAZPsZ; dkim-atps=neutral Received: from sourceware.org (server2.sourceware.org [IPv6:2620:52:3:1:0:246e:9693:128c]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 4Gbl5F6Pqlz9sXk for ; Fri, 30 Jul 2021 21:08:49 +1000 (AEST) Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id BA9ED3942011 for ; Fri, 30 Jul 2021 11:08:47 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org BA9ED3942011 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gcc.gnu.org; s=default; t=1627643327; bh=E1CmysLtGg3TGFH0tPfkfwFvU1m2Lt8tCXcD9Jmthac=; h=To:Subject:Date:In-Reply-To:References:List-Id:List-Unsubscribe: List-Archive:List-Post:List-Help:List-Subscribe:From:Reply-To: From; b=PJrAZPsZdYRvRlN4o+XDXIP7KSDuwpZTko9aycNgg5K8G2EyZjrNlQtZXsikaphYP R3nmlP1657HmIfH9Y6NLmayhZQW+ornkbDo2YMAvnN56LXvrmGfnTwCRhIyo4iEXbS a2Idl6EpDE8zSRDOP0CagRvKYNBFPv+PaDqKbzHc= X-Original-To: gcc-patches@gcc.gnu.org Delivered-To: gcc-patches@gcc.gnu.org Received: from mout-p-202.mailbox.org (mout-p-202.mailbox.org [IPv6:2001:67c:2050::465:202]) by sourceware.org (Postfix) with ESMTPS id 57CA5393CC3F for ; Fri, 30 Jul 2021 11:01:31 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.1 sourceware.org 57CA5393CC3F Received: from smtp2.mailbox.org (smtp2.mailbox.org [IPv6:2001:67c:2050:105:465:1:2:0]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange ECDHE (P-384) server-signature RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) by mout-p-202.mailbox.org (Postfix) with ESMTPS id 4Gbkwp3yPVzQk8f; Fri, 30 Jul 2021 13:01:30 +0200 (CEST) X-Virus-Scanned: amavisd-new at heinlein-support.de Received: from smtp2.mailbox.org ([80.241.60.241]) by gerste.heinlein-support.de (gerste.heinlein-support.de [91.198.250.173]) (amavisd-new, port 10030) with ESMTP id vilXRnmibVDP; Fri, 30 Jul 2021 13:01:27 +0200 (CEST) To: gcc-patches@gcc.gnu.org Subject: [committed 08/12] d: Only handle named enums in enum_initializer_decl Date: Fri, 30 Jul 2021 13:01:07 +0200 Message-Id: <20210730110111.569140-8-ibuclaw@gdcproject.org> In-Reply-To: <20210730110111.569140-1-ibuclaw@gdcproject.org> References: <20210730110111.569140-1-ibuclaw@gdcproject.org> MIME-Version: 1.0 X-Rspamd-Queue-Id: CAAE3183B X-Rspamd-UID: 063f1e X-Spam-Status: No, score=-15.7 required=5.0 tests=BAYES_00, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, DKIM_VALID_EF, GIT_PATCH_0, RCVD_IN_DNSWL_LOW, SPF_HELO_NONE, SPF_PASS, TXREP autolearn=ham autolearn_force=no version=3.4.4 X-Spam-Checker-Version: SpamAssassin 3.4.4 (2020-01-24) on server2.sourceware.org X-BeenThere: gcc-patches@gcc.gnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Gcc-patches mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-Patchwork-Original-From: Iain Buclaw via Gcc-patches From: Iain Buclaw Reply-To: Iain Buclaw Errors-To: gcc-patches-bounces+incoming=patchwork.ozlabs.org@gcc.gnu.org Sender: "Gcc-patches" Anonymous enums neither generate an initializer nor typeinfo symbol, so it's safe to assert that all enum declarations passed to this function always have an identifier. gcc/d/ChangeLog: * decl.cc (enum_initializer_decl): Only handle named enums. --- gcc/d/decl.cc | 7 ++----- 1 file changed, 2 insertions(+), 5 deletions(-) diff --git a/gcc/d/decl.cc b/gcc/d/decl.cc index cf61cd49159..0d46ee180e7 100644 --- a/gcc/d/decl.cc +++ b/gcc/d/decl.cc @@ -2218,13 +2218,10 @@ enum_initializer_decl (EnumDeclaration *decl) if (decl->sinit) return decl->sinit; - tree type = build_ctype (decl->type); + gcc_assert (decl->ident); - Identifier *ident_save = decl->ident; - if (!decl->ident) - decl->ident = Identifier::generateId ("__enum"); + tree type = build_ctype (decl->type); tree ident = mangle_internal_decl (decl, "__init", "Z"); - decl->ident = ident_save; decl->sinit = declare_extern_var (ident, type); DECL_LANG_SPECIFIC (decl->sinit) = build_lang_decl (NULL); From patchwork Fri Jul 30 11:01:08 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Iain Buclaw X-Patchwork-Id: 1511614 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=gcc.gnu.org (client-ip=2620:52:3:1:0:246e:9693:128c; helo=sourceware.org; envelope-from=gcc-patches-bounces+incoming=patchwork.ozlabs.org@gcc.gnu.org; receiver=) Authentication-Results: ozlabs.org; dkim=pass (1024-bit key; unprotected) header.d=gcc.gnu.org header.i=@gcc.gnu.org header.a=rsa-sha256 header.s=default header.b=FQLc84sP; dkim-atps=neutral Received: from sourceware.org (server2.sourceware.org [IPv6:2620:52:3:1:0:246e:9693:128c]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 4Gbl6q69mwz9sXk for ; Fri, 30 Jul 2021 21:10:11 +1000 (AEST) Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id B0CA7393F826 for ; Fri, 30 Jul 2021 11:10:09 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org B0CA7393F826 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gcc.gnu.org; s=default; t=1627643409; bh=wlOGkFygInsLG2n9el5eABtVfrQq+kUkQngcMKUCDZI=; h=To:Subject:Date:In-Reply-To:References:List-Id:List-Unsubscribe: List-Archive:List-Post:List-Help:List-Subscribe:From:Reply-To: From; b=FQLc84sPDuUphAcRRkNLrlFzWn1E6qDB2v6taCPdHaC/SiagQ4l+joydwFOA5SDVB xjNS7jjHDNAChg/V4thmOmwcV/p8aw8YsXMvIMLg9FRawfTcE9Uaghk93DapEtWRrE ZOcc5M/R1IKqKj5uUVP6AkS9PUy9he8SZmoY9WFc= X-Original-To: gcc-patches@gcc.gnu.org Delivered-To: gcc-patches@gcc.gnu.org Received: from mout-p-101.mailbox.org (mout-p-101.mailbox.org [IPv6:2001:67c:2050::465:101]) by sourceware.org (Postfix) with ESMTPS id 25EAC393F812 for ; Fri, 30 Jul 2021 11:01:32 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.1 sourceware.org 25EAC393F812 Received: from smtp2.mailbox.org (smtp2.mailbox.org [80.241.60.241]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange ECDHE (P-384) server-signature RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) by mout-p-101.mailbox.org (Postfix) with ESMTPS id 4Gbkwq2fbVzQk9Z; Fri, 30 Jul 2021 13:01:31 +0200 (CEST) X-Virus-Scanned: amavisd-new at heinlein-support.de Received: from smtp2.mailbox.org ([80.241.60.241]) by spamfilter06.heinlein-hosting.de (spamfilter06.heinlein-hosting.de [80.241.56.125]) (amavisd-new, port 10030) with ESMTP id wGD_XAMT4U_E; Fri, 30 Jul 2021 13:01:28 +0200 (CEST) To: gcc-patches@gcc.gnu.org Subject: [committed 09/12] d: Clarify comment for generating static array assignment with literal. Date: Fri, 30 Jul 2021 13:01:08 +0200 Message-Id: <20210730110111.569140-9-ibuclaw@gdcproject.org> In-Reply-To: <20210730110111.569140-1-ibuclaw@gdcproject.org> References: <20210730110111.569140-1-ibuclaw@gdcproject.org> MIME-Version: 1.0 X-Rspamd-Queue-Id: 99200183E X-Rspamd-UID: 6f24ab X-Spam-Status: No, score=-15.7 required=5.0 tests=BAYES_00, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, DKIM_VALID_EF, GIT_PATCH_0, RCVD_IN_DNSWL_LOW, SPF_HELO_NONE, SPF_PASS, TXREP autolearn=ham autolearn_force=no version=3.4.4 X-Spam-Checker-Version: SpamAssassin 3.4.4 (2020-01-24) on server2.sourceware.org X-BeenThere: gcc-patches@gcc.gnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Gcc-patches mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-Patchwork-Original-From: Iain Buclaw via Gcc-patches From: Iain Buclaw Reply-To: Iain Buclaw Errors-To: gcc-patches-bounces+incoming=patchwork.ozlabs.org@gcc.gnu.org Sender: "Gcc-patches" The code block is done as an optimization to elide a call to the runtime library helpers _d_arrayctor or _d_arrayassign. gcc/d/ChangeLog: * expr.cc (ExprVisitor::visit (AssignExp *)): Clarify comment for generating static array assignment with literal. --- gcc/d/expr.cc | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/gcc/d/expr.cc b/gcc/d/expr.cc index 85269c6b2be..76c1e613e77 100644 --- a/gcc/d/expr.cc +++ b/gcc/d/expr.cc @@ -1163,9 +1163,9 @@ public: bool destructor = needs_dtor (etype); bool lvalue = lvalue_p (e->e2); - /* Even if the elements in rhs are all rvalues and don't have - to call postblits, this assignment should call dtors on old - assigned elements. */ + /* Optimize static array assignment with array literal. Even if the + elements in rhs are all rvalues and don't have to call postblits, + this assignment should call dtors on old assigned elements. */ if ((!postblit && !destructor) || (e->op == TOKconstruct && e->e2->op == TOKarrayliteral) || (e->op == TOKconstruct && !lvalue && postblit) From patchwork Fri Jul 30 11:01:09 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Iain Buclaw X-Patchwork-Id: 1511615 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=gcc.gnu.org (client-ip=8.43.85.97; helo=sourceware.org; envelope-from=gcc-patches-bounces+incoming=patchwork.ozlabs.org@gcc.gnu.org; receiver=) Authentication-Results: ozlabs.org; dkim=pass (1024-bit key; unprotected) header.d=gcc.gnu.org header.i=@gcc.gnu.org header.a=rsa-sha256 header.s=default header.b=bSALSrVQ; dkim-atps=neutral Received: from sourceware.org (server2.sourceware.org [8.43.85.97]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 4Gbl7Z0FDSz9sXk for ; Fri, 30 Jul 2021 21:10:49 +1000 (AEST) Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id CCCAB3942029 for ; Fri, 30 Jul 2021 11:10:46 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org CCCAB3942029 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gcc.gnu.org; s=default; t=1627643446; bh=DJI6aAdhvC6B9e9feYHW5gctfd0BHlG8C11NEGnQm8c=; h=To:Subject:Date:In-Reply-To:References:List-Id:List-Unsubscribe: List-Archive:List-Post:List-Help:List-Subscribe:From:Reply-To: From; b=bSALSrVQMQvngWHegaYA7GVGRnbtGQ9ZfKYvxg1lCU9HSEOxuyM25MInDnmNJDmvs v90OBTs1rp/X/BckKs4WWpNIRawIRAWikTG9U8ra2vqQ/sjhbWQTw/O9eSwhd3tLej 8F7Az1XVTdGEbup5sN4baUlOLoZgh/XWDd/cKMoY= X-Original-To: gcc-patches@gcc.gnu.org Delivered-To: gcc-patches@gcc.gnu.org Received: from mout-p-102.mailbox.org (mout-p-102.mailbox.org [IPv6:2001:67c:2050::465:102]) by sourceware.org (Postfix) with ESMTPS id 2336E393D01A for ; Fri, 30 Jul 2021 11:01:33 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.1 sourceware.org 2336E393D01A Received: from smtp2.mailbox.org (smtp2.mailbox.org [80.241.60.241]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange ECDHE (P-384) server-signature RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) by mout-p-102.mailbox.org (Postfix) with ESMTPS id 4Gbkwr2PzszQk3L; Fri, 30 Jul 2021 13:01:32 +0200 (CEST) X-Virus-Scanned: amavisd-new at heinlein-support.de Received: from smtp2.mailbox.org ([80.241.60.241]) by spamfilter02.heinlein-hosting.de (spamfilter02.heinlein-hosting.de [80.241.56.116]) (amavisd-new, port 10030) with ESMTP id fPs5CLGcLxcu; Fri, 30 Jul 2021 13:01:29 +0200 (CEST) To: gcc-patches@gcc.gnu.org Subject: [committed 10/12] d: Don't generate a PREDICT_EXPR when assert contracts are turned off. Date: Fri, 30 Jul 2021 13:01:09 +0200 Message-Id: <20210730110111.569140-10-ibuclaw@gdcproject.org> In-Reply-To: <20210730110111.569140-1-ibuclaw@gdcproject.org> References: <20210730110111.569140-1-ibuclaw@gdcproject.org> MIME-Version: 1.0 X-Rspamd-Queue-Id: 9FA8D1838 X-Rspamd-UID: 689ed4 X-Spam-Status: No, score=-15.7 required=5.0 tests=BAYES_00, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, DKIM_VALID_EF, GIT_PATCH_0, RCVD_IN_DNSWL_LOW, SPF_HELO_NONE, SPF_PASS, TXREP autolearn=ham autolearn_force=no version=3.4.4 X-Spam-Checker-Version: SpamAssassin 3.4.4 (2020-01-24) on server2.sourceware.org X-BeenThere: gcc-patches@gcc.gnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Gcc-patches mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-Patchwork-Original-From: Iain Buclaw via Gcc-patches From: Iain Buclaw Reply-To: Iain Buclaw Errors-To: gcc-patches-bounces+incoming=patchwork.ozlabs.org@gcc.gnu.org Sender: "Gcc-patches" This expression is just discarded by add_stmt, so never reaches the middle-end. gcc/d/ChangeLog: * expr.cc (ExprVisitor::visit (AssertExp *)): Don't generate PREDICT_EXPR. --- gcc/d/expr.cc | 12 +++--------- 1 file changed, 3 insertions(+), 9 deletions(-) diff --git a/gcc/d/expr.cc b/gcc/d/expr.cc index 76c1e613e77..73e0abeaa43 100644 --- a/gcc/d/expr.cc +++ b/gcc/d/expr.cc @@ -2085,15 +2085,9 @@ public: } else { - /* Assert contracts are turned off, if the contract condition has no - side effects can still use it as a predicate for the optimizer. */ - if (TREE_SIDE_EFFECTS (arg)) - { - this->result_ = void_node; - return; - } - - assert_fail = build_predict_expr (PRED_NORETURN, NOT_TAKEN); + /* Assert contracts are turned off. */ + this->result_ = void_node; + return; } /* Build condition that we are asserting in this contract. */ From patchwork Fri Jul 30 11:01:10 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Iain Buclaw X-Patchwork-Id: 1511616 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=gcc.gnu.org (client-ip=2620:52:3:1:0:246e:9693:128c; helo=sourceware.org; envelope-from=gcc-patches-bounces+incoming=patchwork.ozlabs.org@gcc.gnu.org; receiver=) Authentication-Results: ozlabs.org; dkim=pass (1024-bit key; unprotected) header.d=gcc.gnu.org header.i=@gcc.gnu.org header.a=rsa-sha256 header.s=default header.b=vr/3v46J; dkim-atps=neutral Received: from sourceware.org (server2.sourceware.org [IPv6:2620:52:3:1:0:246e:9693:128c]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 4Gbl8j4nR9z9sXk for ; Fri, 30 Jul 2021 21:11:48 +1000 (AEST) Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id 80E383943405 for ; Fri, 30 Jul 2021 11:11:46 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 80E383943405 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gcc.gnu.org; s=default; t=1627643506; bh=uqoshzzndKabtd2H0OQhT6jWv+SPVBVNtESQ6b5i5Yg=; h=To:Subject:Date:In-Reply-To:References:List-Id:List-Unsubscribe: List-Archive:List-Post:List-Help:List-Subscribe:From:Reply-To: From; b=vr/3v46Jv3bIpXONr0i/MOkhqChtRRrFDlRb5NQm/ajzN91d15Jm1+WNv6AAbm9f+ h66+O7QnmOsW3ZghR862tJ/icCwuS+3XWznyYBaFZq6QznJd5Ya1GnvxXkBP7oPaCW vWfrVgx5MA4qOsGIOyTtTAjrJ1gNCQ7NRaTwkHBQ= X-Original-To: gcc-patches@gcc.gnu.org Delivered-To: gcc-patches@gcc.gnu.org Received: from mout-p-102.mailbox.org (mout-p-102.mailbox.org [IPv6:2001:67c:2050::465:102]) by sourceware.org (Postfix) with ESMTPS id 318EC393D03A for ; Fri, 30 Jul 2021 11:01:38 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.1 sourceware.org 318EC393D03A Received: from smtp2.mailbox.org (smtp2.mailbox.org [80.241.60.241]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange ECDHE (P-384) server-signature RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) by mout-p-102.mailbox.org (Postfix) with ESMTPS id 4Gbkwx2C1vzQk3S; Fri, 30 Jul 2021 13:01:37 +0200 (CEST) X-Virus-Scanned: amavisd-new at heinlein-support.de Received: from smtp2.mailbox.org ([80.241.60.241]) by spamfilter05.heinlein-hosting.de (spamfilter05.heinlein-hosting.de [80.241.56.123]) (amavisd-new, port 10030) with ESMTP id udrrVB6OmipW; Fri, 30 Jul 2021 13:01:30 +0200 (CEST) To: gcc-patches@gcc.gnu.org Subject: [committed 11/12] d: Always layout initializer for the m_RTInfo field in TypeInfo_Class Date: Fri, 30 Jul 2021 13:01:10 +0200 Message-Id: <20210730110111.569140-11-ibuclaw@gdcproject.org> In-Reply-To: <20210730110111.569140-1-ibuclaw@gdcproject.org> References: <20210730110111.569140-1-ibuclaw@gdcproject.org> MIME-Version: 1.0 X-Rspamd-Queue-Id: 7B473182B X-Rspamd-UID: e602ea X-Spam-Status: No, score=-15.7 required=5.0 tests=BAYES_00, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, DKIM_VALID_EF, GIT_PATCH_0, RCVD_IN_DNSWL_LOW, SPF_HELO_NONE, SPF_PASS, TXREP autolearn=ham autolearn_force=no version=3.4.4 X-Spam-Checker-Version: SpamAssassin 3.4.4 (2020-01-24) on server2.sourceware.org X-BeenThere: gcc-patches@gcc.gnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Gcc-patches mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-Patchwork-Original-From: Iain Buclaw via Gcc-patches From: Iain Buclaw Reply-To: Iain Buclaw Errors-To: gcc-patches-bounces+incoming=patchwork.ozlabs.org@gcc.gnu.org Sender: "Gcc-patches" Makes it explicit that the default value is set to NULL. gcc/d/ChangeLog: * typeinfo.cc (TypeInfoVisitor::visit (TypeInfoClassDeclaration *)): Always layout initializer for the m_RTInfo field. --- gcc/d/typeinfo.cc | 2 ++ 1 file changed, 2 insertions(+) diff --git a/gcc/d/typeinfo.cc b/gcc/d/typeinfo.cc index c9126f4c6b5..978c73e65f6 100644 --- a/gcc/d/typeinfo.cc +++ b/gcc/d/typeinfo.cc @@ -934,6 +934,8 @@ public: this->layout_field (build_expr (cd->getRTInfo, true)); else if (!(flags & ClassFlags::noPointers)) this->layout_field (size_one_node); + else + this->layout_field (null_pointer_node); } else { From patchwork Fri Jul 30 11:01:11 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Iain Buclaw X-Patchwork-Id: 1511617 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=gcc.gnu.org (client-ip=8.43.85.97; helo=sourceware.org; envelope-from=gcc-patches-bounces+incoming=patchwork.ozlabs.org@gcc.gnu.org; receiver=) Authentication-Results: ozlabs.org; dkim=pass (1024-bit key; unprotected) header.d=gcc.gnu.org header.i=@gcc.gnu.org header.a=rsa-sha256 header.s=default header.b=BNW49siF; dkim-atps=neutral Received: from sourceware.org (server2.sourceware.org [8.43.85.97]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 4GblBG675hz9sXk for ; Fri, 30 Jul 2021 21:13:10 +1000 (AEST) Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id 90FFC393F826 for ; Fri, 30 Jul 2021 11:13:08 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 90FFC393F826 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gcc.gnu.org; s=default; t=1627643588; bh=79WtGSLOvKH+enLDWktF87D7afC1fRvpQRu+f6eU03k=; h=To:Subject:Date:In-Reply-To:References:List-Id:List-Unsubscribe: List-Archive:List-Post:List-Help:List-Subscribe:From:Reply-To: From; b=BNW49siFUjD7hIdCFJsKBYIBfWH0pY28qF0FolCixIk20oDdyZ5i5jxFHoUheoKr9 y/PDOqBWhMwEKmzZ4miO6SQCSgdx3f/ix2+gYq3oIfJnm5iUsfvnfX8SG/oiJSeDY8 gD1Rux77xASy0SntzKeZwrpDdtfADU9yB5xcgt2U= X-Original-To: gcc-patches@gcc.gnu.org Delivered-To: gcc-patches@gcc.gnu.org Received: from mout-p-202.mailbox.org (mout-p-202.mailbox.org [80.241.56.172]) by sourceware.org (Postfix) with ESMTPS id 91036393D01A for ; Fri, 30 Jul 2021 11:01:39 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.1 sourceware.org 91036393D01A Received: from smtp2.mailbox.org (smtp2.mailbox.org [IPv6:2001:67c:2050:105:465:1:2:0]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange ECDHE (P-384) server-signature RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) by mout-p-202.mailbox.org (Postfix) with ESMTPS id 4Gbkwy4cnnzQk29; Fri, 30 Jul 2021 13:01:38 +0200 (CEST) X-Virus-Scanned: amavisd-new at heinlein-support.de Received: from smtp2.mailbox.org ([80.241.60.241]) by spamfilter05.heinlein-hosting.de (spamfilter05.heinlein-hosting.de [80.241.56.123]) (amavisd-new, port 10030) with ESMTP id osxg6eU2vSBE; Fri, 30 Jul 2021 13:01:32 +0200 (CEST) To: gcc-patches@gcc.gnu.org Subject: [committed 12/12] d: Remove dead code from binary_op. Date: Fri, 30 Jul 2021 13:01:11 +0200 Message-Id: <20210730110111.569140-12-ibuclaw@gdcproject.org> In-Reply-To: <20210730110111.569140-1-ibuclaw@gdcproject.org> References: <20210730110111.569140-1-ibuclaw@gdcproject.org> MIME-Version: 1.0 X-Rspamd-Queue-Id: E483E1847 X-Rspamd-UID: 0842b0 X-Spam-Status: No, score=-15.7 required=5.0 tests=BAYES_00, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, DKIM_VALID_EF, GIT_PATCH_0, RCVD_IN_DNSWL_LOW, SPF_HELO_NONE, SPF_PASS, TXREP autolearn=ham autolearn_force=no version=3.4.4 X-Spam-Checker-Version: SpamAssassin 3.4.4 (2020-01-24) on server2.sourceware.org X-BeenThere: gcc-patches@gcc.gnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Gcc-patches mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-Patchwork-Original-From: Iain Buclaw via Gcc-patches From: Iain Buclaw Reply-To: Iain Buclaw Errors-To: gcc-patches-bounces+incoming=patchwork.ozlabs.org@gcc.gnu.org Sender: "Gcc-patches" The front-end ensures that both sides have been casted to the same type before being given to the lowering pass. gcc/d/ChangeLog: * expr.cc (binary_op): Remove dead code. --- gcc/d/expr.cc | 8 -------- 1 file changed, 8 deletions(-) diff --git a/gcc/d/expr.cc b/gcc/d/expr.cc index 73e0abeaa43..e293cf2a4cd 100644 --- a/gcc/d/expr.cc +++ b/gcc/d/expr.cc @@ -101,8 +101,6 @@ binary_op (tree_code code, tree type, tree arg0, tree arg1) tree t1 = TREE_TYPE (arg1); tree ret = NULL_TREE; - bool unsignedp = TYPE_UNSIGNED (t0) || TYPE_UNSIGNED (t1); - /* Deal with float mod expressions immediately. */ if (code == FLOAT_MOD_EXPR) return build_float_modulus (type, arg0, arg1); @@ -130,12 +128,6 @@ binary_op (tree_code code, tree type, tree arg0, tree arg1) else ret = fold_build2 (POINTER_DIFF_EXPR, ptrtype, arg0, arg1); } - else if (INTEGRAL_TYPE_P (type) && (TYPE_UNSIGNED (type) != unsignedp)) - { - tree inttype = (unsignedp) - ? d_unsigned_type (type) : d_signed_type (type); - ret = fold_build2 (code, inttype, arg0, arg1); - } else { /* If the operation needs excess precision. */