From patchwork Fri Apr 24 19:52:21 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Patrick Palka X-Patchwork-Id: 1276626 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=2620:52:3:1:0:246e:9693:128c; helo=sourceware.org; envelope-from=gcc-patches-bounces@gcc.gnu.org; receiver=) Authentication-Results: ozlabs.org; dmarc=none (p=none dis=none) header.from=gcc.gnu.org Authentication-Results: ozlabs.org; dkim=pass (1024-bit key; unprotected) header.d=gcc.gnu.org header.i=@gcc.gnu.org header.a=rsa-sha256 header.s=default header.b=iOvfGNbl; dkim-atps=neutral Received: from sourceware.org (server2.sourceware.org [IPv6:2620:52:3:1:0:246e:9693:128c]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 4984Zv12Bkz9sSG for ; Sat, 25 Apr 2020 05:52:37 +1000 (AEST) Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id 91B883894E65; Fri, 24 Apr 2020 19:52:34 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 91B883894E65 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gcc.gnu.org; s=default; t=1587757954; bh=0uUhbj2lfQW9Qxw+9/JFnatqEBERtS+lK9SIDwXmnJM=; h=To:Subject:Date:List-Id:List-Unsubscribe:List-Archive:List-Post: List-Help:List-Subscribe:From:Reply-To:From; b=iOvfGNblf2S1jmAwL7oLS6oGaNbAllqEDKxV5OEg9DC7UDM1xXPUS955n8mE96e9H eptjg2hY2yAPpQ2SXbUUT9olQZWTs0fhqAqWfgHtCt66etyrHAhfewZuHCVSDIV6m1 W6VI2KNJi3oZ6f+PPgdUNeZO2PuZpCGrkC7DRoig= X-Original-To: gcc-patches@gcc.gnu.org Delivered-To: gcc-patches@gcc.gnu.org Received: from us-smtp-delivery-1.mimecast.com (us-smtp-delivery-1.mimecast.com [205.139.110.120]) by sourceware.org (Postfix) with ESMTP id 49FE7389365C for ; Fri, 24 Apr 2020 19:52:32 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.3.2 sourceware.org 49FE7389365C Received: from mail-qk1-f197.google.com (mail-qk1-f197.google.com [209.85.222.197]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-112-BXg1oBAnMH6YMVv2QQWgow-1; Fri, 24 Apr 2020 15:52:30 -0400 X-MC-Unique: BXg1oBAnMH6YMVv2QQWgow-1 Received: by mail-qk1-f197.google.com with SMTP id h186so11711091qkc.22 for ; Fri, 24 Apr 2020 12:52:30 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:mime-version :content-transfer-encoding; bh=AjgSnHellA6TKZp9qDmQMH42yUNmC2qTBwn7diZ0yGs=; b=Vh0JHqjA7C5tcVpEG0UpICEh565iVfGixxJ67yCG9bBOSPjBM1QfcDT/kuKNzbMj1p UU1eum3/i9HzefwRN7XbW8PyXtS45wU9t05NhW/W4x9+IQNrfQwX7g12/mLfarY1FObV GQ32S0CWd4Zq3ZcM4keUNh+7M6yRK/ho0XIvxQtGZOU17TMyRMbT/dh2Ui5QcdKHqjHq Tay134OxIqKheu/aw9k33YnNB9QyTF2qAGYqDk69b50yb//PSf0M0xqlIlcJNb94s6hk w7cZ+jKQvHyJSfhOsOMthOVA8DUPC1tAYCzPlGrg65Lil3vQ3gvKV/01RXdJhCP87NkP UzwA== X-Gm-Message-State: AGi0PuYQxuGwZ5xO+1ssebz9Gx0clpueV1GW1UX5kbbSjNTOD1yG2ts9 cP9mhyxHQ1EJarwSom+vfe1SsJpstn2Hxxkffg2xKtxFJgD6yMiFTQYlj+nkHd9CigtExoqdsbn AKF/t2S0sMy4TE8cO4g== X-Received: by 2002:a37:cc7:: with SMTP id 190mr10811914qkm.44.1587757949533; Fri, 24 Apr 2020 12:52:29 -0700 (PDT) X-Google-Smtp-Source: APiQypLUkQ7Cl1w0+ARk94FQZqMd+I4MK7hxKfDqnvGwBMtMKNGaVj2VGFhNafTPH8wGKZuc8eTcpQ== X-Received: by 2002:a37:cc7:: with SMTP id 190mr10811892qkm.44.1587757949167; Fri, 24 Apr 2020 12:52:29 -0700 (PDT) Received: from localhost.localdomain (ool-457d493a.dyn.optonline.net. [69.125.73.58]) by smtp.gmail.com with ESMTPSA id i6sm4294535qkk.123.2020.04.24.12.52.27 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 24 Apr 2020 12:52:28 -0700 (PDT) To: gcc-patches@gcc.gnu.org Subject: [PATCH] c++: add "'requires' only available with ..." note Date: Fri, 24 Apr 2020 15:52:21 -0400 Message-Id: <20200424195221.3604674-1-ppalka@redhat.com> X-Mailer: git-send-email 2.26.2.266.ge870325ee8 MIME-Version: 1.0 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com X-Spam-Status: No, score=-28.3 required=5.0 tests=BAYES_00, DKIMWL_WL_HIGH, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, DKIM_VALID_EF, GIT_PATCH_0, GIT_PATCH_1, GIT_PATCH_2, GIT_PATCH_3, RCVD_IN_DNSWL_NONE, SPF_HELO_NONE, SPF_PASS, TXREP autolearn=ham autolearn_force=no version=3.4.2 X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) 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-Patchwork-Original-From: Patrick Palka via Gcc-patches From: Patrick Palka Reply-To: Patrick Palka Errors-To: gcc-patches-bounces@gcc.gnu.org Sender: "Gcc-patches" This adds a note suggesting to enable concepts whenever 'requires' is parsed as an invalid type name with concepts disabled. Bootstrapped and regtested on x86_64-pc-linux-gnu, does this look OK to commit? gcc/cp/ChangeLog: * parser.c (cp_parser_diagnose_invalid_type_name): Suggest to enable concepts if the invalid identifier is 'requires'. gcc/testsuite/ChangeLog: * g++.dg/concepts/diagnostic11.C: New test. --- gcc/cp/parser.c | 3 +++ gcc/testsuite/g++.dg/concepts/diagnostic11.C | 6 ++++++ 2 files changed, 9 insertions(+) create mode 100644 gcc/testsuite/g++.dg/concepts/diagnostic11.C diff --git a/gcc/cp/parser.c b/gcc/cp/parser.c index 47e3f2bbd3d..337f22d2784 100644 --- a/gcc/cp/parser.c +++ b/gcc/cp/parser.c @@ -3378,6 +3378,9 @@ cp_parser_diagnose_invalid_type_name (cp_parser *parser, tree id, else if (!flag_concepts && id == ridpointers[(int)RID_CONCEPT]) inform (location, "% only available with %<-std=c++2a%> or " "%<-fconcepts%>"); + else if (!flag_concepts && id == ridpointers[(int)RID_REQUIRES]) + inform (location, "% only available with %<-std=c++2a%> or " + "%<-fconcepts%>"); else if (processing_template_decl && current_class_type && TYPE_BINFO (current_class_type)) { diff --git a/gcc/testsuite/g++.dg/concepts/diagnostic11.C b/gcc/testsuite/g++.dg/concepts/diagnostic11.C new file mode 100644 index 00000000000..7c60912352a --- /dev/null +++ b/gcc/testsuite/g++.dg/concepts/diagnostic11.C @@ -0,0 +1,6 @@ +// { dg-do compile { target c++17_only } } + +template + requires B // { dg-error ".requires. does not name a type" } +// { dg-message ".requires. only available with" "" { target *-*-* } .-1 } +void foo() { }