From: Andrew Sutton Date: Tue, 7 Jan 2020 01:02:06 +0000 (+0000) Subject: PR c++/92739 - parsing requires clause with attributes. X-Git-Url: https://git.libre-soc.org/?a=commitdiff_plain;h=e4bcf1f5497188d0ca6c4128767dcd0d5953914d;p=gcc.git PR c++/92739 - parsing requires clause with attributes. gcc/cp/ * parser.c (cp_parser_constraint_requires_parens): Exclude attributes as postfix expressions. gcc/testsuite/ * g++.dg/concepts-pr92739.C: New test. From-SVN: r279935 --- diff --git a/gcc/cp/ChangeLog b/gcc/cp/ChangeLog index 3e5f58cac2a..02ebb9fbf94 100644 --- a/gcc/cp/ChangeLog +++ b/gcc/cp/ChangeLog @@ -1,3 +1,9 @@ +2020-01-06 Andrew Sutton + + PR c++/92739 - parsing requires clause with attributes. + * parser.c (cp_parser_constraint_requires_parens): Exclude + attributes as postfix expressions. + 2020-01-05 Jakub Jelinek PR c++/93138 diff --git a/gcc/cp/parser.c b/gcc/cp/parser.c index 7cd8e150dd5..1ea05ddd497 100644 --- a/gcc/cp/parser.c +++ b/gcc/cp/parser.c @@ -27256,6 +27256,14 @@ cp_parser_constraint_requires_parens (cp_parser *parser, bool lambda_p) gcc_fallthrough (); } case CPP_OPEN_SQUARE: + { + /* A primary-constraint-expression followed by a '[[' is not a + postfix expression. */ + if (cp_lexer_nth_token_is (parser->lexer, 2, CPP_OPEN_SQUARE)) + return pce_ok; + + gcc_fallthrough (); + } case CPP_PLUS_PLUS: case CPP_MINUS_MINUS: case CPP_DOT: diff --git a/gcc/testsuite/g++.dg/cpp2a/concepts-attrib1.C b/gcc/testsuite/g++.dg/cpp2a/concepts-attrib1.C new file mode 100644 index 00000000000..0154afa5df1 --- /dev/null +++ b/gcc/testsuite/g++.dg/cpp2a/concepts-attrib1.C @@ -0,0 +1,15 @@ +// PR c++/92739 +// { dg-do compile { target concepts } } + +template +concept C = true; + +template + requires C +[[nodiscard]] int f(T t) { + return 22; +} + +int main() { + return 0; +}