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.
This commit is contained in:
parent
018730326d
commit
5e7e8b98f4
@ -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
|
||||
|
@ -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))
|
||||
{
|
||||
|
@ -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
|
||||
|
6
gcc/testsuite/g++.dg/concepts/diagnostic11.C
Normal file
6
gcc/testsuite/g++.dg/concepts/diagnostic11.C
Normal file
@ -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() { }
|
Loading…
Reference in New Issue
Block a user