From patchwork Tue Feb 21 20:48:43 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jason Merrill X-Patchwork-Id: 730773 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org 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 3vSXfj1NVgz9s78 for ; Wed, 22 Feb 2017 07:49:17 +1100 (AEDT) Authentication-Results: ozlabs.org; dkim=pass (1024-bit key; unprotected) header.d=gcc.gnu.org header.i=@gcc.gnu.org header.b="KWldkBq0"; dkim-atps=neutral DomainKey-Signature: a=rsa-sha1; c=nofws; d=gcc.gnu.org; h=list-id :list-unsubscribe:list-archive:list-post:list-help:sender :mime-version:from:date:message-id:subject:to:content-type; q= dns; s=default; b=nlAfMTzL83gJGjnlxVRDFXZlugXbDrX1nnu23xxZEMWWkU is2jQPT5lprepxWYEN+FjJQm8p7CawEehGXdC+FX3QJ+fQBSW78yhygg6mXuNKCd DM1FRp94LvBV8dH5frF626u4CR+KxuC2+tsv2Is4o+XxPHmMnjztwlEMHGaqs= 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 :mime-version:from:date:message-id:subject:to:content-type; s= default; bh=u3i9dbGJte6pOEV5Eu50+M9Ibls=; b=KWldkBq0cxVwR3Ct4qTa 5KSKCgR4pi3Vcmk/K7A9JrkhuJ3oPVBh/AJ4MwmGJOgtuzuXWW5UsmvhzMfs+dv6 MyJwjMfXtbQ7QwfJpvfIZ70K2SkBmGWrj4F2P0SNxOnhDhn9IHfxXm2Ca/mkgfVB u66ztCmhMVXNhtUQG1MQPks= Received: (qmail 119530 invoked by alias); 21 Feb 2017 20:49:06 -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 119520 invoked by uid 89); 21 Feb 2017 20:49:06 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-24.3 required=5.0 tests=AWL, BAYES_00, GIT_PATCH_0, GIT_PATCH_1, GIT_PATCH_2, GIT_PATCH_3, RCVD_IN_DNSWL_NONE, RCVD_IN_SORBS_SPAM autolearn=ham version=3.3.2 spammy= X-HELO: mail-ot0-f176.google.com Received: from mail-ot0-f176.google.com (HELO mail-ot0-f176.google.com) (74.125.82.176) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with ESMTP; Tue, 21 Feb 2017 20:49:05 +0000 Received: by mail-ot0-f176.google.com with SMTP id k4so76941277otc.0 for ; Tue, 21 Feb 2017 12:49:05 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:from:date:message-id:subject:to; bh=hKjm1WSSpjbhozQD+Cqz2rUJhXdI+vfft7uW9qzkvaA=; b=pHb3gNGFJ3oyBTMvup2Rgy8rXeYWSPjGTw5ZWKvvsMNqmei30ZnM8NguTIeycCFewU ZwFR/UYPgWZAn6u8tA+OHGDC53IC7JjQ082pU5Hrh4hU8IrMvybYc6cZkD4aX39gW++p t4xXENE1sX45x59/UDnfWVcWeZ4GmmyhtnWQChl1b1wiz+A9aU43Z0yLrmjG80vqWsQd qZwIwYH1tOgmuHcuUBaA+FzJ/ZPfqp9di2KgD33fI7KCL+AlQAJ6W9yxPv/nsJ4QGoOt Hb2GAhHAs9RSWgQSJOx/SHjEkVNZeE1zVe5a9R+qes9n2UHd4dd3azjUk6Eg8TCVTpP/ ts8g== X-Gm-Message-State: AMke39m443vrgfDvVwjgDkcLLHu6KmLZQQn8Eep3YkBFcXyFlDfQSl+8l1/ZtMFGNj4nakxulP7c4L2dEZZKXE23 X-Received: by 10.157.61.164 with SMTP id l33mr16958432otc.274.1487710143759; Tue, 21 Feb 2017 12:49:03 -0800 (PST) MIME-Version: 1.0 Received: by 10.182.5.4 with HTTP; Tue, 21 Feb 2017 12:48:43 -0800 (PST) From: Jason Merrill Date: Tue, 21 Feb 2017 12:48:43 -0800 Message-ID: Subject: C++ PATCH for c++/17729, c++/50308, deprecated warning issues To: gcc-patches List X-IsSubscribed: yes Both of these PRs are problems with the attribute deprecated warning in cases when there are no other declarations of the name in scope. [basic.def.odr] says that a function is odr-used if it is the unique result of name lookup, and also if it is selected by overload resolution; in 17729 that results in a duplicate warning, and in 50308 in a bogus warning because a different function is chosen by arg-dependent lookup. The solution for these is to avoid calling mark_used on the lookup when we know we're building a call. Tested x86_64-pc-linux-gnu, applying to trunk. commit b823b69a6cec77c5e96d0383b919a8da14b13a72 Author: Jason Merrill Date: Tue Feb 21 09:45:19 2017 -0800 PR c++/50308 - wrong deprecated warning with ADL PR c++/17729 - duplicate deprecated warning * semantics.c (finish_id_expression): Only call mark_used on a function if we aren't building a call. diff --git a/gcc/cp/semantics.c b/gcc/cp/semantics.c index 6a47476..6ba7c13 100644 --- a/gcc/cp/semantics.c +++ b/gcc/cp/semantics.c @@ -3743,7 +3743,15 @@ finish_id_expression (tree id_expression, if (TREE_CODE (first_fn) == TEMPLATE_DECL) first_fn = DECL_TEMPLATE_RESULT (first_fn); - if (!really_overloaded_fn (decl) + /* [basic.def.odr]: "A function whose name appears as a + potentially-evaluated expression is odr-used if it is the unique + lookup result". + + But only mark it if it's a complete postfix-expression; in a call, + ADL might select a different function, and we'll call mark_used in + build_over_call. */ + if (done + && !really_overloaded_fn (decl) && !mark_used (first_fn)) return error_mark_node; diff --git a/gcc/testsuite/c-c++-common/pr69558.c b/gcc/testsuite/c-c++-common/pr69558.c index 102d72c..4c6d498 100644 --- a/gcc/testsuite/c-c++-common/pr69558.c +++ b/gcc/testsuite/c-c++-common/pr69558.c @@ -16,4 +16,4 @@ __attribute__((deprecated)) void foo (void); /* { dg-bogus "declared here" "" { xfail { c++ } } } */ -C (foo) /* { dg-bogus "is deprecated" "" { xfail { c++ } } } */ +C (foo) /* { dg-bogus "is deprecated" } */ diff --git a/gcc/testsuite/g++.dg/warn/deprecated-12.C b/gcc/testsuite/g++.dg/warn/deprecated-12.C new file mode 100644 index 0000000..df5c76f --- /dev/null +++ b/gcc/testsuite/g++.dg/warn/deprecated-12.C @@ -0,0 +1,20 @@ +// PR c++/50308 + +void A( int ) __attribute__((deprecated)); + +namespace B { + + struct C {}; + + void A(C) {} + +} + +int main () +{ + B::C x; + + // ADL correctly identifies the non-deprecated B::A, but a warning about the + // global A is generated anyway + A( x ); // { dg-bogus "deprecated" } +}