diff --git a/gcc/cp/parser.cc b/gcc/cp/parser.cc index 28a95e9fa7991..72f72fae87366 100644 --- a/gcc/cp/parser.cc +++ b/gcc/cp/parser.cc @@ -30087,7 +30087,7 @@ cp_parser_contract_attribute_spec (cp_parser *parser, tree attribute, } else { - parens.consume_open (parser); + parens.require_open (parser); if (postcondition_p && cp_lexer_next_token_is (parser->lexer, CPP_NAME) && cp_lexer_peek_nth_token (parser->lexer, 2)->type == CPP_COLON) identifier = cp_parser_identifier (parser); diff --git a/gcc/testsuite/g++.dg/contracts/new/contracts1.C b/gcc/testsuite/g++.dg/contracts/new/contracts1.C index a74dd5ac07115..63a308b868d9f 100644 --- a/gcc/testsuite/g++.dg/contracts/new/contracts1.C +++ b/gcc/testsuite/g++.dg/contracts/new/contracts1.C @@ -27,6 +27,7 @@ int g2(int a) [[pre: f(a) > a ]] } int fun(int n) pre (n > 0 ); +void fun2(int n) pre n > 0 ]]; // { dg-error } void fun2(int n) pre (: n > 0 ]]; // { dg-error } int fun3(int n) [[ pre : n > 0 ); // { dg-error "expected .]. before " }