From 471c53308a04d9f65a8e13b458fb56366318dc04 Mon Sep 17 00:00:00 2001 From: Joseph Myers Date: Thu, 7 Nov 2019 01:01:07 +0000 Subject: [PATCH] Move string concatenation for C into the parser. This patch is another piece of preparation for C2x attributes support. C2x attributes require unbounded lookahead in the parser, because the token sequence '[[' that starts a C2x attribute is also valid in Objective-C in some of the same contexts, so it is necessary to see whether the matching ']]' are consecutive tokens or not to determine whether those tokens start an attribute. Unbounded lookahead means lexing an unbounded number of tokens before they are parsed. c_lex_one_token does various context-sensitive processing of tokens that cannot be done at that lookahead time, because it depends on information (such as whether particular identifiers are typedefs) that may be different at the time it is relevant than at the time the lookahead is needed (recall that more or less arbitrary C code, including declarations and statements, can appear inside expressions in GNU C). Most of that context-sensitive processing is not a problem, simply because it is not needed for lookahead purposes so can be deferred until the tokens lexed during lookahead are parsed. However, the earliest piece of context-sensitive processing is the handling of string literals based on flags passed to c_lex_with_flags, which determine whether adjacent literals are concatenated and whether translation to the execution character set occurs. Because the choice of whether to translate to the execution character set is context-sensitive, this means that unbounded lookahead requires the C parser to move to the approach used by the C++ parser, where string literals are generally not translated or concatenated from within c_lex_with_flags, but only later in the parser once it knows whether translation is needed. (Translation requires the tokens in their form before concatenation.) Thus, this patch makes that change to the C parser. Flags in the parser are still used for two special cases similar to C++: the handling of an initial #pragma pch_preprocess, and arranging for strings inside attributes not to be translated (the latter is made more logically correct by saving and restoring the flags, as in the C++ parser, rather than assuming that the state outside the attribute was always to translate string literals, which might not be the case in corner cases involving declarations and attributes inside attributes). The consequent change to pragma_lex to use c_parser_string_literal makes it disallow wide strings and disable translation in that context, which also follows C++ and is more logically correct than the previous state without special handling in that regard. Translation to the execution character set is always disabled when string constants are handled in the GIMPLE parser. Although the handling of strings is now a lot closer to that in C++, there are still some differences, in particular regarding the handling of locations. See c-c++-common/Wformat-pr88257.c, which has different expected multiline diagnostic output for C and C++, for example; I'm not sure whether the C or C++ output is better there (C++ has a more complete range than C, C mentions a macro definition location that C++ doesn't), but I tried to keep the locations the same as those previously used by the C front end, as far as possible, to minimize the testsuite changes needed, rather than possibly making them closer to those used with C++. The only changes needed for tests of user-visible diagnostics were for the wording of one diagnostic changing to match C++ (as a consequence of having a check for wide strings based on a flag in a general string-handling function rather than in a function specific to asm). However, although locations are extremely similar to what they were before, I couldn't make them completely identical in all cases. (My understanding of the implementation reason for the differences is as follows: lex_string uses src_loc from each cpp_token; the C parser is using the virtual location from cpp_get_token_with_location as called by c_lex_with_flags, and while passing that through linemap_resolve_location with LRK_MACRO_DEFINITION_LOCATION, as this patch does, produces something very close to what lex_string uses, it's not completely identical in some cases.) This results in changes being needed to two of the gcc.dg/plugin tests that use a plugin to test details of how string locations are handled. Because the tests being changed are for ICEs and the only change is to the details of the particular non-user-visible error that code gives in cases it can't handle (one involving __FILE__, one involving a string literal from stringizing), I think it's OK to change that non-user-visible error and that the new errors are no worse than the old ones. So these particular errors are now different for C and C++ (some other messages in those tests already had differences between C and C++). Bootstrapped with no regressions on x86_64-pc-linux-gnu. gcc/c: * c-parser.c (c_parser): Remove lex_untranslated_string. Add lex_joined_string and translate_strings_p. (c_lex_one_token): Pass 0 or C_LEX_STRING_NO_JOIN to c_lex_with_flags. (c_parser_string_literal): New function. (c_parser_static_assert_declaration_no_semi): Use c_parser_string_literal. Do not set lex_untranslated_string. (c_parser_asm_string_literal): Use c_parser_string_literal. (c_parser_simple_asm_expr): Do not set lex_untranslated_string. (c_parser_gnu_attributes): Set and restore translate_strings_p instead of lex_untranslated_string. (c_parser_asm_statement): Do not set lex_untranslated_string. (c_parser_asm_operands): Likewise. (c_parser_has_attribute_expression): Set and restore translate_strings_p instead of lex_untranslated_string. (c_parser_postfix_expression): Use c_parser_string_literal. (pragma_lex): Likewise. (c_parser_pragma_pch_preprocess): Set lex_joined_string. (c_parse_file): Set translate_strings_p. * gimple-parser.c (c_parser_gimple_postfix_expression) (c_parser_gimple_or_rtl_pass_list): Use c_parser_string_literal. * c-parser.c (c_parser_string_literal): Declare function. gcc/testsuite: * gcc.dg/asm-wide-1.c, gcc.dg/diagnostic-token-ranges.c, gcc.dg/plugin/diagnostic-test-string-literals-1.c, gcc.dg/plugin/diagnostic-test-string-literals-2.c: Update expected diagnostics. From-SVN: r277903 --- gcc/c/ChangeLog | 25 ++ gcc/c/c-parser.c | 274 ++++++++++++++---- gcc/c/c-parser.h | 1 + gcc/c/gimple-parser.c | 9 +- gcc/testsuite/ChangeLog | 7 + gcc/testsuite/gcc.dg/asm-wide-1.c | 18 +- .../gcc.dg/diagnostic-token-ranges.c | 2 +- .../diagnostic-test-string-literals-1.c | 3 +- .../diagnostic-test-string-literals-2.c | 3 +- 9 files changed, 261 insertions(+), 81 deletions(-) diff --git a/gcc/c/ChangeLog b/gcc/c/ChangeLog index 59e53cf129f..c7bb22dc7a2 100644 --- a/gcc/c/ChangeLog +++ b/gcc/c/ChangeLog @@ -1,3 +1,28 @@ +2019-11-07 Joseph Myers + + * c-parser.c (c_parser): Remove lex_untranslated_string. Add + lex_joined_string and translate_strings_p. + (c_lex_one_token): Pass 0 or C_LEX_STRING_NO_JOIN to + c_lex_with_flags. + (c_parser_string_literal): New function. + (c_parser_static_assert_declaration_no_semi): Use + c_parser_string_literal. Do not set lex_untranslated_string. + (c_parser_asm_string_literal): Use c_parser_string_literal. + (c_parser_simple_asm_expr): Do not set lex_untranslated_string. + (c_parser_gnu_attributes): Set and restore translate_strings_p + instead of lex_untranslated_string. + (c_parser_asm_statement): Do not set lex_untranslated_string. + (c_parser_asm_operands): Likewise. + (c_parser_has_attribute_expression): Set and restore + translate_strings_p instead of lex_untranslated_string. + (c_parser_postfix_expression): Use c_parser_string_literal. + (pragma_lex): Likewise. + (c_parser_pragma_pch_preprocess): Set lex_joined_string. + (c_parse_file): Set translate_strings_p. + * gimple-parser.c (c_parser_gimple_postfix_expression) + (c_parser_gimple_or_rtl_pass_list): Use c_parser_string_literal. + * c-parser.c (c_parser_string_literal): Declare function. + 2019-11-02 Jakub Jelinek * c-parser.c (c_finish_omp_declare_variant): Use diff --git a/gcc/c/c-parser.c b/gcc/c/c-parser.c index 6a43419637f..4f044127a7e 100644 --- a/gcc/c/c-parser.c +++ b/gcc/c/c-parser.c @@ -185,8 +185,15 @@ struct GTY(()) c_parser { BOOL_BITFIELD in_pragma : 1; /* True if we're parsing the outermost block of an if statement. */ BOOL_BITFIELD in_if_block : 1; - /* True if we want to lex an untranslated string. */ - BOOL_BITFIELD lex_untranslated_string : 1; + /* True if we want to lex a translated, joined string (for an + initial #pragma pch_preprocess). Otherwise the parser is + responsible for concatenating strings and translating to the + execution character set as needed. */ + BOOL_BITFIELD lex_joined_string : 1; + /* True if, when the parser is concatenating string literals, it + should translate them to the execution character set (false + inside attributes). */ + BOOL_BITFIELD translate_strings_p : 1; /* Objective-C specific parser/lexer information. */ @@ -253,8 +260,8 @@ c_lex_one_token (c_parser *parser, c_token *token) token->type = c_lex_with_flags (&token->value, &token->location, &token->flags, - (parser->lex_untranslated_string - ? C_LEX_STRING_NO_TRANSLATE : 0)); + (parser->lex_joined_string + ? 0 : C_LEX_STRING_NO_JOIN)); token->id_kind = C_ID_NONE; token->keyword = RID_MAX; token->pragma_kind = PRAGMA_NONE; @@ -2481,7 +2488,6 @@ c_parser_static_assert_declaration_no_semi (c_parser *parser) location_t value_tok_loc = c_parser_peek_token (parser)->location; value = c_parser_expr_no_commas (parser, NULL).value; value_loc = EXPR_LOC_OR_LOC (value, value_tok_loc); - parser->lex_untranslated_string = true; if (c_parser_next_token_is (parser, CPP_COMMA)) { c_parser_consume_token (parser); @@ -2492,13 +2498,10 @@ c_parser_static_assert_declaration_no_semi (c_parser *parser) case CPP_STRING32: case CPP_WSTRING: case CPP_UTF8STRING: - string = c_parser_peek_token (parser)->value; - c_parser_consume_token (parser); - parser->lex_untranslated_string = false; + string = c_parser_string_literal (parser, false, true).value; break; default: c_parser_error (parser, "expected string literal"); - parser->lex_untranslated_string = false; return; } } @@ -4200,10 +4203,7 @@ c_parser_parameter_declaration (c_parser *parser, tree attrs) asm-string-literal: string-literal - - ??? At present, following the old parser, the caller needs to have - set lex_untranslated_string to 1. It would be better to follow the - C++ parser rather than using this kludge. */ +*/ static tree c_parser_asm_string_literal (c_parser *parser) @@ -4211,23 +4211,7 @@ c_parser_asm_string_literal (c_parser *parser) tree str; int save_flag = warn_overlength_strings; warn_overlength_strings = 0; - if (c_parser_next_token_is (parser, CPP_STRING)) - { - str = c_parser_peek_token (parser)->value; - c_parser_consume_token (parser); - } - else if (c_parser_next_token_is (parser, CPP_WSTRING)) - { - error_at (c_parser_peek_token (parser)->location, - "wide string literal in %"); - str = build_string (1, ""); - c_parser_consume_token (parser); - } - else - { - c_parser_error (parser, "expected string literal"); - str = NULL_TREE; - } + str = c_parser_string_literal (parser, false, false).value; warn_overlength_strings = save_flag; return str; } @@ -4245,18 +4229,11 @@ c_parser_simple_asm_expr (c_parser *parser) { tree str; gcc_assert (c_parser_next_token_is_keyword (parser, RID_ASM)); - /* ??? Follow the C++ parser rather than using the - lex_untranslated_string kludge. */ - parser->lex_untranslated_string = true; c_parser_consume_token (parser); matching_parens parens; if (!parens.require_open (parser)) - { - parser->lex_untranslated_string = false; - return NULL_TREE; - } + return NULL_TREE; str = c_parser_asm_string_literal (parser); - parser->lex_untranslated_string = false; if (!parens.require_close (parser)) { c_parser_skip_until_found (parser, CPP_CLOSE_PAREN, NULL); @@ -4457,7 +4434,6 @@ c_parser_gnu_attribute (c_parser *parser, tree attrs, c_parser_consume_token (parser); else { - parser->lex_untranslated_string = false; c_parser_skip_until_found (parser, CPP_CLOSE_PAREN, "expected %<)%>"); return error_mark_node; @@ -4483,20 +4459,19 @@ c_parser_gnu_attributes (c_parser *parser) tree attrs = NULL_TREE; while (c_parser_next_token_is_keyword (parser, RID_ATTRIBUTE)) { - /* ??? Follow the C++ parser rather than using the - lex_untranslated_string kludge. */ - parser->lex_untranslated_string = true; + bool save_translate_strings_p = parser->translate_strings_p; + parser->translate_strings_p = false; /* Consume the `__attribute__' keyword. */ c_parser_consume_token (parser); /* Look for the two `(' tokens. */ if (!c_parser_require (parser, CPP_OPEN_PAREN, "expected %<(%>")) { - parser->lex_untranslated_string = false; + parser->translate_strings_p = save_translate_strings_p; return attrs; } if (!c_parser_require (parser, CPP_OPEN_PAREN, "expected %<(%>")) { - parser->lex_untranslated_string = false; + parser->translate_strings_p = save_translate_strings_p; c_parser_skip_until_found (parser, CPP_CLOSE_PAREN, NULL); return attrs; } @@ -4518,7 +4493,7 @@ c_parser_gnu_attributes (c_parser *parser) c_parser_consume_token (parser); else { - parser->lex_untranslated_string = false; + parser->translate_strings_p = save_translate_strings_p; c_parser_skip_until_found (parser, CPP_CLOSE_PAREN, "expected %<)%>"); return attrs; @@ -4527,12 +4502,12 @@ c_parser_gnu_attributes (c_parser *parser) c_parser_consume_token (parser); else { - parser->lex_untranslated_string = false; + parser->translate_strings_p = save_translate_strings_p; c_parser_skip_until_found (parser, CPP_CLOSE_PAREN, "expected %<)%>"); return attrs; } - parser->lex_untranslated_string = false; + parser->translate_strings_p = save_translate_strings_p; } return attrs; @@ -6487,9 +6462,6 @@ c_parser_asm_statement (c_parser *parser) bool is_inline = (inline_loc != UNKNOWN_LOCATION); bool is_goto = (goto_loc != UNKNOWN_LOCATION); - /* ??? Follow the C++ parser rather than using the - lex_untranslated_string kludge. */ - parser->lex_untranslated_string = true; ret = NULL; matching_parens parens; @@ -6577,7 +6549,6 @@ c_parser_asm_statement (c_parser *parser) clobbers, labels, simple, is_inline)); error: - parser->lex_untranslated_string = false; return ret; error_close_paren: @@ -6628,16 +6599,11 @@ c_parser_asm_operands (c_parser *parser) str = c_parser_asm_string_literal (parser); if (str == NULL_TREE) return NULL_TREE; - parser->lex_untranslated_string = false; matching_parens parens; if (!parens.require_open (parser)) - { - parser->lex_untranslated_string = true; - return NULL_TREE; - } + return NULL_TREE; expr = c_parser_expression (parser); mark_exp_read (expr.value); - parser->lex_untranslated_string = true; if (!parens.require_close (parser)) { c_parser_skip_until_found (parser, CPP_CLOSE_PAREN, NULL); @@ -6718,6 +6684,185 @@ c_parser_asm_goto_operands (c_parser *parser) } } +/* Parse a possibly concatenated sequence of string literals. + TRANSLATE says whether to translate them to the execution character + set; WIDE_OK says whether any kind of prefixed string literal is + permitted in this context. This code is based on that in + lex_string. */ + +struct c_expr +c_parser_string_literal (c_parser *parser, bool translate, bool wide_ok) +{ + struct c_expr ret; + size_t count; + struct obstack str_ob; + struct obstack loc_ob; + cpp_string str, istr, *strs; + c_token *tok; + location_t loc, last_tok_loc; + enum cpp_ttype type; + tree value, string_tree; + + tok = c_parser_peek_token (parser); + loc = tok->location; + last_tok_loc = linemap_resolve_location (line_table, loc, + LRK_MACRO_DEFINITION_LOCATION, + NULL); + type = tok->type; + switch (type) + { + case CPP_STRING: + case CPP_WSTRING: + case CPP_STRING16: + case CPP_STRING32: + case CPP_UTF8STRING: + string_tree = tok->value; + break; + + default: + c_parser_error (parser, "expected string literal"); + ret.set_error (); + ret.value = NULL_TREE; + ret.original_code = ERROR_MARK; + ret.original_type = NULL_TREE; + return ret; + } + + /* Try to avoid the overhead of creating and destroying an obstack + for the common case of just one string. */ + switch (c_parser_peek_2nd_token (parser)->type) + { + default: + c_parser_consume_token (parser); + str.text = (const unsigned char *) TREE_STRING_POINTER (string_tree); + str.len = TREE_STRING_LENGTH (string_tree); + count = 1; + strs = &str; + break; + + case CPP_STRING: + case CPP_WSTRING: + case CPP_STRING16: + case CPP_STRING32: + case CPP_UTF8STRING: + gcc_obstack_init (&str_ob); + gcc_obstack_init (&loc_ob); + count = 0; + do + { + c_parser_consume_token (parser); + count++; + str.text = (const unsigned char *) TREE_STRING_POINTER (string_tree); + str.len = TREE_STRING_LENGTH (string_tree); + if (type != tok->type) + { + if (type == CPP_STRING) + type = tok->type; + else if (tok->type != CPP_STRING) + error ("unsupported non-standard concatenation " + "of string literals"); + } + obstack_grow (&str_ob, &str, sizeof (cpp_string)); + obstack_grow (&loc_ob, &last_tok_loc, sizeof (location_t)); + tok = c_parser_peek_token (parser); + string_tree = tok->value; + last_tok_loc + = linemap_resolve_location (line_table, tok->location, + LRK_MACRO_DEFINITION_LOCATION, NULL); + } + while (tok->type == CPP_STRING + || tok->type == CPP_WSTRING + || tok->type == CPP_STRING16 + || tok->type == CPP_STRING32 + || tok->type == CPP_UTF8STRING); + strs = (cpp_string *) obstack_finish (&str_ob); + } + + if (count > 1 && !in_system_header_at (input_location)) + warning (OPT_Wtraditional, + "traditional C rejects string constant concatenation"); + + if ((type == CPP_STRING || wide_ok) + && ((translate + ? cpp_interpret_string : cpp_interpret_string_notranslate) + (parse_in, strs, count, &istr, type))) + { + value = build_string (istr.len, (const char *) istr.text); + free (CONST_CAST (unsigned char *, istr.text)); + if (count > 1) + { + location_t *locs = (location_t *) obstack_finish (&loc_ob); + gcc_assert (g_string_concat_db); + g_string_concat_db->record_string_concatenation (count, locs); + } + } + else + { + if (type != CPP_STRING && !wide_ok) + { + error_at (loc, "a wide string is invalid in this context"); + type = CPP_STRING; + } + /* Callers cannot generally handle error_mark_node in this + context, so return the empty string instead. An error has + been issued, either above or from cpp_interpret_string. */ + switch (type) + { + default: + case CPP_STRING: + case CPP_UTF8STRING: + value = build_string (1, ""); + break; + case CPP_STRING16: + value = build_string (TYPE_PRECISION (char16_type_node) + / TYPE_PRECISION (char_type_node), + "\0"); /* char16_t is 16 bits */ + break; + case CPP_STRING32: + value = build_string (TYPE_PRECISION (char32_type_node) + / TYPE_PRECISION (char_type_node), + "\0\0\0"); /* char32_t is 32 bits */ + break; + case CPP_WSTRING: + value = build_string (TYPE_PRECISION (wchar_type_node) + / TYPE_PRECISION (char_type_node), + "\0\0\0"); /* widest supported wchar_t + is 32 bits */ + break; + } + } + + switch (type) + { + default: + case CPP_STRING: + case CPP_UTF8STRING: + TREE_TYPE (value) = char_array_type_node; + break; + case CPP_STRING16: + TREE_TYPE (value) = char16_array_type_node; + break; + case CPP_STRING32: + TREE_TYPE (value) = char32_array_type_node; + break; + case CPP_WSTRING: + TREE_TYPE (value) = wchar_array_type_node; + } + value = fix_string_type (value); + + if (count > 1) + { + obstack_free (&str_ob, 0); + obstack_free (&loc_ob, 0); + } + + ret.value = value; + ret.original_code = STRING_CST; + ret.original_type = NULL_TREE; + set_c_expr_source_range (&ret, get_range_from_loc (line_table, loc)); + return ret; +} + /* Parse an expression other than a compound expression; that is, an assignment expression (C90 6.3.16, C99 6.5.16, C11 6.5.16). If AFTER is not NULL then it is an Objective-C message expression which @@ -7700,14 +7845,14 @@ c_parser_has_attribute_expression (c_parser *parser) return result; } - parser->lex_untranslated_string = true; + bool save_translate_strings_p = parser->translate_strings_p; location_t atloc = c_parser_peek_token (parser)->location; /* Parse a single attribute. Require no leading comma and do not allow empty attributes. */ tree attr = c_parser_gnu_attribute (parser, NULL_TREE, false, false); - parser->lex_untranslated_string = false; + parser->translate_strings_p = save_translate_strings_p; if (c_parser_next_token_is (parser, CPP_CLOSE_PAREN)) c_parser_consume_token (parser); @@ -8202,10 +8347,8 @@ c_parser_postfix_expression (c_parser *parser) case CPP_STRING32: case CPP_WSTRING: case CPP_UTF8STRING: - expr.value = c_parser_peek_token (parser)->value; - set_c_expr_source_range (&expr, tok_range); - expr.original_code = STRING_CST; - c_parser_consume_token (parser); + expr = c_parser_string_literal (parser, parser->translate_strings_p, + true); break; case CPP_OBJC_STRING: gcc_assert (c_dialect_objc ()); @@ -11687,6 +11830,8 @@ pragma_lex (tree *value, location_t *loc) if (ret == CPP_PRAGMA_EOL || ret == CPP_EOF) ret = CPP_EOF; + else if (ret == CPP_STRING) + *value = c_parser_string_literal (the_parser, false, false).value; else { if (ret == CPP_KEYWORD) @@ -11702,6 +11847,7 @@ c_parser_pragma_pch_preprocess (c_parser *parser) { tree name = NULL; + parser->lex_joined_string = true; c_parser_consume_pragma (parser); if (c_parser_next_token_is (parser, CPP_STRING)) { @@ -11711,6 +11857,7 @@ c_parser_pragma_pch_preprocess (c_parser *parser) else c_parser_error (parser, "expected string literal"); c_parser_skip_to_pragma_eol (parser); + parser->lex_joined_string = false; if (name) c_common_pch_pragma (parse_in, TREE_STRING_POINTER (name)); @@ -20783,6 +20930,7 @@ c_parse_file (void) c_parser tparser; memset (&tparser, 0, sizeof tparser); + tparser.translate_strings_p = true; tparser.tokens = &tparser.tokens_buf[0]; the_parser = &tparser; diff --git a/gcc/c/c-parser.h b/gcc/c/c-parser.h index 7a30e30ac60..641da2fce39 100644 --- a/gcc/c/c-parser.h +++ b/gcc/c/c-parser.h @@ -185,6 +185,7 @@ c_parser_next_token_is_keyword (c_parser *parser, enum rid keyword) return c_parser_peek_token (parser)->keyword == keyword; } +struct c_expr c_parser_string_literal (c_parser *, bool, bool); extern struct c_declarator * c_parser_declarator (c_parser *parser, bool type_seen_p, c_dtr_syn kind, bool *seen_id); diff --git a/gcc/c/gimple-parser.c b/gcc/c/gimple-parser.c index d8588d47462..ceec758ffbe 100644 --- a/gcc/c/gimple-parser.c +++ b/gcc/c/gimple-parser.c @@ -1406,10 +1406,7 @@ c_parser_gimple_postfix_expression (gimple_parser &parser) case CPP_STRING32: case CPP_WSTRING: case CPP_UTF8STRING: - expr.value = c_parser_peek_token (parser)->value; - set_c_expr_source_range (&expr, tok_range); - expr.original_code = STRING_CST; - c_parser_consume_token (parser); + expr = c_parser_string_literal (parser, false, true); break; case CPP_DOT: expr = c_parser_gimple_call_internal (parser); @@ -1926,8 +1923,8 @@ c_parser_gimple_or_rtl_pass_list (c_parser *parser, c_declspecs *specs) return; } pass = xstrdup (TREE_STRING_POINTER - (c_parser_peek_token (parser)->value)); - c_parser_consume_token (parser); + (c_parser_string_literal (parser, false, + false).value)); if (! c_parser_require (parser, CPP_CLOSE_PAREN, "expected %<(%>")) return; } diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog index 473f66f26b7..e40445337f6 100644 --- a/gcc/testsuite/ChangeLog +++ b/gcc/testsuite/ChangeLog @@ -1,3 +1,10 @@ +2019-11-07 Joseph Myers + + * gcc.dg/asm-wide-1.c, gcc.dg/diagnostic-token-ranges.c, + gcc.dg/plugin/diagnostic-test-string-literals-1.c, + gcc.dg/plugin/diagnostic-test-string-literals-2.c: Update expected + diagnostics. + 2019-11-06 Iain Sandoe * gcc.dg/framework-1.c: Adjust test header path. diff --git a/gcc/testsuite/gcc.dg/asm-wide-1.c b/gcc/testsuite/gcc.dg/asm-wide-1.c index 88bbaed7f16..5ddc4c7d9cf 100644 --- a/gcc/testsuite/gcc.dg/asm-wide-1.c +++ b/gcc/testsuite/gcc.dg/asm-wide-1.c @@ -3,29 +3,29 @@ /* { dg-do compile } */ /* { dg-options "" } */ -int foo asm (L"bar"); /* { dg-error "14:wide string literal in 'asm'" } */ +int foo asm (L"bar"); /* { dg-error "14:a wide string is invalid in this context" } */ -asm (L"foo"); /* { dg-error "6:wide string literal in 'asm'" } */ +asm (L"foo"); /* { dg-error "6:a wide string is invalid in this context" } */ void f (void) { int x = 1; - asm (L"foo"); /* { dg-error "8:wide string literal in 'asm'" } */ + asm (L"foo"); /* { dg-error "8:a wide string is invalid in this context" } */ asm ("foo" : - L"=g" (x)); /* { dg-error "8:wide string literal in 'asm'" } */ + L"=g" (x)); /* { dg-error "8:a wide string is invalid in this context" } */ /* Extra errors from the substitution of "" for wide strings: */ /* { dg-error "output" "output" { target *-*-* } .-2 } */ asm ("foo" : [x] - L"=g" (x)); /* { dg-error "8:wide string literal in 'asm'" } */ + L"=g" (x)); /* { dg-error "8:a wide string is invalid in this context" } */ /* { dg-error "output" "output" { target *-*-* } .-1 } */ asm ("foo" : [x] "=g" (x), - L"=g" (x)); /* { dg-error "8:wide string literal in 'asm'" } */ + L"=g" (x)); /* { dg-error "8:a wide string is invalid in this context" } */ /* { dg-error "output" "output" { target *-*-* } .-1 } */ asm ("foo" : : - L"g" (x)); /* { dg-error "8:wide string literal in 'asm'" } */ + L"g" (x)); /* { dg-error "8:a wide string is invalid in this context" } */ asm ("foo" : : : - L"memory"); /* { dg-error "8:wide string literal in 'asm'" } */ + L"memory"); /* { dg-error "8:a wide string is invalid in this context" } */ asm ("foo" : : : "memory", - L"memory"); /* { dg-error "8:wide string literal in 'asm'" } */ + L"memory"); /* { dg-error "8:a wide string is invalid in this context" } */ } diff --git a/gcc/testsuite/gcc.dg/diagnostic-token-ranges.c b/gcc/testsuite/gcc.dg/diagnostic-token-ranges.c index 406bd323cc8..7d7ec0a9e0b 100644 --- a/gcc/testsuite/gcc.dg/diagnostic-token-ranges.c +++ b/gcc/testsuite/gcc.dg/diagnostic-token-ranges.c @@ -67,7 +67,7 @@ foo (unknown_type param); /* { dg-error "unknown type name 'unknown_type'" } */ void wide_string_literal_in_asm (void) { - __asm (L"nop"); /* { dg-error "wide string literal in 'asm'" } */ + __asm (L"nop"); /* { dg-error "a wide string is invalid in this context" } */ /* { dg-begin-multiline-output "" } __asm (L"nop"); diff --git a/gcc/testsuite/gcc.dg/plugin/diagnostic-test-string-literals-1.c b/gcc/testsuite/gcc.dg/plugin/diagnostic-test-string-literals-1.c index 36324fda43c..ac4fa1b52bd 100644 --- a/gcc/testsuite/gcc.dg/plugin/diagnostic-test-string-literals-1.c +++ b/gcc/testsuite/gcc.dg/plugin/diagnostic-test-string-literals-1.c @@ -332,7 +332,8 @@ pr87652 (const char *stem, int counter) OFFSET + end_idx); \ } while (0) -/* { dg-error "unable to read substring location: failed to get ordinary maps" "" { target *-*-* } 329 } */ +/* { dg-error "unable to read substring location: unable to read source line" "" { target c } 329 } */ +/* { dg-error "unable to read substring location: failed to get ordinary maps" "" { target c++ } 329 } */ /* { dg-begin-multiline-output "" } __emit_string_literal_range(__FILE__":%5d: " format, \ ^~~~~~~~ diff --git a/gcc/testsuite/gcc.dg/plugin/diagnostic-test-string-literals-2.c b/gcc/testsuite/gcc.dg/plugin/diagnostic-test-string-literals-2.c index 260c47d3401..3e855b3cca0 100644 --- a/gcc/testsuite/gcc.dg/plugin/diagnostic-test-string-literals-2.c +++ b/gcc/testsuite/gcc.dg/plugin/diagnostic-test-string-literals-2.c @@ -69,7 +69,8 @@ test_pr79210 (void) "some multiline blurb with a short final line " "here"); - /* { dg-error "19: unable to read substring location: line is not wide enough" "" { target *-*-* } .-11 } */ + /* { dg-error "19: unable to read substring location: range endpoints are on different lines" "" { target c } .-11 } */ + /* { dg-error "19: unable to read substring location: line is not wide enough" "" { target c++ } .-12 } */ #undef LPFC_VPORT_ATTR_R #undef lpfc_vport_param_init -- 2.30.2