From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mail-oo1-xc2b.google.com (mail-oo1-xc2b.google.com [IPv6:2607:f8b0:4864:20::c2b]) by sourceware.org (Postfix) with ESMTPS id 2C4EA3857BAD for ; Wed, 8 Jun 2022 08:13:43 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.1 sourceware.org 2C4EA3857BAD Received: by mail-oo1-xc2b.google.com with SMTP id f2-20020a4a8f42000000b0035e74942d42so3782343ool.13 for ; Wed, 08 Jun 2022 01:13:43 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc; bh=gGEfjcGtHabyNWdUGRYlIQ4MCFdE9RyScXCroNWeSEs=; b=Fu/GacAmoy/8kwCXnL4DOPdhQubNJIdLEok84wZGbVUuhhOELnLJSRK2IFgQ78MzOZ YjMv30XlmE5lxeCsX2w67NZgqEZgULbr9kYb8d8LP3hwUMFHfZHBbf1Kx6Tbg8lJDib3 qcdfgHp2pwmGt5PZ6hHe0t/KilHAfYwiaCIWKYkP9YrPf7dBmBsZlUn4eE162W4hY80m qbpTsrsrQ2m1L/+FV/T8dhaQ800U3hjBJ+69CP1YwG52JvIBSp6neGuEcCVwIJ5nTLmQ DvQ8PBIIYZne1ITac5AJpLQ6bQz8rdnMwrrRxA1t35uBWupl4ic5WLMCESE0pIy1QZm1 SIyg== X-Gm-Message-State: AOAM533gtC6BxJUGvWOy+nBbcZzK+jk/Lj/m0TfxugR7mKqz1ABuDPNX lw2vRw0xLmZ8xLa6FcbZCXB3QEbar942LEd+E81edJgfxnE= X-Google-Smtp-Source: ABdhPJxuXtPUOFYObLstGAMYT85ki8bWohehNTZiIQQ+4JjpNOh/g/+95/nAYMZaQqZ35DypWToFj0C77G5vppxh6C8= X-Received: by 2002:a4a:e787:0:b0:41b:7367:3587 with SMTP id x7-20020a4ae787000000b0041b73673587mr7366872oov.11.1654676022360; Wed, 08 Jun 2022 01:13:42 -0700 (PDT) MIME-Version: 1.0 References: <875a5f84da00d9ade01a444a4ead4b5d4dfd9c58.camel@xry111.site> In-Reply-To: <875a5f84da00d9ade01a444a4ead4b5d4dfd9c58.camel@xry111.site> From: Zopolis0 Date: Wed, 8 Jun 2022 18:13:31 +1000 Message-ID: Subject: Re: Incorrect replacement of TYPE_METHODS with TYPE_FIELDS causing segfault. To: Xi Ruoyao Cc: gcc-help X-Spam-Status: No, score=-0.5 required=5.0 tests=BAYES_00, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, DKIM_VALID_EF, FREEMAIL_FROM, HTML_MESSAGE, KAM_LOTSOFHASH, RCVD_IN_DNSWL_NONE, SPF_HELO_NONE, SPF_PASS, TXREP, T_SCC_BODY_TEXT_LINE, WEIRD_PORT autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on server2.sourceware.org Content-Type: text/plain; charset="UTF-8" X-Content-Filtered-By: Mailman/MimeDel 2.1.29 X-BeenThere: gcc-help@gcc.gnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Gcc-help mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 08 Jun 2022 08:13:46 -0000 Do I need the TREE_CODE there? Would TREE_TYPE (fld)) == METHOD_TYPE not work? On Wed, Jun 8, 2022 at 5:02 PM Xi Ruoyao wrote: > On Wed, 2022-06-08 at 14:47 +1000, Zopolis0 via Gcc-help wrote: > > /* snip */ > > > java/lang/Object.java: internal compiler error: tree check: expected > > function_decl, have field_decl in layout_class_method, at > java/class.cc:2627 > > > > I believe that this error is due to the following incorrect code at line > > 2589 at gcc/java/class.cc: > > for (tree method_decl = TYPE_FIELDS (this_class); > > > > Before it was removed, this line was: > > for (method_decl = TYPE_METHODS (this_class); > > > > But I have since modified it ( > > > https://github.com/Zopolis4/gcj/commit/1f38bc896a704290ca0b742c60c60a88d5e1fb07#diff-bf49cdc948b20b9f25afd3fbb36922a10e979a55ff9600b3b51d0ec54175b752L2592 > ) > > in accordance with 5aaa8fb40681ee66282d73dab8c8eccbf5ee0518 > > > > Given that this was incorrect, what would be the correct way to replace > > this instance of TYPE_METHODS? Were all my replacements of TYPE_METHODS > in > > gcc/java/class.cc wrong? > > 5aaa8fb is not a simple replacement. For example: > > /* If there are user-defined methods, they are deemed non-trivial. */ > - for (tmp = TYPE_METHODS (type); tmp; tmp = TREE_CHAIN (tmp)) > - if (!DECL_ARTIFICIAL (tmp)) > + for (tree fld = TYPE_FIELDS (type); fld; fld = DECL_CHAIN (fld)) > + if (TREE_CODE (TREE_TYPE (fld)) == METHOD_TYPE && !DECL_ARTIFICIAL > (fld)) > ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ > return true; > > I think you need to check if the field is really a method like this. > -- > Xi Ruoyao > School of Aerospace Science and Technology, Xidian University >