From patchwork Tue Aug 13 13:32:17 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jonathan Wakely X-Patchwork-Id: 1146365 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=pass (mailfrom) smtp.mailfrom=gcc.gnu.org (client-ip=209.132.180.131; helo=sourceware.org; envelope-from=gcc-patches-return-506818-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="OqGrCPng"; 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 467DCy0dnMz9sND for ; Tue, 13 Aug 2019 23:32:28 +1000 (AEST) 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:mime-version:content-type; q=dns; s=default; b=E1aAf5iRSMBoc3FreqzrYgC/b7lzh5QiaXcZTGSjZMfaRxTn7d KYMVcviVWQxH/qwHJr1h+gXXpHBm6m/av7/tuHYvESHykJNGwu4rJM296vrozb2R fIioEf1myHV1NknLrz+cPVcsNu6hBtnB5+Kx7gR4gaA7+cZdC4+mOb2+Y= 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:mime-version:content-type; s= default; bh=W7d6WbcZLQNOpkPuykOltKX9X10=; b=OqGrCPng8D/evYB0ZSGf LFcmtFYLsyWDk5nMf0FwjPP+utgBiCi+WWGvD85pjAaTgIGFtAA+yAiGgf9ZQJim YAsPA6rHpkjWyiScAeovSp8iynIruRbciveFAHDFH5ukGzCY6gGJgpOTjCAaDYGt nsexDWDJ045WDftHba6xW54= Received: (qmail 41829 invoked by alias); 13 Aug 2019 13:32:21 -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 41815 invoked by uid 89); 13 Aug 2019 13:32:20 -0000 Authentication-Results: sourceware.org; auth=none X-Spam-SWARE-Status: No, score=-16.3 required=5.0 tests=AWL, BAYES_00, GIT_PATCH_0, GIT_PATCH_1, GIT_PATCH_2, GIT_PATCH_3, SPF_HELO_PASS autolearn=ham version=3.3.1 spammy= X-HELO: mx1.redhat.com Received: from mx1.redhat.com (HELO mx1.redhat.com) (209.132.183.28) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with ESMTP; Tue, 13 Aug 2019 13:32:19 +0000 Received: from smtp.corp.redhat.com (int-mx07.intmail.prod.int.phx2.redhat.com [10.5.11.22]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 763B030FB8EC; Tue, 13 Aug 2019 13:32:18 +0000 (UTC) Received: from localhost (unknown [10.33.36.86]) by smtp.corp.redhat.com (Postfix) with ESMTP id 1F94110013A1; Tue, 13 Aug 2019 13:32:17 +0000 (UTC) Date: Tue, 13 Aug 2019 14:32:17 +0100 From: Jonathan Wakely To: gcc-patches@gcc.gnu.org Cc: Jason Merrill , Nathan Sidwell , David Malcolm Subject: [PATCH 1/2] PR c++/91436 fix C++ dialect for std::make_unique fix-it hint Message-ID: <20190813133217.GA11146@redhat.com> MIME-Version: 1.0 Content-Disposition: inline X-Clacks-Overhead: GNU Terry Pratchett User-Agent: Mutt/1.12.0 (2019-05-25) The std::make_unique function wasn't added until C++14, and neither was the std::complex_literals namespace. gcc/cp: PR c++/91436 * name-lookup.c (get_std_name_hint): Fix min_dialect field for complex_literals and make_unique entries. gcc/testsuite: PR c++/91436 * g++.dg/lookup/missing-std-include-5.C: Limit test to C++14 and up. * g++.dg/lookup/missing-std-include-6.C: Don't check make_unique in test that runs for C++11. Tested x86_64-linux. OK for trunk? commit b58e771fe21ae380200fdec00aa899d4b15b73d5 Author: Jonathan Wakely Date: Tue Aug 13 13:25:39 2019 +0100 PR c++/91436 fix C++ dialect for std::make_unique fix-it hint The std::make_unique function wasn't added until C++14, and neither was the std::complex_literals namespace. gcc/cp: PR c++/91436 * name-lookup.c (get_std_name_hint): Fix min_dialect field for complex_literals and make_unique entries. gcc/testsuite: PR c++/91436 * g++.dg/lookup/missing-std-include-5.C: Limit test to C++14 and up. * g++.dg/lookup/missing-std-include-6.C: Don't check make_unique in test that runs for C++11. diff --git a/gcc/cp/name-lookup.c b/gcc/cp/name-lookup.c index 9f278220df3..96b2d90540d 100644 --- a/gcc/cp/name-lookup.c +++ b/gcc/cp/name-lookup.c @@ -5557,7 +5557,7 @@ get_std_name_hint (const char *name) {"bitset", "", cxx11}, /* . */ {"complex", "", cxx98}, - {"complex_literals", "", cxx98}, + {"complex_literals", "", cxx14}, /* . */ {"condition_variable", "", cxx11}, {"condition_variable_any", "", cxx11}, @@ -5619,7 +5619,7 @@ get_std_name_hint (const char *name) {"multimap", "", cxx98}, /* . */ {"make_shared", "", cxx11}, - {"make_unique", "", cxx11}, + {"make_unique", "", cxx14}, {"shared_ptr", "", cxx11}, {"unique_ptr", "", cxx11}, {"weak_ptr", "", cxx11}, diff --git a/gcc/testsuite/g++.dg/lookup/missing-std-include-5.C b/gcc/testsuite/g++.dg/lookup/missing-std-include-5.C index fe880a6263b..3ec9abd9316 100644 --- a/gcc/testsuite/g++.dg/lookup/missing-std-include-5.C +++ b/gcc/testsuite/g++.dg/lookup/missing-std-include-5.C @@ -1,2 +1,3 @@ +// { dg-do compile { target c++14 } } using namespace std::complex_literals; // { dg-error "" } // { dg-message "#include " "" { target *-*-* } .-1 } diff --git a/gcc/testsuite/g++.dg/lookup/missing-std-include-6.C b/gcc/testsuite/g++.dg/lookup/missing-std-include-6.C index d9eeb4284e8..a8f27473e6d 100644 --- a/gcc/testsuite/g++.dg/lookup/missing-std-include-6.C +++ b/gcc/testsuite/g++.dg/lookup/missing-std-include-6.C @@ -11,15 +11,6 @@ void test_make_shared () // { dg-error "expected primary-expression before '\\)' token" "" { target *-*-* } .-3 } } -template -void test_make_unique () -{ - auto p = std::make_unique(); // { dg-error "'make_unique' is not a member of 'std'" } - // { dg-message "'#include '" "" { target *-*-* } .-1 } - // { dg-error "expected primary-expression before '>' token" "" { target *-*-* } .-2 } - // { dg-error "expected primary-expression before '\\)' token" "" { target *-*-* } .-3 } -} - std::shared_ptr test_shared_ptr; // { dg-error "'shared_ptr' in namespace 'std' does not name a template type" } // { dg-message "'#include '" "" { target *-*-* } .-1 } From patchwork Tue Aug 13 13:36:30 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jonathan Wakely X-Patchwork-Id: 1146368 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=pass (mailfrom) smtp.mailfrom=gcc.gnu.org (client-ip=209.132.180.131; helo=sourceware.org; envelope-from=gcc-patches-return-506819-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="Rcs9y3A2"; 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 467DJq0W1zz9sDQ for ; Tue, 13 Aug 2019 23:36:41 +1000 (AEST) 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:references:mime-version :content-type:in-reply-to; q=dns; s=default; b=m9Djqqa9B+De+IInj SCvDxPdvZW/29JxUi5BCf6JANjANoMKotR4jdNVpHXl5IxCfXABBwBApWIo/JMTR JFszj0Pj5sEnBvPt6ksHBYDD3Zf2tFITHQlsnUKlXjliapEfVd5r+/RjJ5LlL8ze VkAPaSjwCkpguACh67qdAJcBww= 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:references:mime-version :content-type:in-reply-to; s=default; bh=jrG0QtlOQd3dQyA+MXJkCr8 nQII=; b=Rcs9y3A2B9hoUvzuZ5x90wf1OFFvLFzckXH6dziDvoiuQalj4NtiBin c8tLPRoPmzEQmmZjxWh0xzB/6Uu5q8+/kmrEOoVz4U3NtAk/4YFqVDqTTzrEysGA U8prl5MJzIqQSzy6l+OfS5PXrl+FXmC1USYA7X2okcDwHqbSJTL4= Received: (qmail 119804 invoked by alias); 13 Aug 2019 13:36:34 -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 119495 invoked by uid 89); 13 Aug 2019 13:36:34 -0000 Authentication-Results: sourceware.org; auth=none X-Spam-SWARE-Status: No, score=-16.3 required=5.0 tests=AWL, BAYES_00, GIT_PATCH_0, GIT_PATCH_1, GIT_PATCH_2, GIT_PATCH_3, SPF_HELO_PASS autolearn=ham version=3.3.1 spammy= X-HELO: mx1.redhat.com Received: from mx1.redhat.com (HELO mx1.redhat.com) (209.132.183.28) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with ESMTP; Tue, 13 Aug 2019 13:36:32 +0000 Received: from smtp.corp.redhat.com (int-mx01.intmail.prod.int.phx2.redhat.com [10.5.11.11]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 68D408E59F; Tue, 13 Aug 2019 13:36:31 +0000 (UTC) Received: from localhost (unknown [10.33.36.86]) by smtp.corp.redhat.com (Postfix) with ESMTP id 0C70E7EF45; Tue, 13 Aug 2019 13:36:30 +0000 (UTC) Date: Tue, 13 Aug 2019 14:36:30 +0100 From: Jonathan Wakely To: gcc-patches@gcc.gnu.org Cc: Jason Merrill , Nathan Sidwell , David Malcolm Subject: [PATCH 2/2] Add more entries to the C++ get_std_name_hint array Message-ID: <20190813133630.GG9487@redhat.com> References: <20190813133217.GA11146@redhat.com> MIME-Version: 1.0 Content-Disposition: inline In-Reply-To: <20190813133217.GA11146@redhat.com> X-Clacks-Overhead: GNU Terry Pratchett User-Agent: Mutt/1.12.0 (2019-05-25) This adds some commonly-used C++11/14 names, and some new C++17/20 names. The latter aren't available when using the -std=gnu++14 default, so the fix-it suggesting to use a newer dialect is helpful. * name-lookup.c (get_std_name_hint): Add more entries. Tested x86_64-linux. OK for trunk? commit 0c12d092e5659689951b5e134b84c5b506b543d5 Author: Jonathan Wakely Date: Tue Aug 13 13:42:40 2019 +0100 Add more entries to the C++ get_std_name_hint array * name-lookup.c (get_std_name_hint): Add more entries. diff --git a/gcc/cp/name-lookup.c b/gcc/cp/name-lookup.c index 96b2d90540d..68ebd7655c7 100644 --- a/gcc/cp/name-lookup.c +++ b/gcc/cp/name-lookup.c @@ -5550,9 +5550,11 @@ get_std_name_hint (const char *name) {"make_any", "", cxx17}, /* . */ {"array", "", cxx11}, + {"to_array", "", cxx2a}, /* . */ {"atomic", "", cxx11}, {"atomic_flag", "", cxx11}, + {"atomic_ref", "", cxx2a}, /* . */ {"bitset", "", cxx11}, /* . */ @@ -5575,9 +5577,17 @@ get_std_name_hint (const char *name) {"ofstream", "", cxx98}, /* . */ {"bind", "", cxx11}, + {"bind_front", "", cxx2a}, {"function", "", cxx11}, {"hash", "", cxx11}, + {"invoke", "", cxx17}, {"mem_fn", "", cxx11}, + {"not_fn", "", cxx17}, + {"reference_wrapper", "", cxx11}, + {"unwrap_reference", "", cxx2a}, + {"unwrap_reference_t", "", cxx2a}, + {"unwrap_ref_decay", "", cxx2a}, + {"unwrap_ref_decay_t", "", cxx2a}, /* . */ {"async", "", cxx11}, {"future", "", cxx11}, @@ -5618,11 +5628,16 @@ get_std_name_hint (const char *name) {"map", "", cxx98}, {"multimap", "", cxx98}, /* . */ + {"allocate_shared", "", cxx11}, + {"allocator", "", cxx98}, + {"allocator_traits", "", cxx11}, {"make_shared", "", cxx11}, {"make_unique", "", cxx14}, {"shared_ptr", "", cxx11}, {"unique_ptr", "", cxx11}, {"weak_ptr", "", cxx11}, + /* . */ + {"pmr", "", cxx17}, /* . */ {"mutex", "", cxx11}, {"timed_mutex", "", cxx11}, @@ -5672,14 +5687,39 @@ get_std_name_hint (const char *name) {"u16string", "", cxx11}, {"u32string", "", cxx11}, /* . */ + {"basic_string_view", "", cxx17}, {"string_view", "", cxx17}, /* . */ {"thread", "", cxx11}, + {"this_thread", "", cxx11}, /* . */ + {"apply", "", cxx17}, + {"forward_as_tuple", "", cxx11}, + {"make_from_tuple", "", cxx17}, {"make_tuple", "", cxx11}, + {"tie", "", cxx11}, {"tuple", "", cxx11}, + {"tuple_cat", "", cxx11}, {"tuple_element", "", cxx11}, + {"tuple_element_t", "", cxx14}, {"tuple_size", "", cxx11}, + {"tuple_size_v", "", cxx17}, + /* . */ + {"enable_if", "", cxx11}, + {"enable_if_t", "", cxx14}, + {"invoke_result", "", cxx17}, + {"invoke_result_t", "", cxx17}, + {"remove_cvref", "", cxx17}, + {"remove_cvref_t", "", cxx17}, + {"type_identity", "", cxx2a}, + {"type_identity_t", "", cxx2a}, + {"void_t", "", cxx17}, + {"conjunction", "", cxx17}, + {"conjunction_v", "", cxx17}, + {"disjunction", "", cxx17}, + {"disjunction_v", "", cxx17}, + {"negation", "", cxx17}, + {"negation_v", "", cxx17}, /* . */ {"unordered_map", "", cxx11}, {"unordered_multimap", "", cxx11},