Don't require 'bool' in a concept definition.
authorJason Merrill <jason@redhat.com>
Thu, 14 Mar 2019 19:53:04 +0000 (15:53 -0400)
committerJason Merrill <jason@gcc.gnu.org>
Thu, 14 Mar 2019 19:53:04 +0000 (15:53 -0400)
* parser.c (cp_parser_decl_specifier_seq): Support C++20
concept-definition syntax without 'bool'.

From-SVN: r269692

gcc/cp/ChangeLog
gcc/cp/parser.c
gcc/testsuite/g++.dg/concepts/no-bool1.C [new file with mode: 0644]

index 054a891bcef374a69643d7709b33978dcb9c0474..6c96c24430fc3477bf70032fd73ea5e5d0e1640d 100644 (file)
@@ -1,3 +1,8 @@
+2019-03-14  Jason Merrill  <jason@redhat.com>
+
+       * parser.c (cp_parser_decl_specifier_seq): Support C++20
+       concept-definition syntax without 'bool'.
+
 2019-03-14  Jakub Jelinek  <jakub@redhat.com>
 
        PR c++/89512
index 14da1a14501511127680ec5ba74c1834dae14788..b8a0245ce57a7c2f13f351306518bb66e9c94232 100644 (file)
@@ -13964,6 +13964,15 @@ cp_parser_decl_specifier_seq (cp_parser* parser,
         case RID_CONCEPT:
           ds = ds_concept;
           cp_lexer_consume_token (parser->lexer);
+         /* In C++20 a concept definition is just 'concept name = expr;'
+            Support that syntax by pretending we've seen 'bool'.  */
+         if (cp_lexer_next_token_is (parser->lexer, CPP_NAME)
+             && cp_lexer_nth_token_is (parser->lexer, 2, CPP_EQ))
+           {
+             cp_parser_set_decl_spec_type (decl_specs, boolean_type_node,
+                                           token, /*type_definition*/false);
+             decl_specs->any_type_specifiers_p = true;
+           }
           break;
 
          /* function-specifier:
diff --git a/gcc/testsuite/g++.dg/concepts/no-bool1.C b/gcc/testsuite/g++.dg/concepts/no-bool1.C
new file mode 100644 (file)
index 0000000..be9b73a
--- /dev/null
@@ -0,0 +1,4 @@
+// { dg-do compile { target c++14 } }
+// { dg-additional-options -fconcepts }
+
+template <class T> concept True = true;