diff options
author | Andrew Sutton <asutton@lock3software.com> | 2020-01-07 01:02:06 +0000 |
---|---|---|
committer | Jason Merrill <jason@gcc.gnu.org> | 2020-01-06 20:02:06 -0500 |
commit | e4bcf1f5497188d0ca6c4128767dcd0d5953914d (patch) | |
tree | 8a05b75ebc7b9266e690d339058ba0e41b84f1fc /gcc | |
parent | bd401fc809040000c15e9c6bd39e9507c692b697 (diff) | |
download | gcc-e4bcf1f5497188d0ca6c4128767dcd0d5953914d.zip gcc-e4bcf1f5497188d0ca6c4128767dcd0d5953914d.tar.gz gcc-e4bcf1f5497188d0ca6c4128767dcd0d5953914d.tar.bz2 |
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
Diffstat (limited to 'gcc')
-rw-r--r-- | gcc/cp/ChangeLog | 6 | ||||
-rw-r--r-- | gcc/cp/parser.c | 8 | ||||
-rw-r--r-- | gcc/testsuite/g++.dg/cpp2a/concepts-attrib1.C | 15 |
3 files changed, 29 insertions, 0 deletions
diff --git a/gcc/cp/ChangeLog b/gcc/cp/ChangeLog index 3e5f58c..02ebb9f 100644 --- a/gcc/cp/ChangeLog +++ b/gcc/cp/ChangeLog @@ -1,3 +1,9 @@ +2020-01-06 Andrew Sutton <asutton@lock3software.com> + + 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 <jakub@redhat.com> PR c++/93138 diff --git a/gcc/cp/parser.c b/gcc/cp/parser.c index 7cd8e15..1ea05dd 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 0000000..0154afa --- /dev/null +++ b/gcc/testsuite/g++.dg/cpp2a/concepts-attrib1.C @@ -0,0 +1,15 @@ +// PR c++/92739 +// { dg-do compile { target concepts } } + +template <class T> +concept C = true; + +template <class T> + requires C<T> +[[nodiscard]] int f(T t) { + return 22; +} + +int main() { + return 0; +} |