public inbox for gcc-cvs@sourceware.org
help / color / mirror / Atom feed
* [gcc/devel/gccgo] c++: add "'requires' only available with ..." note
@ 2020-07-12 17:32 Ian Lance Taylor
  0 siblings, 0 replies; only message in thread
From: Ian Lance Taylor @ 2020-07-12 17:32 UTC (permalink / raw)
  To: gcc-cvs

https://gcc.gnu.org/g:5e7e8b98f49eda9ffb9817d97975a211c87c5a53

commit 5e7e8b98f49eda9ffb9817d97975a211c87c5a53
Author: Patrick Palka <ppalka@redhat.com>
Date:   Fri Apr 24 21:16:59 2020 -0400

    c++: add "'requires' only available with ..." note
    
    This adds a note suggesting to enable concepts whenever 'requires' is parsed as
    an invalid type name with concepts disabled.
    
    gcc/cp/ChangeLog:
    
            * parser.c (cp_parser_diagnose_invalid_type_name): Suggest enabling
            concepts if the invalid identifier is 'requires'.
    
    gcc/testsuite/ChangeLog:
    
            * g++.dg/concepts/diagnostic11.C: New test.

Diff:
---
 gcc/cp/ChangeLog                             | 5 +++++
 gcc/cp/parser.c                              | 3 +++
 gcc/testsuite/ChangeLog                      | 4 ++++
 gcc/testsuite/g++.dg/concepts/diagnostic11.C | 6 ++++++
 4 files changed, 18 insertions(+)

diff --git a/gcc/cp/ChangeLog b/gcc/cp/ChangeLog
index 5b9ff5a694c..2a5b4171366 100644
--- a/gcc/cp/ChangeLog
+++ b/gcc/cp/ChangeLog
@@ -1,3 +1,8 @@
+2020-04-25  Patrick Palka  <ppalka@redhat.com>
+
+	* parser.c (cp_parser_diagnose_invalid_type_name): Suggest enabling
+	concepts if the invalid identifier is 'requires'.
+
 2020-04-25  Jakub Jelinek  <jakub@redhat.com>
 
 	PR c++/94742
diff --git a/gcc/cp/parser.c b/gcc/cp/parser.c
index d2f3f853cb4..e1f9786893a 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, "%<concept%> only available with %<-std=c++2a%> or "
 		"%<-fconcepts%>");
+      else if (!flag_concepts && id == ridpointers[(int)RID_REQUIRES])
+	inform (location, "%<requires%> 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/ChangeLog b/gcc/testsuite/ChangeLog
index b9be66865cd..efbfe99d0d9 100644
--- a/gcc/testsuite/ChangeLog
+++ b/gcc/testsuite/ChangeLog
@@ -1,3 +1,7 @@
+2020-04-25  Patrick Palka  <ppalka@redhat.com>
+
+	* g++.dg/concepts/diagnostic11.C: New test.
+
 2020-04-25  Jakub Jelinek  <jakub@redhat.com>
 
 	PR c++/94742
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 <bool B>
+  requires B // { dg-error ".requires. does not name a type" }
+// { dg-message ".requires. only available with" "" { target *-*-* } .-1 }
+void foo() { }


^ permalink raw reply	[flat|nested] only message in thread

only message in thread, other threads:[~2020-07-12 17:32 UTC | newest]

Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-07-12 17:32 [gcc/devel/gccgo] c++: add "'requires' only available with ..." note Ian Lance Taylor

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).