From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.133.124]) by sourceware.org (Postfix) with ESMTPS id 56E193858D33 for ; Thu, 18 Jan 2024 04:54:55 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 56E193858D33 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 56E193858D33 Authentication-Results: server2.sourceware.org; arc=none smtp.remote-ip=170.10.133.124 ARC-Seal: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1705553696; cv=none; b=p5tWctOFQZ9bRkNQFVo03wTgrDgJAjT3DWNURVz7lX/hCHB4HaYrovR9JGT6ZLJwYSqHzrxyOQqvL9lJnLuLqAIuG1GsJ1/AiGTmKggB3RXe8JdUH/Ty+MfEMUN4hhdXNJQvzDc1Jpo0M/9nsb2wQwJ5LrL+GiDY7X+ET1BT8mc= ARC-Message-Signature: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1705553696; c=relaxed/simple; bh=qMa+/Qumr/dJ194CIKVjhUcvekeHSWITCIzge67+cBQ=; h=DKIM-Signature:Message-ID:Date:MIME-Version:Subject:To:From; b=U0xL68tzXM8VSKTUBXEul+t5Yt9lGGKhiPEa1L36KOYTvf6LVocLdFjSZ60/lwRqh4f1+Fpfh0Ny3uWzCGcSMCbV9CX0ne8GSCDyCShxsJjqAfzCdIzquQjUERACVHdSo8jYhnNRKXuArLtJbLiO18WTr0eKONT7p46PXkaIVeU= ARC-Authentication-Results: i=1; server2.sourceware.org DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1705553695; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=v1AAu+7a0AV83mbTBCVRAZRz0rGoAYL4vNqPTYEJ2LY=; b=BOdq3xe/WP9PKVgRPF5QQ4lVLMuIMsAjqpW405GtHTk4fvObjic8i+E7oWsXCUusMsb34c RRA7OdlJFFBlIT/Hm+sWL7Err/r1c+AucOGP3SEvsGZDSzzVVePnP0fRYCmUC9dECBYxqi eio0dt/c3BWoJ+NKhQ5zcCtO3g5my9Y= Received: from mail-qk1-f198.google.com (mail-qk1-f198.google.com [209.85.222.198]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-392-LkjPuLXgM-S53NYox9r9fw-1; Wed, 17 Jan 2024 23:54:53 -0500 X-MC-Unique: LkjPuLXgM-S53NYox9r9fw-1 Received: by mail-qk1-f198.google.com with SMTP id af79cd13be357-7837045adc4so256320585a.1 for ; Wed, 17 Jan 2024 20:54:53 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1705553692; x=1706158492; h=content-transfer-encoding:in-reply-to:from:references:to :content-language:subject:user-agent:mime-version:date:message-id :x-gm-message-state:from:to:cc:subject:date:message-id:reply-to; bh=v1AAu+7a0AV83mbTBCVRAZRz0rGoAYL4vNqPTYEJ2LY=; b=mjUJIPdAtSQ7k1YJzs4jyUdph5i2REQN6OiKthc76UcAs2kZuUX0Fw5TJ1Pc7+8yHz qIdLG0UzqOeNCD/EK4gnJzkmyqgahoWRUFqhJN6QayXkYyScWd+3ELbwKDsIDjKbGIfW 4Z16f+nR8pswh1gwij27V+U4iNxkPX3F7VmzBgpQMYxA/LFaJsfiKn5HvYehN2d8xPXN oyiB8R+nWs6aA27nVlv+EulmiGWnkYjj9Mtvzy9WZIKlA2i6uPKd+qmKCRONm5GqnBh2 6lfnJKO/sbithE41ebWr2cW+vEuQHOJ2hWdaV8rJI36RUQ9D2vMptR72LzB8zBaljXAt F2MA== X-Gm-Message-State: AOJu0YyFUMZ7sZoai8/ErKI2+TW/bmU8tDpZcPXa8Ke2QN8ED1AtbWj+ Yn9ve8jQVgAW2H55Ediv7YTXBCqzHq6Dx87gndLzxBzrYffb6rFuyzjJmLdexDkRtSoqYoUM5as LQ5rbL3Mi83NjEFM4JlZ3GXDRgrY+RsakU6pd1oTXNc+Mu7QXMLWicBwJgK4OLVE= X-Received: by 2002:a05:620a:2491:b0:783:35f0:ad93 with SMTP id i17-20020a05620a249100b0078335f0ad93mr320256qkn.108.1705553691880; Wed, 17 Jan 2024 20:54:51 -0800 (PST) X-Google-Smtp-Source: AGHT+IFuV9SPEmhjq7mNrqQtPHqf0+J7LH7KyXozwzgwcNmg/ANvpV5VV/Zczj6EsQylRFLUuOBoEg== X-Received: by 2002:a05:620a:2491:b0:783:35f0:ad93 with SMTP id i17-20020a05620a249100b0078335f0ad93mr320252qkn.108.1705553691618; Wed, 17 Jan 2024 20:54:51 -0800 (PST) Received: from [192.168.1.146] (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 f14-20020a37ad0e000000b00781b8f4c89asm5013070qkm.43.2024.01.17.20.54.50 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Wed, 17 Jan 2024 20:54:51 -0800 (PST) Message-ID: <6ff234ab-44ef-4561-8443-e910e974ec9e@redhat.com> Date: Wed, 17 Jan 2024 23:54:50 -0500 MIME-Version: 1.0 User-Agent: Mozilla Thunderbird Subject: Re: [PATCH] c++: ICE when xobj is not the first parm [PR113389] To: Marek Polacek , GCC Patches References: <20240118011714.451164-1-polacek@redhat.com> From: Jason Merrill In-Reply-To: <20240118011714.451164-1-polacek@redhat.com> X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Language: en-US Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 7bit X-Spam-Status: No, score=-13.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,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: On 1/17/24 20:17, Marek Polacek wrote: > Bootstrapped/regtested on x86_64-pc-linux-gnu, ok for trunk? OK. > -- >8 -- > In grokdeclarator/cdk_function the comment says that the find_xobj_parm > lambda clears TREE_PURPOSE so that we can correctly detect an xobj that > is not the first parameter. That's all good, but we should also clear > the TREE_PURPOSE once we've given the error, otherwise we crash later in > check_default_argument because the 'this' TREE_PURPOSE lacks a type. > > PR c++/113389 > > gcc/cp/ChangeLog: > > * decl.cc (grokdeclarator) : Set TREE_PURPOSE to > NULL_TREE when emitting an error. > > gcc/testsuite/ChangeLog: > > * g++.dg/cpp23/explicit-obj-diagnostics10.C: New test. > --- > gcc/cp/decl.cc | 1 + > gcc/testsuite/g++.dg/cpp23/explicit-obj-diagnostics10.C | 8 ++++++++ > 2 files changed, 9 insertions(+) > create mode 100644 gcc/testsuite/g++.dg/cpp23/explicit-obj-diagnostics10.C > > diff --git a/gcc/cp/decl.cc b/gcc/cp/decl.cc > index 322e48dee2e..3e41fd4fa31 100644 > --- a/gcc/cp/decl.cc > +++ b/gcc/cp/decl.cc > @@ -13391,6 +13391,7 @@ grokdeclarator (const cp_declarator *declarator, > if (TREE_PURPOSE (parm) != this_identifier) > continue; > bad_xobj_parm_encountered = true; > + TREE_PURPOSE (parm) = NULL_TREE; > gcc_rich_location bad_xobj_parm > (DECL_SOURCE_LOCATION (TREE_VALUE (parm))); > error_at (&bad_xobj_parm, > diff --git a/gcc/testsuite/g++.dg/cpp23/explicit-obj-diagnostics10.C b/gcc/testsuite/g++.dg/cpp23/explicit-obj-diagnostics10.C > new file mode 100644 > index 00000000000..354823db166 > --- /dev/null > +++ b/gcc/testsuite/g++.dg/cpp23/explicit-obj-diagnostics10.C > @@ -0,0 +1,8 @@ > +// PR c++/113389 > +// { dg-do compile { target c++23 } } > + > +struct A { > + void foo(A, this A); // { dg-error "only the first parameter" } > + void qux(A, this A, // { dg-error "only the first parameter" } > + this A); // { dg-error "only the first parameter" } > +}; > > base-commit: 4a8430c8c3abb1c2c14274105b3a621100f251a2