From: Paolo Carlini Date: Wed, 29 Aug 2018 20:29:55 +0000 (+0000) Subject: re PR c++/85265 ([concepts] ICE with missing identifier) X-Git-Url: https://git.libre-soc.org/?a=commitdiff_plain;h=849ec6caae2fa53d3f552a1d58fd151a93a39edc;p=gcc.git re PR c++/85265 ([concepts] ICE with missing identifier) /cp 2018-08-29 Paolo Carlini PR c++/85265 * parser.c (cp_parser_introduction_list): If cp_parser_identifier returns error_mark_node early exit the loop. (cp_parser_template_introduction): Improve error-recovery, remove error call about empty introduction-list. /testsuite 2018-08-29 Paolo Carlini PR c++/85265 * g++.dg/concepts/pr85265.C: New. From-SVN: r263966 --- diff --git a/gcc/cp/ChangeLog b/gcc/cp/ChangeLog index 0719186f800..6ed074eea1a 100644 --- a/gcc/cp/ChangeLog +++ b/gcc/cp/ChangeLog @@ -1,3 +1,11 @@ +2018-08-29 Paolo Carlini + + PR c++/85265 + * parser.c (cp_parser_introduction_list): If cp_parser_identifier + returns error_mark_node early exit the loop. + (cp_parser_template_introduction): Improve error-recovery, remove + error call about empty introduction-list. + 2018-08-29 David Malcolm PR c++/85110 diff --git a/gcc/cp/parser.c b/gcc/cp/parser.c index 8291b131750..92e6b40efb4 100644 --- a/gcc/cp/parser.c +++ b/gcc/cp/parser.c @@ -15242,11 +15242,15 @@ cp_parser_introduction_list (cp_parser *parser) if (is_pack) cp_lexer_consume_token (parser->lexer); + tree identifier = cp_parser_identifier (parser); + if (identifier == error_mark_node) + break; + /* Build placeholder. */ tree parm = build_nt (WILDCARD_DECL); DECL_SOURCE_LOCATION (parm) = cp_lexer_peek_token (parser->lexer)->location; - DECL_NAME (parm) = cp_parser_identifier (parser); + DECL_NAME (parm) = identifier; WILDCARD_PACK_P (parm) = is_pack; vec_safe_push (introduction_vec, parm); @@ -27178,18 +27182,18 @@ cp_parser_template_introduction (cp_parser* parser, bool member_p) matching identifiers. */ tree introduction_list = cp_parser_introduction_list (parser); + /* Look for closing brace for introduction. */ + if (!braces.require_close (parser)) + return true; + /* The introduction-list shall not be empty. */ int nargs = TREE_VEC_LENGTH (introduction_list); if (nargs == 0) { - error ("empty introduction-list"); + /* In cp_parser_introduction_list we have already issued an error. */ return true; } - /* Look for closing brace for introduction. */ - if (!braces.require_close (parser)) - return true; - if (tmpl_decl == error_mark_node) { cp_parser_name_lookup_error (parser, concept_name, tmpl_decl, NLE_NULL, diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog index 20119739b15..78bbd7f31e5 100644 --- a/gcc/testsuite/ChangeLog +++ b/gcc/testsuite/ChangeLog @@ -1,3 +1,8 @@ +2018-08-29 Paolo Carlini + + PR c++/85265 + * g++.dg/concepts/pr85265.C: New. + 2018-08-29 Martin Sebor Bernd Edlinger diff --git a/gcc/testsuite/g++.dg/concepts/pr85265.C b/gcc/testsuite/g++.dg/concepts/pr85265.C new file mode 100644 index 00000000000..86124ceb712 --- /dev/null +++ b/gcc/testsuite/g++.dg/concepts/pr85265.C @@ -0,0 +1,6 @@ +// { dg-do compile { target c++14 } } +// { dg-additional-options "-fconcepts" } + +template concept bool C = true; + +C{} void foo(); // { dg-error "expected identifier" }