Commit 32129a17 by David Malcolm Committed by David Malcolm

C/C++: show pertinent open token when missing a close token

gcc/c/ChangeLog:
	* c-parser.c (c_parser_error): Rename to...
	(c_parser_error_richloc): ...this, making static, and adding
	"richloc" parameter, passing it to the c_parse_error call,
	rather than calling c_parser_set_source_position_from_token.
	(c_parser_error): Reintroduce, reimplementing in terms of the
	above, converting return type from void to bool.
	(class token_pair): New class.
	(struct matching_paren_traits): New struct.
	(matching_parens): New typedef.
	(struct matching_brace_traits): New struct.
	(matching_braces): New typedef.
	(get_matching_symbol): New function.
	(c_parser_require): Add param MATCHING_LOCATION, using it to
	highlight matching "opening" tokens for missing "closing" tokens.
	(c_parser_skip_until_found): Likewise.
	(c_parser_static_assert_declaration_no_semi): Convert explicit
	parsing of CPP_OPEN_PAREN and CPP_CLOSE_PAREN to use of
	class matching_parens, so that the pertinent open parenthesis is
	highlighted when there are problems locating the close
	parenthesis.
	(c_parser_struct_or_union_specifier): Likewise.
	(c_parser_typeof_specifier): Likewise.
	(c_parser_alignas_specifier): Likewise.
	(c_parser_simple_asm_expr): Likewise.
	(c_parser_braced_init): Likewise, for matching_braces.
	(c_parser_paren_condition): Likewise, for matching_parens.
	(c_parser_switch_statement): Likewise.
	(c_parser_for_statement): Likewise.
	(c_parser_asm_statement): Likewise.
	(c_parser_asm_operands): Likewise.
	(c_parser_cast_expression): Likewise.
	(c_parser_sizeof_expression): Likewise.
	(c_parser_alignof_expression): Likewise.
	(c_parser_generic_selection): Likewise.
	(c_parser_postfix_expression): Likewise for cases RID_VA_ARG,
	RID_OFFSETOF, RID_TYPES_COMPATIBLE_P, RID_AT_SELECTOR,
	RID_AT_PROTOCOL, RID_AT_ENCODE, reindenting as necessary.
	In case CPP_OPEN_PAREN, pass loc_open_paren to the
	c_parser_skip_until_found call.
	(c_parser_objc_class_definition): Use class matching_parens as
	above.
	(c_parser_objc_method_decl): Likewise.
	(c_parser_objc_try_catch_finally_statement): Likewise.
	(c_parser_objc_synchronized_statement): Likewise.
	(c_parser_objc_at_property_declaration): Likewise.
	(c_parser_oacc_wait_list): Likewise.
	(c_parser_omp_var_list_parens): Likewise.
	(c_parser_omp_clause_collapse): Likewise.
	(c_parser_omp_clause_default): Likewise.
	(c_parser_omp_clause_if): Likewise.
	(c_parser_omp_clause_num_threads): Likewise.
	(c_parser_omp_clause_num_tasks): Likewise.
	(c_parser_omp_clause_grainsize): Likewise.
	(c_parser_omp_clause_priority): Likewise.
	(c_parser_omp_clause_hint): Likewise.
	(c_parser_omp_clause_defaultmap): Likewise.
	(c_parser_oacc_single_int_clause): Likewise.
	(c_parser_omp_clause_ordered): Likewise.
	(c_parser_omp_clause_reduction): Likewise.
	(c_parser_omp_clause_schedule): Likewise.
	(c_parser_omp_clause_num_teams): Likewise.
	(c_parser_omp_clause_thread_limit): Likewise.
	(c_parser_omp_clause_aligned): Likewise.
	(c_parser_omp_clause_linear): Likewise.
	(c_parser_omp_clause_safelen): Likewise.
	(c_parser_omp_clause_simdlen): Likewise.
	(c_parser_omp_clause_depend): Likewise.
	(c_parser_omp_clause_map): Likewise.
	(c_parser_omp_clause_device): Likewise.
	(c_parser_omp_clause_dist_schedule): Likewise.
	(c_parser_omp_clause_proc_bind): Likewise.
	(c_parser_omp_clause_uniform): Likewise.
	(c_parser_omp_for_loop): Likewise.
	(c_parser_cilk_clause_vectorlength): Likewise.
	(c_parser_cilk_clause_linear): Likewise.
	(c_parser_transaction_expression): Likewise.
	* c-parser.h (c_parser_require): Add param matching_location with
	default UNKNOWN_LOCATION.
	(c_parser_error): Convert return type from void to bool.
	(c_parser_skip_until_found): Add param matching_location with
	default UNKNOWN_LOCATION.

gcc/c-family/ChangeLog:
	* c-common.c (c_parse_error): Add rich_location * param, using it
	rather implicitly using input_location.
	* c-common.h (c_parse_error): Add rich_location * param.

gcc/cp/ChangeLog:
	* parser.c (cp_parser_error): Update for new param to
	c_parse_error.
	(class token_pair): New class.
	(struct matching_paren_traits): New struct.
	(matching_parens): New typedef.
	(struct matching_brace_traits): New struct.
	(matching_braces): New typedef.
	(cp_parser_statement_expr): Convert explicit parsing of
	CPP_OPEN_PAREN and CPP_CLOSE_PAREN to use of
	class matching_parens, so that the pertinent open parenthesis is
	highlighted when there are problems locating the close
	parenthesis.
	(cp_parser_primary_expression): Likewise.
	(cp_parser_compound_literal_p): Remove consumption of opening
	paren.
	(cp_parser_postfix_expression): Convert explicit parsing of
	CPP_OPEN_PAREN and CPP_CLOSE_PAREN to use matching parens, as
	above.  Use it to consume the opening paren previously consumed by
	cp_parser_compound_literal_p.
	(cp_parser_parenthesized_expression_list): Likewise.
	(cp_parser_unary_expression): Likewise.
	(cp_parser_new_expression): Likewise.
	(cp_parser_cast_expression): Likewise.
	(cp_parser_builtin_offsetof): Likewise.
	(cp_parser_trait_expr): Likewise.
	(cp_parser_lambda_declarator_opt): Likewise.
	(cp_parser_lambda_body): Likewise, for matching_braces.
	(cp_parser_compound_statement): Likewise.
	(cp_parser_selection_statement): Likewise, for matching_parens.
	(cp_parser_iteration_statement): Likewise.
	(cp_parser_already_scoped_statement): Likewise, for
	matching_braces.
	(cp_parser_linkage_specification): Likewise.
	(cp_parser_static_assert): Likewise, for matching_parens.
	(cp_parser_decltype): Likewise.
	(cp_parser_operator): Likewise.
	(cp_parser_enum_specifier): Likewise.
	(cp_parser_namespace_definition): Likewise.
	(cp_parser_direct_declarator): Likewise.
	(cp_parser_braced_list): Likewise.
	(cp_parser_class_specifier_1): Likewise, for matching_braces.
	(cp_parser_constant_initializer): Likewise.
	(cp_parser_noexcept_specification_opt): Likewise, for
	matching_parens.
	(cp_parser_exception_specification_opt): Likewise.
	(cp_parser_handler): Likewise.
	(cp_parser_asm_specification_opt): Likewise.
	(cp_parser_asm_operand_list): Likewise.
	(cp_parser_gnu_attributes_opt): Likewise.
	(cp_parser_std_attribute_spec): Likewise.
	(cp_parser_requirement_parameter_list): Likewise.
	(cp_parser_requirement_body): Likewise, for matching_braces.
	(cp_parser_compound_requirement): Likewise.
	(cp_parser_template_introduction): Likewise.
	(cp_parser_sizeof_pack): Likewise, for matching_parens.
	(cp_parser_sizeof_operand): Likewise; use it to consume the
	opening paren previously consumed by cp_parser_compound_literal_p.
	(get_matching_symbol): New function.
	(cp_parser_required_error): Add param "matching_location".  Remove
	calls to cp_parser_error, instead setting a non-NULL gmsgid, and
	handling it if set by calling c_parse_error, potentially with a
	secondary location if matching_location was set.
	(cp_parser_require): Add param "matching_location", with a default
	value of UNKNOWN_LOCATION.
	(cp_parser_require_keyword): Update for new param of
	cp_parser_required_error.
	(cp_parser_objc_encode_expression): Update to class matching_parens
	as above.
	(cp_parser_objc_defs_expression): Likewise.
	(cp_parser_objc_protocol_expression): Likewise.
	(cp_parser_objc_selector_expression): Likewise.
	(cp_parser_objc_typename): Likewise.
	(cp_parser_objc_superclass_or_category): Likewise.
	(cp_parser_objc_try_catch_finally_statement): Likewise.
	(cp_parser_objc_synchronized_statement): Likewise.
	(cp_parser_objc_at_property_declaration): Likewise.
	(cp_parser_oacc_single_int_clause): Likewise.
	(cp_parser_oacc_shape_clause): Likewise.
	(cp_parser_omp_clause_collapse): Likewise.
	(cp_parser_omp_clause_default): Likewise.
	(cp_parser_omp_clause_final): Likewise.
	(cp_parser_omp_clause_if): Likewise.
	(cp_parser_omp_clause_num_threads): Likewise.
	(cp_parser_omp_clause_num_tasks): Likewise.
	(cp_parser_omp_clause_grainsize): Likewise.
	(cp_parser_omp_clause_priority): Likewise.
	(cp_parser_omp_clause_hint): Likewise.
	(cp_parser_omp_clause_defaultmap): Likewise.
	(cp_parser_omp_clause_ordered): Likewise.
	(cp_parser_omp_clause_schedule): Likewise.
	(cp_parser_omp_clause_num_teams): Likewise.
	(cp_parser_omp_clause_thread_limit): Likewise.
	(cp_parser_omp_clause_aligned): Likewise.
	(cp_parser_omp_clause_linear): Likewise.
	(cp_parser_omp_clause_safelen): Likewise.
	(cp_parser_omp_clause_simdlen): Likewise.
	(cp_parser_omp_clause_depend): Likewise.
	(cp_parser_omp_clause_device): Likewise.
	(cp_parser_omp_clause_dist_schedule): Likewise.
	(cp_parser_oacc_clause_async): Likewise.
	(cp_parser_omp_critical): Likewise.
	(cp_parser_omp_for_loop): Likewise.
	(cp_parser_omp_sections_scope): Likewise.
	(cp_parser_omp_declare_reduction_exprs): Likewise.
	Update for new param to cp_parser_required_error.
	(cp_parser_oacc_routine): Likewise.
	(cp_parser_transaction_expression): Likewise.
	(cp_parser_cilk_simd_vectorlength): Likewise.

gcc/testsuite/ChangeLog:
	* c-c++-common/missing-close-symbol.c: New test case.
	* c-c++-common/missing-symbol.c: New test case.
	* gcc.dg/unclosed-init.c: New test case.
	* g++.dg/diagnostic/unclosed-extern-c.C: New test case.
	* g++.dg/diagnostic/unclosed-function.C: New test case.
	* g++.dg/diagnostic/unclosed-namespace.C: New test case.
	* g++.dg/diagnostic/unclosed-struct.C: New test case.
	* g++.dg/parse/pragma2.C: Update to reflect movement of the
	"expected identifier" error.

From-SVN: r251026
parent 7c23ac0d
2017-08-10 David Malcolm <dmalcolm@redhat.com>
* c-common.c (c_parse_error): Add rich_location * param, using it
rather implicitly using input_location.
* c-common.h (c_parse_error): Add rich_location * param.
2017-08-09 Marek Polacek <polacek@redhat.com>
* c-common.c (pointer_int_sum): Use true/false instead of 1/0.
......
......@@ -5950,12 +5950,13 @@ catenate_strings (const char *lhs, const char *rhs_start, int rhs_size)
return result;
}
/* Issue the error given by GMSGID, indicating that it occurred before
TOKEN, which had the associated VALUE. */
/* Issue the error given by GMSGID at RICHLOC, indicating that it occurred
before TOKEN, which had the associated VALUE. */
void
c_parse_error (const char *gmsgid, enum cpp_ttype token_type,
tree value, unsigned char token_flags)
tree value, unsigned char token_flags,
rich_location *richloc)
{
#define catenate_messages(M1, M2) catenate_strings ((M1), (M2), sizeof (M2))
......@@ -5996,7 +5997,7 @@ c_parse_error (const char *gmsgid, enum cpp_ttype token_type,
else
message = catenate_messages (gmsgid, " before %s'\\x%x'");
error (message, prefix, val);
error_at_rich_loc (richloc, message, prefix, val);
free (message);
message = NULL;
}
......@@ -6024,7 +6025,7 @@ c_parse_error (const char *gmsgid, enum cpp_ttype token_type,
else if (token_type == CPP_NAME)
{
message = catenate_messages (gmsgid, " before %qE");
error (message, value);
error_at_rich_loc (richloc, message, value);
free (message);
message = NULL;
}
......@@ -6037,16 +6038,16 @@ c_parse_error (const char *gmsgid, enum cpp_ttype token_type,
else if (token_type < N_TTYPES)
{
message = catenate_messages (gmsgid, " before %qs token");
error (message, cpp_type2name (token_type, token_flags));
error_at_rich_loc (richloc, message, cpp_type2name (token_type, token_flags));
free (message);
message = NULL;
}
else
error (gmsgid);
error_at_rich_loc (richloc, gmsgid);
if (message)
{
error (message);
error_at_rich_loc (richloc, message);
free (message);
}
#undef catenate_messages
......
......@@ -1124,7 +1124,8 @@ extern void builtin_define_with_int_value (const char *, HOST_WIDE_INT);
extern void builtin_define_type_sizeof (const char *, tree);
extern void c_stddef_cpp_builtins (void);
extern void fe_file_change (const line_map_ordinary *);
extern void c_parse_error (const char *, enum cpp_ttype, tree, unsigned char);
extern void c_parse_error (const char *, enum cpp_ttype, tree, unsigned char,
rich_location *richloc);
/* In c-ppoutput.c */
extern void init_pp_output (FILE *);
......
2017-08-10 David Malcolm <dmalcolm@redhat.com>
* c-parser.c (c_parser_error): Rename to...
(c_parser_error_richloc): ...this, making static, and adding
"richloc" parameter, passing it to the c_parse_error call,
rather than calling c_parser_set_source_position_from_token.
(c_parser_error): Reintroduce, reimplementing in terms of the
above, converting return type from void to bool.
(class token_pair): New class.
(struct matching_paren_traits): New struct.
(matching_parens): New typedef.
(struct matching_brace_traits): New struct.
(matching_braces): New typedef.
(get_matching_symbol): New function.
(c_parser_require): Add param MATCHING_LOCATION, using it to
highlight matching "opening" tokens for missing "closing" tokens.
(c_parser_skip_until_found): Likewise.
(c_parser_static_assert_declaration_no_semi): Convert explicit
parsing of CPP_OPEN_PAREN and CPP_CLOSE_PAREN to use of
class matching_parens, so that the pertinent open parenthesis is
highlighted when there are problems locating the close
parenthesis.
(c_parser_struct_or_union_specifier): Likewise.
(c_parser_typeof_specifier): Likewise.
(c_parser_alignas_specifier): Likewise.
(c_parser_simple_asm_expr): Likewise.
(c_parser_braced_init): Likewise, for matching_braces.
(c_parser_paren_condition): Likewise, for matching_parens.
(c_parser_switch_statement): Likewise.
(c_parser_for_statement): Likewise.
(c_parser_asm_statement): Likewise.
(c_parser_asm_operands): Likewise.
(c_parser_cast_expression): Likewise.
(c_parser_sizeof_expression): Likewise.
(c_parser_alignof_expression): Likewise.
(c_parser_generic_selection): Likewise.
(c_parser_postfix_expression): Likewise for cases RID_VA_ARG,
RID_OFFSETOF, RID_TYPES_COMPATIBLE_P, RID_AT_SELECTOR,
RID_AT_PROTOCOL, RID_AT_ENCODE, reindenting as necessary.
In case CPP_OPEN_PAREN, pass loc_open_paren to the
c_parser_skip_until_found call.
(c_parser_objc_class_definition): Use class matching_parens as
above.
(c_parser_objc_method_decl): Likewise.
(c_parser_objc_try_catch_finally_statement): Likewise.
(c_parser_objc_synchronized_statement): Likewise.
(c_parser_objc_at_property_declaration): Likewise.
(c_parser_oacc_wait_list): Likewise.
(c_parser_omp_var_list_parens): Likewise.
(c_parser_omp_clause_collapse): Likewise.
(c_parser_omp_clause_default): Likewise.
(c_parser_omp_clause_if): Likewise.
(c_parser_omp_clause_num_threads): Likewise.
(c_parser_omp_clause_num_tasks): Likewise.
(c_parser_omp_clause_grainsize): Likewise.
(c_parser_omp_clause_priority): Likewise.
(c_parser_omp_clause_hint): Likewise.
(c_parser_omp_clause_defaultmap): Likewise.
(c_parser_oacc_single_int_clause): Likewise.
(c_parser_omp_clause_ordered): Likewise.
(c_parser_omp_clause_reduction): Likewise.
(c_parser_omp_clause_schedule): Likewise.
(c_parser_omp_clause_num_teams): Likewise.
(c_parser_omp_clause_thread_limit): Likewise.
(c_parser_omp_clause_aligned): Likewise.
(c_parser_omp_clause_linear): Likewise.
(c_parser_omp_clause_safelen): Likewise.
(c_parser_omp_clause_simdlen): Likewise.
(c_parser_omp_clause_depend): Likewise.
(c_parser_omp_clause_map): Likewise.
(c_parser_omp_clause_device): Likewise.
(c_parser_omp_clause_dist_schedule): Likewise.
(c_parser_omp_clause_proc_bind): Likewise.
(c_parser_omp_clause_uniform): Likewise.
(c_parser_omp_for_loop): Likewise.
(c_parser_cilk_clause_vectorlength): Likewise.
(c_parser_cilk_clause_linear): Likewise.
(c_parser_transaction_expression): Likewise.
* c-parser.h (c_parser_require): Add param matching_location with
default UNKNOWN_LOCATION.
(c_parser_error): Convert return type from void to bool.
(c_parser_skip_until_found): Add param matching_location with
default UNKNOWN_LOCATION.
2017-08-09 Marek Polacek <polacek@redhat.com>
* c-decl.c (build_enumerator): Use true/false instead of 1/0.
......
......@@ -136,11 +136,13 @@ extern c_token * c_parser_peek_token (c_parser *parser);
extern c_token * c_parser_peek_2nd_token (c_parser *parser);
extern c_token * c_parser_peek_nth_token (c_parser *parser, unsigned int n);
extern bool c_parser_require (c_parser *parser, enum cpp_ttype type,
const char *msgid);
extern void c_parser_error (c_parser *parser, const char *gmsgid);
const char *msgid,
location_t matching_location = UNKNOWN_LOCATION);
extern bool c_parser_error (c_parser *parser, const char *gmsgid);
extern void c_parser_consume_token (c_parser *parser);
extern void c_parser_skip_until_found (c_parser *parser, enum cpp_ttype type,
const char *msgid);
const char *msgid,
location_t = UNKNOWN_LOCATION);
extern bool c_parser_next_token_starts_declspecs (c_parser *parser);
bool c_parser_next_tokens_start_declaration (c_parser *parser);
bool c_token_starts_typename (c_token *token);
......
2017-08-10 David Malcolm <dmalcolm@redhat.com>
* parser.c (cp_parser_error): Update for new param to
c_parse_error.
(class token_pair): New class.
(struct matching_paren_traits): New struct.
(matching_parens): New typedef.
(struct matching_brace_traits): New struct.
(matching_braces): New typedef.
(cp_parser_statement_expr): Convert explicit parsing of
CPP_OPEN_PAREN and CPP_CLOSE_PAREN to use of
class matching_parens, so that the pertinent open parenthesis is
highlighted when there are problems locating the close
parenthesis.
(cp_parser_primary_expression): Likewise.
(cp_parser_compound_literal_p): Remove consumption of opening
paren.
(cp_parser_postfix_expression): Convert explicit parsing of
CPP_OPEN_PAREN and CPP_CLOSE_PAREN to use matching parens, as
above. Use it to consume the opening paren previously consumed by
cp_parser_compound_literal_p.
(cp_parser_parenthesized_expression_list): Likewise.
(cp_parser_unary_expression): Likewise.
(cp_parser_new_expression): Likewise.
(cp_parser_cast_expression): Likewise.
(cp_parser_builtin_offsetof): Likewise.
(cp_parser_trait_expr): Likewise.
(cp_parser_lambda_declarator_opt): Likewise.
(cp_parser_lambda_body): Likewise, for matching_braces.
(cp_parser_compound_statement): Likewise.
(cp_parser_selection_statement): Likewise, for matching_parens.
(cp_parser_iteration_statement): Likewise.
(cp_parser_already_scoped_statement): Likewise, for
matching_braces.
(cp_parser_linkage_specification): Likewise.
(cp_parser_static_assert): Likewise, for matching_parens.
(cp_parser_decltype): Likewise.
(cp_parser_operator): Likewise.
(cp_parser_enum_specifier): Likewise.
(cp_parser_namespace_definition): Likewise.
(cp_parser_direct_declarator): Likewise.
(cp_parser_braced_list): Likewise.
(cp_parser_class_specifier_1): Likewise, for matching_braces.
(cp_parser_constant_initializer): Likewise.
(cp_parser_noexcept_specification_opt): Likewise, for
matching_parens.
(cp_parser_exception_specification_opt): Likewise.
(cp_parser_handler): Likewise.
(cp_parser_asm_specification_opt): Likewise.
(cp_parser_asm_operand_list): Likewise.
(cp_parser_gnu_attributes_opt): Likewise.
(cp_parser_std_attribute_spec): Likewise.
(cp_parser_requirement_parameter_list): Likewise.
(cp_parser_requirement_body): Likewise, for matching_braces.
(cp_parser_compound_requirement): Likewise.
(cp_parser_template_introduction): Likewise.
(cp_parser_sizeof_pack): Likewise, for matching_parens.
(cp_parser_sizeof_operand): Likewise; use it to consume the
opening paren previously consumed by cp_parser_compound_literal_p.
(get_matching_symbol): New function.
(cp_parser_required_error): Add param "matching_location". Remove
calls to cp_parser_error, instead setting a non-NULL gmsgid, and
handling it if set by calling c_parse_error, potentially with a
secondary location if matching_location was set.
(cp_parser_require): Add param "matching_location", with a default
value of UNKNOWN_LOCATION.
(cp_parser_require_keyword): Update for new param of
cp_parser_required_error.
(cp_parser_objc_encode_expression): Update to class matching_parens
as above.
(cp_parser_objc_defs_expression): Likewise.
(cp_parser_objc_protocol_expression): Likewise.
(cp_parser_objc_selector_expression): Likewise.
(cp_parser_objc_typename): Likewise.
(cp_parser_objc_superclass_or_category): Likewise.
(cp_parser_objc_try_catch_finally_statement): Likewise.
(cp_parser_objc_synchronized_statement): Likewise.
(cp_parser_objc_at_property_declaration): Likewise.
(cp_parser_oacc_single_int_clause): Likewise.
(cp_parser_oacc_shape_clause): Likewise.
(cp_parser_omp_clause_collapse): Likewise.
(cp_parser_omp_clause_default): Likewise.
(cp_parser_omp_clause_final): Likewise.
(cp_parser_omp_clause_if): Likewise.
(cp_parser_omp_clause_num_threads): Likewise.
(cp_parser_omp_clause_num_tasks): Likewise.
(cp_parser_omp_clause_grainsize): Likewise.
(cp_parser_omp_clause_priority): Likewise.
(cp_parser_omp_clause_hint): Likewise.
(cp_parser_omp_clause_defaultmap): Likewise.
(cp_parser_omp_clause_ordered): Likewise.
(cp_parser_omp_clause_schedule): Likewise.
(cp_parser_omp_clause_num_teams): Likewise.
(cp_parser_omp_clause_thread_limit): Likewise.
(cp_parser_omp_clause_aligned): Likewise.
(cp_parser_omp_clause_linear): Likewise.
(cp_parser_omp_clause_safelen): Likewise.
(cp_parser_omp_clause_simdlen): Likewise.
(cp_parser_omp_clause_depend): Likewise.
(cp_parser_omp_clause_device): Likewise.
(cp_parser_omp_clause_dist_schedule): Likewise.
(cp_parser_oacc_clause_async): Likewise.
(cp_parser_omp_critical): Likewise.
(cp_parser_omp_for_loop): Likewise.
(cp_parser_omp_sections_scope): Likewise.
(cp_parser_omp_declare_reduction_exprs): Likewise.
Update for new param to cp_parser_required_error.
(cp_parser_oacc_routine): Likewise.
(cp_parser_transaction_expression): Likewise.
(cp_parser_cilk_simd_vectorlength): Likewise.
2017-08-09 Jason Merrill <jason@redhat.com>
PR c++/81525 - wrong constant value with generic lambda
......
2017-08-10 David Malcolm <dmalcolm@redhat.com>
* c-c++-common/missing-close-symbol.c: New test case.
* c-c++-common/missing-symbol.c: New test case.
* gcc.dg/unclosed-init.c: New test case.
* g++.dg/diagnostic/unclosed-extern-c.C: New test case.
* g++.dg/diagnostic/unclosed-function.C: New test case.
* g++.dg/diagnostic/unclosed-namespace.C: New test case.
* g++.dg/diagnostic/unclosed-struct.C: New test case.
* g++.dg/parse/pragma2.C: Update to reflect movement of the
"expected identifier" error.
2017-08-10 Fritz Reese <fritzoreese@gmail.com>
* gfortran.dg/dec_d_lines_1.f: New test.
......
/* { dg-options "-fdiagnostics-show-caret" } */
/* Verify that the C/C++ frontends show the pertinent opening symbol when
a closing symbol is missing. */
/* Verify that, when they are on the same line, that the opening symbol is
shown as a secondary range within the main diagnostic. */
void test_static_assert_same_line (void)
{
_Static_assert(sizeof(int) >= sizeof(char), "msg"; /* { dg-error "expected '\\)' before ';' token" } */
/* { dg-begin-multiline-output "" }
_Static_assert(sizeof(int) >= sizeof(char), "msg";
~ ^
{ dg-end-multiline-output "" } */
}
/* Verify that, when they are on different lines, that the opening symbol is
shown via a secondary diagnostic. */
void test_static_assert_different_line (void)
{
_Static_assert(sizeof(int) >= sizeof(char), /* { dg-message "to match this '\\('" } */
"msg"; /* { dg-error "expected '\\)' before ';' token" } */
/* { dg-begin-multiline-output "" }
"msg";
^
{ dg-end-multiline-output "" } */
/* { dg-begin-multiline-output "" }
_Static_assert(sizeof(int) >= sizeof(char),
^
{ dg-end-multiline-output "" } */
}
/* { dg-options "-fdiagnostics-show-caret" } */
extern int foo (void);
extern int bar (void);
int missing_close_paren_in_switch (int i)
{
switch (i /* { dg-message "10: to match this '\\('" } */
{ /* { dg-error "5: expected '\\)' before '.' token" } */
/* { dg-begin-multiline-output "" }
{
^
{ dg-end-multiline-output "" } */
/* { dg-begin-multiline-output "" }
switch (i
^
{ dg-end-multiline-output "" } */
case 0:
return 5;
default:
return i;
}
} /* { dg-error "1: expected" } */
/* { dg-begin-multiline-output "" }
}
^
{ dg-end-multiline-output "" } */
void missing_close_paren_in_if (void)
{
if (foo () /* { dg-line start_of_if } */
&& bar ()
{ /* { dg-error "5: expected '\\)' before '.' token" } */
/* { dg-begin-multiline-output "" }
{
^
{ dg-end-multiline-output "" } */
/* { dg-message "6: to match this '\\('" "" { target *-*-* } start_of_if } */
/* { dg-begin-multiline-output "" }
if (foo ()
^
{ dg-end-multiline-output "" } */
}
} /* { dg-error "1: expected" } */
/* { dg-begin-multiline-output "" }
}
^
{ dg-end-multiline-output "" } */
extern "C" { /* { dg-message "12: to match this '.'" } */
void test (void); /* { dg-error "17: expected '.' at end of input" } */
void test (void)
{ /* { dg-message "1: to match this '.'" } */
int filler; /* { dg-error "13: expected '.' at end of input" } */
namespace unclosed { /* { dg-message "20: to match this '.'" } */
int filler; /* { dg-error "11: expected '.' at end of input" } */
struct unclosed { /* { dg-message "17: to match this '.'" } */
int dummy; /* { dg-error "12: expected '.' at end of input" } */
// { dg-error "expected unqualified-id at end of input" "" { target *-*-* } .-1 }
......@@ -4,5 +4,5 @@
// does not.
int f(int x,
#pragma interface // { dg-error "not allowed here" }
// The parser gets confused and issues an error on the next line.
int y); // { dg-bogus "" "" { xfail *-*-* } }
// { dg-bogus "expected identifier" "" { xfail *-*-* } .-1 }
int y);
int unclosed[] = { /* { dg-message "18: to match this '.'" } */
42
/* { dg-error "0: expected '.' at end of input" } */
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment