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 3721D3AA8896 for ; Fri, 27 May 2022 15:58:24 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.1 sourceware.org 3721D3AA8896 Received: from mail-qv1-f70.google.com (mail-qv1-f70.google.com [209.85.219.70]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-644-K4PsLXUaPS2cXqq8ub4W7g-1; Fri, 27 May 2022 11:58:22 -0400 X-MC-Unique: K4PsLXUaPS2cXqq8ub4W7g-1 Received: by mail-qv1-f70.google.com with SMTP id j2-20020a0cfd42000000b0045ad9cba5deso3838617qvs.5 for ; Fri, 27 May 2022 08:58:22 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:message-id:date:mime-version:user-agent:subject :content-language:to:references:from:in-reply-to :content-transfer-encoding; bh=rX1XnKYn13KY+oJLczmj4am8H8kEWEcYSrlRThn2P1U=; b=ZAPTtd/Zac30rMMLWulHMRbqPNqvowqQBcwNSlHuNVN0RL0NI3YcWRihsrXIvZv1uA gfivS3GynW8X4mIs+VAnyJoBqrlW9z4Wlo3gez3bwzoyb+kZNaGjRNnrv5PuALChDoiN ZmDUScGvTlO5KPgePGw+o7+VgBQuRClJV9C6XUKVG67aAfjZAe47q3Pa1eZ9NsyQ/WZf B+hPYQJhYQXn+rNH3paujlnenziY3jzQUmVFChsZlviET4Nl7/68HW7taWKDoV6trAaW +PeKbFplac5AiONgxP0Re3wMeUqSrapOmw8HiDxpd98s2JEhchXWZbwyDBi53EUJQCVL YOWA== X-Gm-Message-State: AOAM533rprE9J49SDayajDkTcq4IZSsVSFTCBEfSAXnklkkOfww5FK+a hin4BXUxNB80omBxf0rYAYTRiVD9aKKRNQX+PWQqoPAq9/9Yo1ErVURBSDlGQP/D2LM1DGrlZOh bDMLdCNpLmH/Vtf7Zmg== X-Received: by 2002:a05:620a:4553:b0:6a0:5280:defd with SMTP id u19-20020a05620a455300b006a05280defdmr28481760qkp.165.1653667101632; Fri, 27 May 2022 08:58:21 -0700 (PDT) X-Google-Smtp-Source: ABdhPJwVqdHK46ahz6SYbFs2HA4E5+HTovNUw+gKApTD8M7tVDWk00m1eDp6vJzBT4UXntT3ZuKdEQ== X-Received: by 2002:a05:620a:4553:b0:6a0:5280:defd with SMTP id u19-20020a05620a455300b006a05280defdmr28481740qkp.165.1653667101299; Fri, 27 May 2022 08:58:21 -0700 (PDT) Received: from [192.168.1.100] (130-44-159-43.s15913.c3-0.arl-cbr1.sbo-arl.ma.cable.rcncustomer.com. [130.44.159.43]) by smtp.gmail.com with ESMTPSA id m9-20020a05620a214900b006a5bc8e956esm2186914qkm.133.2022.05.27.08.58.19 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Fri, 27 May 2022 08:58:20 -0700 (PDT) Message-ID: <7e8deb63-36c5-65c3-ef2c-17544ad5bbc5@redhat.com> Date: Fri, 27 May 2022 11:58:18 -0400 MIME-Version: 1.0 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:91.0) Gecko/20100101 Thunderbird/91.9.1 Subject: Re: [PATCH] c++: Fix ICE with -Wmismatched-tags [PR105725] To: Marek Polacek , GCC Patches References: <20220527154647.39582-1-polacek@redhat.com> From: Jason Merrill In-Reply-To: <20220527154647.39582-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.7 required=5.0 tests=BAYES_00, DKIMWL_WL_HIGH, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, DKIM_VALID_EF, GIT_PATCH_0, NICE_REPLY_A, RCVD_IN_DNSWL_NONE, 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.29 Precedence: list List-Id: Gcc-patches mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 27 May 2022 15:58:25 -0000 On 5/27/22 11:46, Marek Polacek wrote: > Here we ICE with -Wmismatched-tags on something like > > template > bool B>>; > > Specifically, the "class T::foo" bit. There, class_decl_loc_t::add gets > a TYPENAME_TYPE as TYPE, rather than a class/union type, so checking > TYPE_BEING_DEFINED will crash. I think it's OK to allow a TYPENAME_TYPE to > slip into that function; we just shouldn't consider the 'class' tag redundant > (which works as a 'typename'). In fact, every other compiler *requires* it. > > Bootstrapped/regtested on x86_64-pc-linux-gnu, ok for trunk? OK. > PR c++/105725 > > gcc/cp/ChangeLog: > > * parser.cc (class_decl_loc_t::add): Check CLASS_TYPE_P. > > gcc/testsuite/ChangeLog: > > * g++.dg/warn/Wmismatched-tags-10.C: New test. > --- > gcc/cp/parser.cc | 5 +++-- > gcc/testsuite/g++.dg/warn/Wmismatched-tags-10.C | 10 ++++++++++ > 2 files changed, 13 insertions(+), 2 deletions(-) > create mode 100644 gcc/testsuite/g++.dg/warn/Wmismatched-tags-10.C > > diff --git a/gcc/cp/parser.cc b/gcc/cp/parser.cc > index 4b9859543ed..9a9f859974a 100644 > --- a/gcc/cp/parser.cc > +++ b/gcc/cp/parser.cc > @@ -33666,7 +33666,8 @@ class_decl_loc_t::add (cp_parser *parser, location_t key_loc, > bool key_redundant = (!def_p && !decl_p > && (decl == type_decl > || TREE_CODE (decl) == TEMPLATE_DECL > - || TYPE_BEING_DEFINED (type))); > + || (CLASS_TYPE_P (type) > + && TYPE_BEING_DEFINED (type)))); > > if (key_redundant > && class_key != class_type > @@ -33704,7 +33705,7 @@ class_decl_loc_t::add (cp_parser *parser, location_t key_loc, > } > else > { > - /* TYPE was previously defined in some unknown precompiled hdeader. > + /* TYPE was previously defined in some unknown precompiled header. > Simply add a record of its definition at an unknown location and > proceed below to add a reference to it at the current location. > (Declarations in precompiled headers that are not definitions > diff --git a/gcc/testsuite/g++.dg/warn/Wmismatched-tags-10.C b/gcc/testsuite/g++.dg/warn/Wmismatched-tags-10.C > new file mode 100644 > index 00000000000..d7e10743bb4 > --- /dev/null > +++ b/gcc/testsuite/g++.dg/warn/Wmismatched-tags-10.C > @@ -0,0 +1,10 @@ > +// PR c++/105725 > +// { dg-do compile { target c++14 } } > +// { dg-options "-Wall -Wmismatched-tags" } > + > +template struct enable_if; > +template using enable_if_t = typename enable_if::type; > +template bool is_class_v; > +template bool B; > +template > +bool B>>; > > base-commit: de57440858591a88e8fd7ba2505ca54546c86021