From patchwork Wed Nov 22 03:37:29 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jason Merrill X-Patchwork-Id: 168090 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a05:612c:2b07:b0:403:3b70:6f57 with SMTP id io7csp1076434vqb; Tue, 21 Nov 2023 19:38:01 -0800 (PST) X-Google-Smtp-Source: AGHT+IGRfMtm9Q7DQcWvtVz7kcoR6b+xDrbY9ldBWQUlpMymeBNhN32absboKqCZFfb8F9BgOYUK X-Received: by 2002:a05:620a:910:b0:77a:2520:2793 with SMTP id v16-20020a05620a091000b0077a25202793mr1066875qkv.2.1700624281047; Tue, 21 Nov 2023 19:38:01 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1700624281; cv=pass; d=google.com; s=arc-20160816; b=XtpHPePlxKtBWZMgiUAKOrO8O1lMZIUgsleik8pla5Ss7Pn2TCJf4EoEyz7XDqigEN zPZLCbhDsEvulFuSQtNJP2f5UYH6Sh/SMXdBqoG0v4dZl6NHzGj9ouakhj+MWEu/4cLM AeqjShJRm1Z79zuCj4sTI+wffwxawA8A/SR9rA0d0jFcyE5J7BqufUixSzwFotcf7Voz Q+QpHddH7ztUolXQbr+kP+9crIKf2Q2RdwjM+5AoeOBz5UoTNudyaGq4b294+EjcOOny DV+P1ZApDdnve3z8J+rdhsD+Q31npFRHNlEB60+Mmt94l98pBE5baRWmTMuuIQhjU3Te 1Jdw== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=errors-to:list-subscribe:list-help:list-post:list-archive :list-unsubscribe:list-id:precedence:content-transfer-encoding :mime-version:message-id:date:subject:cc:to:from:dkim-signature :arc-filter:dmarc-filter:delivered-to; bh=Ws4SQnjDgmBbktuu5JVfWY+ya+Hi/7jMNZBNybJOAP0=; fh=28pTlpITb14AAGVQVeUuFzMdF3mky2UGZU03vGDjvDM=; b=WTQ+t4nEUpR/5A3kOmtNsJucy7V6WfL++LSgelqlwluyXbkRjTU5F013egJquAPnNu CZKFoskxuXwz68nrolaSSmX/coH5jrvWfa844WYpjmkU6FDqh3efzeYKRBWPTzZZhyHL c4NNB7FATNMvv/rzI/nj64xcdU1BP0i106GbsiJLJdhar598havTB1xNjKsnJS3MO4Ge 7C6M6XGtXb57wjveBZc5lIcxIA6rmu7cRljlQ4cUvRJHm4U09IPuTGude5PgBbWBzx3f fsqmtJQ/huXnJ4qSEKCqyGi/vUWE+BT5avq7YfRzTspAGbzPeVp7OXyMSi6fuBKnlG3s pusg== ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b=E8OEATsT; arc=pass (i=1); spf=pass (google.com: domain of gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org designates 8.43.85.97 as permitted sender) smtp.mailfrom="gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=redhat.com Received: from server2.sourceware.org (server2.sourceware.org. [8.43.85.97]) by mx.google.com with ESMTPS id d24-20020a05620a167800b0077d67573f46si198151qko.610.2023.11.21.19.38.00 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 21 Nov 2023 19:38:01 -0800 (PST) Received-SPF: pass (google.com: domain of gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org designates 8.43.85.97 as permitted sender) client-ip=8.43.85.97; Authentication-Results: mx.google.com; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b=E8OEATsT; arc=pass (i=1); spf=pass (google.com: domain of gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org designates 8.43.85.97 as permitted sender) smtp.mailfrom="gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=redhat.com Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id CC81C385840A for ; Wed, 22 Nov 2023 03:38:00 +0000 (GMT) X-Original-To: gcc-patches@gcc.gnu.org Delivered-To: gcc-patches@gcc.gnu.org Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.129.124]) by sourceware.org (Postfix) with ESMTPS id 4E6303858D33 for ; Wed, 22 Nov 2023 03:37:36 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 4E6303858D33 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 4E6303858D33 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=1700624257; cv=none; b=iyN0qQoYhDDIVSkb4EcIckolnk0sX13BeExi2wdeoXLCm/RGHqY0g96AM5OAVDqfh8w2SrUE4YzdQ2SUsdSBPb9TkHMORRvj6EDG4dh3H/A17TnRvc/6ubFR0x2iXT9Ourhs0nc0YY/2PPVft70CEzoXNfMb6a3MW7vgJs27ocs= ARC-Message-Signature: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1700624257; c=relaxed/simple; bh=HPYwtcua8I7F1aHFgLzzsBNGS/roNFVg9TbBVD4jLY0=; h=DKIM-Signature:From:To:Subject:Date:Message-Id:MIME-Version; b=Kg591n+eq89kRNqJp4NrgmWOUpzowtuVf2Zk9SESnnwAuGDlB4wtpS9w3cye/dehqMG/17WxcXnvnkLHva1/PGu7cKtwVcaVRmGvS0sbSADhr6J9PHGRf2UEj3qZrYJmg2r48tlYQjizXtUWZBzvsJ2Q5K+Ram/+zbX3QgXYVm4= ARC-Authentication-Results: i=1; server2.sourceware.org DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1700624255; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding; bh=Ws4SQnjDgmBbktuu5JVfWY+ya+Hi/7jMNZBNybJOAP0=; b=E8OEATsTLdjoLmZfJ1tRT8ct9DPaJHJXBhCnKUisn7C4ae+TcXf74sQ3xRr6TwdpkEoDIw NOYvtz71XU1mImNM+Yj6QJQsIEQJgPzRsoDFum+MxA8u8alrkcE2hVvcBvhhYR28PapidM fk8XeLpvoNPP5X1D8LuzLCmtIUs6s+A= Received: from mail-qv1-f72.google.com (mail-qv1-f72.google.com [209.85.219.72]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-45-T0ePEYfWMSakyIjqSiYXSA-1; Tue, 21 Nov 2023 22:37:33 -0500 X-MC-Unique: T0ePEYfWMSakyIjqSiYXSA-1 Received: by mail-qv1-f72.google.com with SMTP id 6a1803df08f44-679e650f9f0so23474756d6.3 for ; Tue, 21 Nov 2023 19:37:33 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1700624252; x=1701229052; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:x-gm-message-state:from:to:cc:subject:date:message-id :reply-to; bh=Ws4SQnjDgmBbktuu5JVfWY+ya+Hi/7jMNZBNybJOAP0=; b=fzSKny5rII3/63R1+jPcYOrM1UN7Kh3Bf56Q6teSSw0+8QoLs+qUS3mGA/To30N+Lx pt+z2+SW0qLOZir8gfeCRIuwHtzO5376F8nng11Fs0hq2cLDNWk3wIWv3t6P/VSu7+0E sGUdUunUTJJn4ftKsh0VK1lkTMxBH05v7oahq3xTiJIWCp6KiFHhIyPIZqN0/S06nWYV zwjzuVYnBhX/pClWtXiC2Ts3MDbukz4V3LZ1W/m9hepuPZ+Ae8RuyP02vUH2cjek4dnR d8ILDf0wZDKGn11XqeLYLcO49oNgkHKlvTi9Snaa2p+vvsMYMYCcdnEBrfaFHOcsNt6j D58A== X-Gm-Message-State: AOJu0YykvkZe7B36BrdawXeIlW+X2WCrzBOk1Ltskv41bT9OLFs2JI1g 0YR4cRpRB7lXNvtEhyv3Bqx1ZosS6RhOpRGMuEBAWdSQ5gGiAoxLIgYDEDTlFQ29GNWrdbIhn2t 218lym9zl4hZiElc7liLmlGNVNgiefK5Mob9Hvn8q013Ddy5lz7WchepFnjEO4JH4bUy9fSLVig == X-Received: by 2002:a05:6214:e48:b0:677:fbc3:5ac8 with SMTP id o8-20020a0562140e4800b00677fbc35ac8mr1132550qvc.60.1700624252411; Tue, 21 Nov 2023 19:37:32 -0800 (PST) X-Received: by 2002:a05:6214:e48:b0:677:fbc3:5ac8 with SMTP id o8-20020a0562140e4800b00677fbc35ac8mr1132536qvc.60.1700624252029; Tue, 21 Nov 2023 19:37:32 -0800 (PST) Received: from jason.com (130-44-146-16.s12558.c3-0.arl-cbr1.sbo-arl.ma.cable.rcncustomer.com. [130.44.146.16]) by smtp.gmail.com with ESMTPSA id e15-20020ad442af000000b0065cfec43097sm4518802qvr.39.2023.11.21.19.37.31 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 21 Nov 2023 19:37:31 -0800 (PST) From: Jason Merrill To: gcc-patches@gcc.gnu.org Cc: waffl3x@protonmail.com Subject: [pushed] c++: start_preparsed_function tweak Date: Tue, 21 Nov 2023 22:37:29 -0500 Message-Id: <20231122033729.3335056-1-jason@redhat.com> X-Mailer: git-send-email 2.39.3 MIME-Version: 1.0 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com X-Spam-Status: No, score=-12.3 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_H4, RCVD_IN_MSPIKE_WL, SPF_HELO_NONE, SPF_NONE, 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 X-BeenThere: gcc-patches@gcc.gnu.org X-Mailman-Version: 2.1.30 Precedence: list List-Id: Gcc-patches mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1783233806014086846 X-GMAIL-MSGID: 1783233806014086846 Tested x86_64-pc-linux-gnu, applying to trunk. -- 8< -- In review of the deducing 'this' patch, it came up that the logic in start_preparsed_function around the ctype variable was convoluted, being set for non-static member functions and friends, but not for static member functions. Let's set it for any member function, and not rely on it to decide whether to set up 'this'. gcc/cp/ChangeLog: * decl.cc (start_preparsed_function): Clarify ctype logic. --- gcc/cp/decl.cc | 12 +++++------- 1 file changed, 5 insertions(+), 7 deletions(-) base-commit: 4649c079409ec6cb67cd2cca0df81877e53c78b4 diff --git a/gcc/cp/decl.cc b/gcc/cp/decl.cc index e6f75d771e0..e7701afdefd 100644 --- a/gcc/cp/decl.cc +++ b/gcc/cp/decl.cc @@ -17392,8 +17392,8 @@ start_preparsed_function (tree decl1, tree attrs, int flags) gcc_assert (TREE_CHAIN (void_list_node) == NULL_TREE); tree fntype = TREE_TYPE (decl1); - if (TREE_CODE (fntype) == METHOD_TYPE) - ctype = TYPE_METHOD_BASETYPE (fntype); + if (DECL_CLASS_SCOPE_P (decl1)) + ctype = DECL_CONTEXT (decl1); else { ctype = DECL_FRIEND_CONTEXT (decl1); @@ -17424,15 +17424,13 @@ start_preparsed_function (tree decl1, tree attrs, int flags) /* Sometimes we don't notice that a function is a static member, and build a METHOD_TYPE for it. Fix that up now. */ - gcc_assert (!(ctype != NULL_TREE && DECL_STATIC_FUNCTION_P (decl1) + gcc_assert (!(DECL_STATIC_FUNCTION_P (decl1) && TREE_CODE (TREE_TYPE (decl1)) == METHOD_TYPE)); /* Set up current_class_type, and enter the scope of the class, if appropriate. */ if (ctype) push_nested_class (ctype); - else if (DECL_STATIC_FUNCTION_P (decl1)) - push_nested_class (DECL_CONTEXT (decl1)); /* Now that we have entered the scope of the class, we must restore the bindings for any template parameters surrounding DECL1, if it @@ -17469,7 +17467,7 @@ start_preparsed_function (tree decl1, tree attrs, int flags) tree newdecl1 = push_template_decl (decl1, doing_friend); if (newdecl1 == error_mark_node) { - if (ctype || DECL_STATIC_FUNCTION_P (decl1)) + if (ctype) pop_nested_class (); return false; } @@ -17621,7 +17619,7 @@ start_preparsed_function (tree decl1, tree attrs, int flags) /* Start the statement-tree, start the tree now. */ DECL_SAVED_TREE (decl1) = push_stmt_list (); - if (ctype && !doing_friend && !DECL_STATIC_FUNCTION_P (decl1)) + if (DECL_NONSTATIC_MEMBER_FUNCTION_P (decl1)) { /* We know that this was set up by `grokclassfn'. We do not wait until `store_parm_decls', since evil parse errors may