From patchwork Wed Nov 27 23:43:00 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jakub Jelinek X-Patchwork-Id: 1201837 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=209.132.180.131; helo=sourceware.org; envelope-from=gcc-patches-return-514745-incoming=patchwork.ozlabs.org@gcc.gnu.org; receiver=) Authentication-Results: ozlabs.org; dmarc=fail (p=none dis=none) header.from=redhat.com Authentication-Results: ozlabs.org; dkim=pass (1024-bit key; unprotected) header.d=gcc.gnu.org header.i=@gcc.gnu.org header.b="ci5QvdHX"; dkim=fail reason="signature verification failed" (1024-bit key; unprotected) header.d=redhat.com header.i=@redhat.com header.b="EtA4aNC8"; dkim-atps=neutral Received: from sourceware.org (server1.sourceware.org [209.132.180.131]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 47Nclp3sgRz9sSF for ; Thu, 28 Nov 2019 10:43:17 +1100 (AEDT) DomainKey-Signature: a=rsa-sha1; c=nofws; d=gcc.gnu.org; h=list-id :list-unsubscribe:list-archive:list-post:list-help:sender:date :from:to:cc:subject:message-id:reply-to:mime-version :content-type:content-transfer-encoding; q=dns; s=default; b=JnS CIK3W5XOnguNrfUEyYDuqpJA9C/tujrun0LUDr2CzScDPSHwe9D8KG16JVJx4gi1 Jb3fGxyI6n0cyQ4JglBwya2nkqxQ8eBRNRp1t/hYpuaTQq+1YgP/42QZ+yF1E9Uo 12ocvt0Sld7oT3Ao43grOcEW2Zc1TXJwdlZrRfMo= DKIM-Signature: v=1; a=rsa-sha1; c=relaxed; d=gcc.gnu.org; h=list-id :list-unsubscribe:list-archive:list-post:list-help:sender:date :from:to:cc:subject:message-id:reply-to:mime-version :content-type:content-transfer-encoding; s=default; bh=pyYTFO7Jr SCyJFczNB29/Lr0BwA=; b=ci5QvdHXV905FaZ7tO2yY9kO889ZlOMMx9iJPZvJP xjcGNftG05FFp7ocTG22dYhgGvqiTYXcCj4cvhwPj23z+G1HUl4wUPcHx3qWVLt+ lkF8+crEBHAB89Zyem4kXInDYQGGkr7AEftrqS2keeQgBFCiI/ca5m3Wi1Rkqh1G kg= Received: (qmail 71030 invoked by alias); 27 Nov 2019 23:43:10 -0000 Mailing-List: contact gcc-patches-help@gcc.gnu.org; run by ezmlm Precedence: bulk List-Id: List-Unsubscribe: List-Archive: List-Post: List-Help: Sender: gcc-patches-owner@gcc.gnu.org Delivered-To: mailing list gcc-patches@gcc.gnu.org Received: (qmail 71021 invoked by uid 89); 27 Nov 2019 23:43:10 -0000 Authentication-Results: sourceware.org; auth=none X-Spam-SWARE-Status: No, score=-7.8 required=5.0 tests=AWL, BAYES_00, GIT_PATCH_2, GIT_PATCH_3 autolearn=ham version=3.3.1 spammy=HX-Languages-Length:2328, pointless X-HELO: us-smtp-delivery-1.mimecast.com Received: from us-smtp-1.mimecast.com (HELO us-smtp-delivery-1.mimecast.com) (205.139.110.61) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with ESMTP; Wed, 27 Nov 2019 23:43:09 +0000 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1574898188; h=from:from:reply-to: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=bC5+JvIGfRFyAhLgBqKZVe4E+cOU9id0pPkz59bXrKU=; b=EtA4aNC86YyOc0q4ZjuzNUb6Ah6WrDoECEp9jN5yYdgGdqTMKIijbI+tDeqRp6BCNNzvQS xdrv3RCXeF3fhySx+Lj7jmxsB7eX6G7Vp4dDxcQSW8p8eT/O8VZzYl6aLS2Z85wMm9UnQ7 QsyBKwirpyAxzvEngxUCkpGHf+ZA15A= Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-124-skApXv2bP0iunbSOiwxMLg-1; Wed, 27 Nov 2019 18:43:04 -0500 Received: from smtp.corp.redhat.com (int-mx02.intmail.prod.int.phx2.redhat.com [10.5.11.12]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 02DA81800D41 for ; Wed, 27 Nov 2019 23:43:04 +0000 (UTC) Received: from tucnak.zalov.cz (ovpn-117-59.ams2.redhat.com [10.36.117.59]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 8E29160BE2; Wed, 27 Nov 2019 23:43:03 +0000 (UTC) Received: from tucnak.zalov.cz (localhost [127.0.0.1]) by tucnak.zalov.cz (8.15.2/8.15.2) with ESMTP id xARNh1q5011179; Thu, 28 Nov 2019 00:43:01 +0100 Received: (from jakub@localhost) by tucnak.zalov.cz (8.15.2/8.15.2/Submit) id xARNh0Aa011178; Thu, 28 Nov 2019 00:43:00 +0100 Date: Thu, 28 Nov 2019 00:43:00 +0100 From: Jakub Jelinek To: Jason Merrill Cc: gcc-patches@gcc.gnu.org Subject: [C++ PATCH] Avoid weird warning about pure virtual inline being used but not defined (PR c++/92695) Message-ID: <20191127234300.GE10088@tucnak> Reply-To: Jakub Jelinek MIME-Version: 1.0 User-Agent: Mutt/1.11.3 (2019-02-01) X-Mimecast-Spam-Score: 0 Content-Disposition: inline X-IsSubscribed: yes Hi! While working on the PR92695 bug, I've noticed a weird warning, when the testcase contained (pointless, but not invalid) constexpr specifier on pure virtual function. constexpr implies DECL_DECLARED_INLINE_P and we would note_vague_linkage_fn and later complain that the inline function wasn't ever defined. As can be seen in the testcase, for inline pure virtual we warn the same. The specifiers don't make much sense, but Jonathan nor I could find anything that would say that inline pure virtual or constexpr pure virtual is invalid. clang++ accepts those without warnings too. Fixed thusly, bootstrapped/regtested on x86_64-linux and i686-linux, ok for trunk? 2019-11-27 Jakub Jelinek PR c++/92695 * decl2.c (mark_used): Don't call note_vague_linkage_fn for pure virtual functions, even if they are declared inline. * g++.dg/warn/inline3.C: New test. Jakub --- gcc/cp/decl2.c.jj 2019-11-12 09:09:33.658814862 +0100 +++ gcc/cp/decl2.c 2019-11-27 18:26:53.698018564 +0100 @@ -5596,8 +5596,11 @@ mark_used (tree decl, tsubst_flags_t com vec_safe_push (no_linkage_decls, decl); } - if (TREE_CODE (decl) == FUNCTION_DECL && DECL_DECLARED_INLINE_P (decl) - && !DECL_INITIAL (decl) && !DECL_ARTIFICIAL (decl)) + if (TREE_CODE (decl) == FUNCTION_DECL + && DECL_DECLARED_INLINE_P (decl) + && !DECL_INITIAL (decl) + && !DECL_ARTIFICIAL (decl) + && !DECL_PURE_VIRTUAL_P (decl)) /* Remember it, so we can check it was defined. */ note_vague_linkage_fn (decl); --- gcc/testsuite/g++.dg/warn/inline3.C.jj 2019-11-27 18:13:46.685074239 +0100 +++ gcc/testsuite/g++.dg/warn/inline3.C 2019-11-27 18:18:40.688577837 +0100 @@ -0,0 +1,20 @@ +struct S { + inline virtual void foo () = 0; // { dg-bogus "used but never defined" } +#if __cplusplus > 201703L + constexpr virtual void bar () = 0; // { dg-bogus "used but never defined" "" { target c++2a } } +#else + inline virtual void bar () = 0; // { dg-bogus "used but never defined" "" { target c++17_down } } +#endif + S () {} +}; +struct T : public S { + inline virtual void foo () {} +#if __cplusplus > 201703L + constexpr virtual void bar () {} +#else + inline virtual void bar () {} +#endif + T () {} +}; +T t; +void foo (S *s) { s->foo (); s->bar (); }