diff options
author | SimplyTheOther <simplytheother@gmail.com> | 2020-09-25 17:48:56 +0800 |
---|---|---|
committer | Philip Herron <philip.herron@embecosm.com> | 2020-11-28 21:13:21 +0000 |
commit | 636b1630184a37a9d5647cff19103bca34c8f125 (patch) | |
tree | 516de1905cac342736b81a943e0a9390dda4e882 /gcc | |
parent | c7440d88c72dc33ca8a50b96b8f5b13c90f9e0bf (diff) | |
download | gcc-636b1630184a37a9d5647cff19103bca34c8f125.zip gcc-636b1630184a37a9d5647cff19103bca34c8f125.tar.gz gcc-636b1630184a37a9d5647cff19103bca34c8f125.tar.bz2 |
Attempt to significantly reduce warning count by modifying error message format
Diffstat (limited to 'gcc')
-rw-r--r-- | gcc/rust/lex/rust-lex.cc | 68 | ||||
-rw-r--r-- | gcc/rust/parse/rust-parse-impl.h | 561 | ||||
-rw-r--r-- | gcc/rust/rust-session-manager.cc | 256 |
3 files changed, 457 insertions, 428 deletions
diff --git a/gcc/rust/lex/rust-lex.cc b/gcc/rust/lex/rust-lex.cc index 019e922..f45f168 100644 --- a/gcc/rust/lex/rust-lex.cc +++ b/gcc/rust/lex/rust-lex.cc @@ -683,8 +683,8 @@ Lexer::build_token () else /*if (!ISDIGIT (peek_input ()))*/ { // single dot . - // Only if followed by a non-number - otherwise is float - // nope, float cannot start with '.'. + // Only if followed by a non-number - otherwise is float + // nope, float cannot start with '.'. current_column++; return Token::make (DOT, loc); } @@ -730,7 +730,8 @@ Lexer::build_token () // int and float literals if (ISDIGIT (current_char)) { // _ not allowed as first char - if (current_char == '0' && is_non_decimal_int_literal_separator (peek_input ())) + if (current_char == '0' + && is_non_decimal_int_literal_separator (peek_input ())) { // handle binary, octal, hex literals TokenPtr non_dec_int_lit_ptr @@ -761,14 +762,15 @@ Lexer::build_token () // DEBUG: check for specific character problems: if (current_char == '0') - fprintf(stderr, "'0' uncaught before unexpected character\n"); + fprintf (stderr, "'0' uncaught before unexpected character\n"); else if (current_char == ']') - fprintf(stderr, "']' uncaught before unexpected character\n"); + fprintf (stderr, "']' uncaught before unexpected character\n"); else if (current_char == 0x5d) - fprintf(stderr, "whatever 0x5d is (not '0' or ']') uncaught before unexpected character\n"); + fprintf (stderr, "whatever 0x5d is (not '0' or ']') uncaught before " + "unexpected character\n"); // didn't match anything so error - rust_error_at (loc, "unexpected character '%x'", current_char); + rust_error_at (loc, "unexpected character %<%x%>", current_char); current_column++; } } @@ -867,7 +869,7 @@ Lexer::parse_in_type_suffix () } else { - rust_error_at (get_current_location (), "unknown number suffix '%s'", + rust_error_at (get_current_location (), "unknown number suffix %<%s%>", suffix.c_str ()); return std::make_pair (CORETYPE_UNKNOWN, additional_length_offset); @@ -967,7 +969,7 @@ Lexer::parse_escape (char opening_char) if (hexLong > 255 || hexLong < 0) rust_error_at ( get_current_location (), - "byte \\x escape '\\x%X' out of range - allows up to '\\xFF'", + "byte \\x escape %<\\x%X%> out of range - allows up to %<\\xFF%>", static_cast<unsigned int> (hexLong)); char hexChar = static_cast<char> (hexLong); @@ -1005,8 +1007,8 @@ Lexer::parse_escape (char opening_char) // string continue return std::make_tuple (0, parse_partial_string_continue (), true); default: - rust_error_at (get_current_location (), "unknown escape sequence '\\%c'", - current_char); + rust_error_at (get_current_location (), + "unknown escape sequence %<\\%c%>", current_char); // returns false if no parsing could be done // return false; return std::make_tuple (output_char, additional_length_offset, false); @@ -1045,7 +1047,7 @@ Lexer::parse_utf8_escape (char opening_char) if (hexLong > 127 || hexLong < 0) rust_error_at ( get_current_location (), - "ascii \\x escape '\\x%X' out of range - allows up to '\\x7F'", + "ascii \\x escape %<\\x%X%> out of range - allows up to %<\\x7F%>", static_cast<unsigned int> (hexLong)); char hexChar = static_cast<char> (hexLong); @@ -1086,8 +1088,8 @@ Lexer::parse_utf8_escape (char opening_char) // string continue return std::make_tuple (0, parse_partial_string_continue (), true); default: - rust_error_at (get_current_location (), "unknown escape sequence '\\%c'", - current_char); + rust_error_at (get_current_location (), + "unknown escape sequence %<\\%c%>", current_char); // returns false if no parsing could be done // return false; return std::make_tuple (output_char, additional_length_offset, false); @@ -1154,7 +1156,8 @@ Lexer::parse_partial_hex_escape () if (!is_x_digit (current_char)) { rust_error_at (get_current_location (), - "invalid character '\\x%c' in \\x sequence", current_char); + "invalid character %<\\x%c%> in \\x sequence", + current_char); } hexNum[0] = current_char; @@ -1166,7 +1169,8 @@ Lexer::parse_partial_hex_escape () if (!is_x_digit (current_char)) { rust_error_at (get_current_location (), - "invalid character '\\x%c' in \\x sequence", current_char); + "invalid character %<\\x%c%> in \\x sequence", + current_char); } hexNum[1] = current_char; @@ -1233,7 +1237,7 @@ Lexer::parse_partial_unicode_escape () { // actually an error, but allow propagation anyway rust_error_at (get_current_location (), - "expected terminating '}' in unicode escape"); + "expected terminating %<}%> in unicode escape"); // return false; return std::make_pair (Codepoint (0), additional_length_offset); } @@ -1283,8 +1287,8 @@ Lexer::parse_byte_char (Location loc) if (byte_char > 127) { - rust_error_at (get_current_location (), "byte char '%c' out of range", - byte_char); + rust_error_at (get_current_location (), + "byte char %<%c%> out of range", byte_char); byte_char = 0; } @@ -1320,7 +1324,7 @@ Lexer::parse_byte_char (Location loc) else { rust_error_at (get_current_location (), - "no character inside '' for byte char"); + "no character inside %<%> for byte char"); } current_column += length; @@ -1359,7 +1363,7 @@ Lexer::parse_byte_string (Location loc) if (output_char > 127) { rust_error_at (get_current_location (), - "char '%c' in byte string out of range", + "char %<%c%> in byte string out of range", output_char); output_char = 0; } @@ -1427,7 +1431,7 @@ Lexer::parse_raw_byte_string (Location loc) if (current_char != '"') { rust_error_at (get_current_location (), - "raw byte string has no opening '\"'"); + "raw byte string has no opening %<\"%>"); } skip_input (); @@ -1508,13 +1512,13 @@ Lexer::parse_raw_identifier (Location loc) // if just a single underscore, not an identifier if (first_is_underscore && length == 1) rust_error_at (get_current_location (), - "'_' is not a valid raw identifier"); + "%<_%> is not a valid raw identifier"); if (str == "crate" || str == "extern" || str == "self" || str == "super" || str == "Self") { rust_error_at (get_current_location (), - "'%s' is a forbidden raw identifier", str.c_str ()); + "%<%s%> is a forbidden raw identifier", str.c_str ()); return nullptr; } @@ -1657,7 +1661,7 @@ Lexer::parse_raw_string (Location loc, int initial_hash_count) current_char = peek_input (); if (current_char != '"') - rust_error_at (get_current_location (), "raw string has no opening '\"'"); + rust_error_at (get_current_location (), "raw string has no opening %<\"%>"); length++; skip_input (); @@ -1751,7 +1755,7 @@ Lexer::parse_non_decimal_int_literal (Location loc, IsDigitFunc is_digit_func, if (type_hint == CORETYPE_F32 || type_hint == CORETYPE_F64) { rust_error_at (get_current_location (), - "invalid type suffix '%s' for integer (%s) literal", + "invalid type suffix %<%s%> for integer (%s) literal", get_type_hint_string (type_hint), base == 16 ? "hex" @@ -1843,7 +1847,7 @@ Lexer::parse_decimal_int_or_float (Location loc) && type_hint != CORETYPE_UNKNOWN) { rust_error_at (get_current_location (), - "invalid type suffix '%s' for float literal", + "invalid type suffix %<%s%> for float literal", get_type_hint_string (type_hint)); // ignore invalid type suffix as everything else seems fine type_hint = CORETYPE_UNKNOWN; @@ -1892,7 +1896,7 @@ Lexer::parse_decimal_int_or_float (Location loc) && type_hint != CORETYPE_UNKNOWN) { rust_error_at (get_current_location (), - "invalid type suffix '%s' for float literal", + "invalid type suffix %<%s%> for float literal", get_type_hint_string (type_hint)); // ignore invalid type suffix as everything else seems fine type_hint = CORETYPE_UNKNOWN; @@ -1914,10 +1918,10 @@ Lexer::parse_decimal_int_or_float (Location loc) if (type_hint == CORETYPE_F32 || type_hint == CORETYPE_F64) { - rust_error_at (get_current_location (), - "invalid type suffix '%s' for integer " - "(decimal) literal", - get_type_hint_string (type_hint)); + rust_error_at ( + get_current_location (), + "invalid type suffix %<%s%> for integer (decimal) literal", + get_type_hint_string (type_hint)); // ignore invalid type suffix as everything else seems fine type_hint = CORETYPE_UNKNOWN; } diff --git a/gcc/rust/parse/rust-parse-impl.h b/gcc/rust/parse/rust-parse-impl.h index 72957df..51ff16e 100644 --- a/gcc/rust/parse/rust-parse-impl.h +++ b/gcc/rust/parse/rust-parse-impl.h @@ -238,7 +238,7 @@ Parser<ManagedTokenSource>::skip_generics_right_angle () } default: rust_error_at (tok->get_locus (), - "expected '>' at end of generic argument - found '%s'", + "expected %<>%> at end of generic argument - found %<%s%>", tok->get_token_description ()); return false; } @@ -583,8 +583,7 @@ Parser<ManagedTokenSource>::parse_simple_path () { fprintf (stderr, "when parsing simple path, somehow empty path segment was " - "not filtered out. Path " - "begins with '%s' \n", + "not filtered out. Path begins with '%s' \n", segments.at (0).as_string ().c_str ()); } } @@ -629,8 +628,8 @@ Parser<ManagedTokenSource>::parse_simple_path_segment () gcc_fallthrough (); default: // do nothing but inactivates warning from gcc when compiling - // could put the rust_error_at thing here but fallthrough (from failing - // $crate condition) isn't completely obvious if it is. + /* could put the rust_error_at thing here but fallthrough (from failing + * $crate condition) isn't completely obvious if it is. */ // test prevent error return AST::SimplePathSegment::create_error (); @@ -722,7 +721,7 @@ Parser<ManagedTokenSource>::parse_attr_input () { rust_error_at ( t->get_locus (), - "unknown token '%s' in attribute body - literal expected", + "unknown token %<%s%> in attribute body - literal expected", t->get_token_description ()); skip_after_end_attribute (); return nullptr; @@ -771,7 +770,7 @@ Parser<ManagedTokenSource>::parse_attr_input () return nullptr; default: rust_error_at (t->get_locus (), - "unknown token '%s' in attribute body - attribute input " + "unknown token %<%s%> in attribute body - attribute input " "or none expected", t->get_token_description ()); skip_after_end_attribute (); @@ -838,7 +837,7 @@ Parser<ManagedTokenSource>::parse_delim_token_tree () break; default: rust_error_at (t->get_locus (), - "unexpected token '%s' - expecting delimiters (for a " + "unexpected token %<%s%> - expecting delimiters (for a " "delimited token tree)", t->get_token_description ()); return AST::DelimTokenTree::create_empty (); @@ -858,7 +857,7 @@ Parser<ManagedTokenSource>::parse_delim_token_tree () // TODO: is this error handling appropriate? rust_error_at ( t->get_locus (), - "failed to parse token tree in delimited token tree - found '%s'", + "failed to parse token tree in delimited token tree - found %<%s%>", t->get_token_description ()); return AST::DelimTokenTree::create_empty (); } @@ -892,13 +891,13 @@ Parser<ManagedTokenSource>::parse_delim_token_tree () else { // tokens don't match opening delimiters, so produce error - rust_error_at (t->get_locus (), - "unexpected token '%s' - expecting closing delimiter '%s' " - "(for a delimited token tree)", - t->get_token_description (), - (delim_type == AST::PARENS - ? ")" - : (delim_type == AST::SQUARE ? "]" : "}"))); + rust_error_at ( + t->get_locus (), + "unexpected token %<%s%> - expecting closing delimiter %<%s%> " + "(for a delimited token tree)", + t->get_token_description (), + (delim_type == AST::PARENS ? ")" + : (delim_type == AST::SQUARE ? "]" : "}"))); /* return empty token tree despite possibly parsing valid token tree - * TODO is this a good idea? */ @@ -927,11 +926,11 @@ Parser<ManagedTokenSource>::parse_token_tree () case RIGHT_SQUARE: case RIGHT_CURLY: // error - should not be called when this a token - rust_error_at (t->get_locus (), - "unexpected closing delimiter '%s' - token tree requires " - "either paired delimiters " - "or non-delimiter tokens", - t->get_token_description ()); + rust_error_at ( + t->get_locus (), + "unexpected closing delimiter %<%s%> - token tree requires " + "either paired delimiters or non-delimiter tokens", + t->get_token_description ()); lexer.skip_token (); return nullptr; default: @@ -983,8 +982,8 @@ Parser<ManagedTokenSource>::parse_item (bool called_from_statement) std::vector<AST::Attribute> outer_attrs = parse_outer_attributes (); // TODO: decide how to deal with VisItem vs MacroItem dichotomy - // best current solution: catch all keywords that would imply a VisItem in a - // switch and have MacroItem as a last resort + /* best current solution: catch all keywords that would imply a VisItem in a + * switch and have MacroItem as a last resort */ const_TokenPtr t = lexer.peek_token (); @@ -1037,8 +1036,8 @@ Parser<ManagedTokenSource>::parse_item (bool called_from_statement) else if (lexer.peek_token (1)->get_id () == SCOPE_RESOLUTION || lexer.peek_token (1)->get_id () == EXCLAM) { - // path (probably) or macro invocation, so probably a macro invocation - // semi + /* path (probably) or macro invocation, so probably a macro invocation + * semi */ return parse_macro_item (std::move (outer_attrs)); } gcc_fallthrough (); @@ -1046,7 +1045,8 @@ Parser<ManagedTokenSource>::parse_item (bool called_from_statement) default: // otherwise unrecognised // return parse_macro_item(std::move(outer_attrs)); - rust_error_at (t->get_locus (), "unrecognised token '%s' for start of %s", + rust_error_at (t->get_locus (), + "unrecognised token %<%s%> for start of %s", t->get_token_description (), called_from_statement ? "statement" : "item"); // skip somewhere? @@ -1066,8 +1066,8 @@ Parser<ManagedTokenSource>::parse_outer_attributes () { AST::Attribute outer_attr = parse_outer_attribute (); - // Ensure only valid outer attributes are added to the outer_attributes - // list + /* Ensure only valid outer attributes are added to the outer_attributes + * list */ if (!outer_attr.is_empty ()) { outer_attributes.push_back (std::move (outer_attr)); @@ -1104,10 +1104,10 @@ Parser<ManagedTokenSource>::parse_outer_attribute () if (id == EXCLAM) { // this is inner attribute syntax, so throw error - rust_error_at (lexer.peek_token ()->get_locus (), - "token '!' found, indicating inner attribute " - "definition. Inner attributes are not " - "possible at this location."); + rust_error_at ( + lexer.peek_token ()->get_locus (), + "token %<!%> found, indicating inner attribute definition. Inner " + "attributes are not possible at this location"); } // TODO: are there any cases where this wouldn't be an error? return AST::Attribute::create_empty (); } @@ -1166,7 +1166,7 @@ Parser<ManagedTokenSource>::parse_vis_item ( default: rust_error_at ( t->get_locus (), - "unexpected token '%s' in some sort of extern production", + "unexpected token %<%s%> in some sort of extern production", t->get_token_description ()); lexer.skip_token (2); // TODO: is this right thing to do? return nullptr; @@ -1174,7 +1174,7 @@ Parser<ManagedTokenSource>::parse_vis_item ( default: rust_error_at ( t->get_locus (), - "unexpected token '%s' in some sort of extern production", + "unexpected token %<%s%> in some sort of extern production", t->get_token_description ()); lexer.skip_token (1); // TODO: is this right thing to do? return nullptr; @@ -1218,7 +1218,7 @@ Parser<ManagedTokenSource>::parse_vis_item ( default: rust_error_at ( t->get_locus (), - "unexpected token '%s' in some sort of const production", + "unexpected token %<%s%> in some sort of const production", t->get_token_description ()); lexer.skip_token (1); // TODO: is this right thing to do? return nullptr; @@ -1245,7 +1245,7 @@ Parser<ManagedTokenSource>::parse_vis_item ( default: rust_error_at ( t->get_locus (), - "unexpected token '%s' in some sort of unsafe production", + "unexpected token %<%s%> in some sort of unsafe production", t->get_token_description ()); lexer.skip_token (1); // TODO: is this right thing to do? return nullptr; @@ -1290,8 +1290,7 @@ Parser<ManagedTokenSource>::parse_macro_item ( { fprintf (stderr, "just add to last error: token is not macro_rules and is " - "not an identifier either " - "- it is '%s'", + "not an identifier either - it is '%s'", t->get_token_description ()); } @@ -1311,7 +1310,7 @@ Parser<ManagedTokenSource>::parse_macro_rules_def ( { rust_error_at ( t->get_locus (), - "macro rules definition does not start with 'macro_rules'"); + "macro rules definition does not start with %<macro_rules%>"); // skip after somewhere? return nullptr; } @@ -1353,7 +1352,7 @@ Parser<ManagedTokenSource>::parse_macro_rules_def ( break; default: rust_error_at (t->get_locus (), - "unexpected token '%s' - expecting delimiters (for a " + "unexpected token %<%s%> - expecting delimiters (for a " "macro rules definition)", t->get_token_description ()); return nullptr; @@ -1442,14 +1441,13 @@ Parser<ManagedTokenSource>::parse_macro_rules_def ( else { // tokens don't match opening delimiters, so produce error - rust_error_at (t->get_locus (), - "unexpected token '%s' - expecting closing delimiter '%s' " - "(for a macro rules " - "definition)", - t->get_token_description (), - (delim_type == AST::PARENS - ? ")" - : (delim_type == AST::SQUARE ? "]" : "}"))); + rust_error_at ( + t->get_locus (), + "unexpected token %<%s%> - expecting closing delimiter %<%s%> " + "(for a macro rules definition)", + t->get_token_description (), + (delim_type == AST::PARENS ? ")" + : (delim_type == AST::SQUARE ? "]" : "}"))); /* return empty macro definiton despite possibly parsing mostly valid one * - TODO is this a good idea? */ @@ -1490,7 +1488,7 @@ Parser<ManagedTokenSource>::parse_macro_invocation_semi ( break; default: rust_error_at (t->get_locus (), - "unexpected token '%s' - expecting delimiters (for a " + "unexpected token %<%s%> - expecting delimiters (for a " "macro invocation semi body)", t->get_token_description ()); return nullptr; @@ -1508,10 +1506,10 @@ Parser<ManagedTokenSource>::parse_macro_invocation_semi ( if (tree == nullptr) { - rust_error_at ( - t->get_locus (), - "failed to parse token tree for macro invocation semi - found '%s'", - t->get_token_description ()); + rust_error_at (t->get_locus (), + "failed to parse token tree for macro invocation semi " + "- found %<%s%>", + t->get_token_description ()); return nullptr; } @@ -1555,14 +1553,13 @@ Parser<ManagedTokenSource>::parse_macro_invocation_semi ( else { // tokens don't match opening delimiters, so produce error - rust_error_at (t->get_locus (), - "unexpected token '%s' - expecting closing delimiter '%s' " - "(for a macro invocation " - "semi)", - t->get_token_description (), - (delim_type == AST::PARENS - ? ")" - : (delim_type == AST::SQUARE ? "]" : "}"))); + rust_error_at ( + t->get_locus (), + "unexpected token %<%s%> - expecting closing delimiter %<%s%> " + "(for a macro invocation semi)", + t->get_token_description (), + (delim_type == AST::PARENS ? ")" + : (delim_type == AST::SQUARE ? "]" : "}"))); /* return empty macro invocation despite possibly parsing mostly valid one * - TODO is this a good idea? */ @@ -1612,9 +1609,7 @@ Parser<ManagedTokenSource>::parse_macro_rule () AST::MacroMatcher matcher = parse_macro_matcher (); if (matcher.is_error ()) - { - return AST::MacroRule::create_error (); - } + return AST::MacroRule::create_error (); if (!skip_token (MATCH_ARROW)) { @@ -1655,7 +1650,7 @@ Parser<ManagedTokenSource>::parse_macro_matcher () default: rust_error_at ( t->get_locus (), - "unexpected token '%s' - expecting delimiters (for a macro matcher)", + "unexpected token %<%s%> - expecting delimiters (for a macro matcher)", t->get_token_description ()); return AST::MacroMatcher::create_error (); } @@ -1674,7 +1669,7 @@ Parser<ManagedTokenSource>::parse_macro_matcher () { rust_error_at ( t->get_locus (), - "failed to parse macro match for macro matcher - found '%s'", + "failed to parse macro match for macro matcher - found %<%s%>", t->get_token_description ()); return AST::MacroMatcher::create_error (); } @@ -1699,13 +1694,13 @@ Parser<ManagedTokenSource>::parse_macro_matcher () else { // tokens don't match opening delimiters, so produce error - rust_error_at (t->get_locus (), - "unexpected token '%s' - expecting closing delimiter '%s' " - "(for a macro matcher)", - t->get_token_description (), - (delim_type == AST::PARENS - ? ")" - : (delim_type == AST::SQUARE ? "]" : "}"))); + rust_error_at ( + t->get_locus (), + "unexpected token %<%s%> - expecting closing delimiter %<%s%> " + "(for a macro matcher)", + t->get_token_description (), + (delim_type == AST::PARENS ? ")" + : (delim_type == AST::SQUARE ? "]" : "}"))); /* return error macro matcher despite possibly parsing mostly correct one? * TODO is this the best idea? */ @@ -1749,11 +1744,11 @@ Parser<ManagedTokenSource>::parse_macro_match () return parse_macro_match_repetition (); default: // error: unrecognised - rust_error_at (t2->get_locus (), - "unrecognised token combination '$%s' at start of " - "macro match - did you " - "mean '$identifier' or '$('?", - t2->get_token_description ()); + rust_error_at ( + t2->get_locus (), + "unrecognised token combination %<$%s%> at start of " + "macro match - did you mean %<$identifier%> or %<$(%>?", + t2->get_token_description ()); // skip somewhere? return nullptr; } @@ -1763,7 +1758,7 @@ Parser<ManagedTokenSource>::parse_macro_match () case RIGHT_CURLY: // not allowed rust_error_at (t->get_locus (), - "closing delimiters like '%s' are not allowed at the " + "closing delimiters like %<%s%> are not allowed at the " "start of a macro match", t->get_token_description ()); // skip somewhere? @@ -1802,9 +1797,10 @@ Parser<ManagedTokenSource>::parse_macro_match_fragment () AST::MacroFragSpec frag = AST::get_frag_spec_from_str (t->get_str ()); if (frag == AST::INVALID) { - rust_error_at (t->get_locus (), - "invalid fragment specifier '%s' in fragment macro match", - t->get_str ().c_str ()); + rust_error_at ( + t->get_locus (), + "invalid fragment specifier %<%s%> in fragment macro match", + t->get_str ().c_str ()); return nullptr; } @@ -1903,10 +1899,11 @@ Parser<ManagedTokenSource>::parse_macro_match_repetition () lexer.skip_token (); break; default: - rust_error_at (t->get_locus (), - "expected macro repetition operator ('*', '+', or '?') in " - "macro match - found '%s'", - t->get_token_description ()); + rust_error_at ( + t->get_locus (), + "expected macro repetition operator (%<*%>, %<+%>, or %<?%>) in " + "macro match - found %<%s%>", + t->get_token_description ()); // skip after somewhere? return nullptr; } @@ -1979,7 +1976,7 @@ Parser<ManagedTokenSource>::parse_visibility () return AST::Visibility::create_in_path (std::move (path)); } default: - rust_error_at (t->get_locus (), "unexpected token '%s' in visibility", + rust_error_at (t->get_locus (), "unexpected token %<%s%> in visibility", t->get_token_description ()); lexer.skip_token (); return AST::Visibility::create_error (); @@ -2051,7 +2048,7 @@ Parser<ManagedTokenSource>::parse_module ( default: rust_error_at ( t->get_locus (), - "unexpected token '%s' in module declaration/definition item", + "unexpected token %<%s%> in module declaration/definition item", t->get_token_description ()); lexer.skip_token (); return nullptr; @@ -2093,9 +2090,10 @@ Parser<ManagedTokenSource>::parse_extern_crate ( lexer.skip_token (); break; default: - rust_error_at (crate_name_tok->get_locus (), - "expecting crate name (identifier or 'self'), found '%s'", - crate_name_tok->get_token_description ()); + rust_error_at ( + crate_name_tok->get_locus (), + "expecting crate name (identifier or %<self%>), found %<%s%>", + crate_name_tok->get_token_description ()); skip_after_semicolon (); return nullptr; } @@ -2132,9 +2130,10 @@ Parser<ManagedTokenSource>::parse_extern_crate ( lexer.skip_token (); break; default: - rust_error_at (as_name_tok->get_locus (), - "expecting as clause name (identifier or '_'), found '%s'", - as_name_tok->get_token_description ()); + rust_error_at ( + as_name_tok->get_locus (), + "expecting as clause name (identifier or %<_%>), found %<%s%>", + as_name_tok->get_token_description ()); skip_after_semicolon (); return nullptr; } @@ -2280,8 +2279,8 @@ Parser<ManagedTokenSource>::parse_use_tree () return nullptr; } - // TODO: find way to determine whether GLOBAL or NO_PATH path type - - // placeholder + /* TODO: find way to determine whether GLOBAL or NO_PATH path type - + * placeholder */ return std::unique_ptr<AST::UseTreeList> ( new AST::UseTreeList (AST::UseTreeList::NO_PATH, AST::SimplePath::create_empty (), @@ -2290,15 +2289,14 @@ Parser<ManagedTokenSource>::parse_use_tree () case AS: // this is not allowed rust_error_at (t->get_locus (), - "use declaration with rebind 'as' requires a valid " + "use declaration with rebind %<as%> requires a valid " "simple path - none found."); skip_after_semicolon (); return nullptr; default: rust_error_at (t->get_locus (), - "unexpected token '%s' in use tree with no valid " - "simple path (i.e. list or " - "glob use tree)", + "unexpected token %<%s%> in use tree with no valid " + "simple path (i.e. list or glob use tree)", t->get_token_description ()); skip_after_semicolon (); return nullptr; @@ -2382,11 +2380,11 @@ Parser<ManagedTokenSource>::parse_use_tree () std::move (path), locus, std::string ("_"))); default: - rust_error_at ( - t->get_locus (), - "unexpected token '%s' in use tree with as clause - expected " - "identifier or '_'", - t->get_token_description ()); + rust_error_at (t->get_locus (), + "unexpected token %<%s%> in use tree with as " + "clause - expected " + "identifier or %<_%>", + t->get_token_description ()); skip_after_semicolon (); return nullptr; } @@ -2408,7 +2406,7 @@ Parser<ManagedTokenSource>::parse_use_tree () locus)); default: rust_error_at (t->get_locus (), - "unexpected token '%s' in use tree with valid path", + "unexpected token %<%s%> in use tree with valid path", t->get_token_description ()); // skip_after_semicolon(); return nullptr; @@ -2766,8 +2764,7 @@ Parser<ManagedTokenSource>::parse_lifetime_params () { std::vector<std::unique_ptr<AST::LifetimeParam> > lifetime_params; - // if end_token is not specified, it defaults to EOF, so should work fine - while (lexer.peek_token ()->get_id () != end_token) + while (lexer.peek_token ()->get_id () != END_OF_FILE) { AST::LifetimeParam lifetime_param = parse_lifetime_param (); @@ -2781,7 +2778,7 @@ Parser<ManagedTokenSource>::parse_lifetime_params () new AST::LifetimeParam (std::move (lifetime_param)))); if (lexer.peek_token ()->get_id () != COMMA) - break; + break; // skip commas, including trailing commas lexer.skip_token (); @@ -2808,16 +2805,18 @@ Parser<ManagedTokenSource>::parse_lifetime_params (EndTokenPred is_end_token) if (lifetime_param.is_error ()) { - // TODO: is it worth throwing away all lifetime params just because one failed? - rust_error_at (lexer.peek_token ()->get_locus (), "failed to parse lifetime param in lifetime params"); - return {}; + // TODO: is it worth throwing away all lifetime params just because + // one failed? + rust_error_at (lexer.peek_token ()->get_locus (), + "failed to parse lifetime param in lifetime params"); + return {}; } lifetime_params.push_back (std::unique_ptr<AST::LifetimeParam> ( new AST::LifetimeParam (std::move (lifetime_param)))); if (lexer.peek_token ()->get_id () != COMMA) - break; + break; // skip commas, including trailing commas lexer.skip_token (); @@ -2844,14 +2843,14 @@ Parser<ManagedTokenSource>::parse_lifetime_params_objs () if (lifetime_param.is_error ()) { - // not an error as only way to exit if trailing comma + // not an error as only way to exit if trailing comma break; } lifetime_params.push_back (std::move (lifetime_param)); if (lexer.peek_token ()->get_id () != COMMA) - break; + break; // skip commas, including trailing commas lexer.skip_token (); @@ -2868,7 +2867,8 @@ Parser<ManagedTokenSource>::parse_lifetime_params_objs () template <typename ManagedTokenSource> template <typename EndTokenPred> std::vector<AST::LifetimeParam> -Parser<ManagedTokenSource>::parse_lifetime_params_objs (EndTokenPred is_end_token) +Parser<ManagedTokenSource>::parse_lifetime_params_objs ( + EndTokenPred is_end_token) { std::vector<AST::LifetimeParam> lifetime_params; @@ -2878,15 +2878,17 @@ Parser<ManagedTokenSource>::parse_lifetime_params_objs (EndTokenPred is_end_toke if (lifetime_param.is_error ()) { - // TODO: is it worth throwing away all lifetime params just because one failed? - rust_error_at (lexer.peek_token ()->get_locus (), "failed to parse lifetime param in lifetime params"); - return {}; + // TODO: is it worth throwing away all lifetime params just because + // one failed? + rust_error_at (lexer.peek_token ()->get_locus (), + "failed to parse lifetime param in lifetime params"); + return {}; } lifetime_params.push_back (std::move (lifetime_param)); if (lexer.peek_token ()->get_id () != COMMA) - break; + break; // skip commas, including trailing commas lexer.skip_token (); @@ -2897,15 +2899,17 @@ Parser<ManagedTokenSource>::parse_lifetime_params_objs (EndTokenPred is_end_toke return lifetime_params; } -/* Parses various types of generic parameters (templated). Will also consume any trailing - * comma. Has extra is_end_token predicate checking. +/* Parses various types of generic parameters (templated). Will also consume any + * trailing comma. Has extra is_end_token predicate checking. * TODO: is this best solution? implements most of the same algorithm. */ template <typename ManagedTokenSource> template <typename ParseFunction, typename EndTokenPred> auto -Parser<ManagedTokenSource>::parse_generic_params (ParseFunction parsing_function, EndTokenPred is_end_token, std::string error_msg) -> std::vector<decltype(parsing_function ())> +Parser<ManagedTokenSource>::parse_generic_params ( + ParseFunction parsing_function, EndTokenPred is_end_token, + std::string error_msg) -> std::vector<decltype (parsing_function ())> { - std::vector<decltype(parsing_function ())> params; + std::vector<decltype (parsing_function ())> params; while (!is_end_token (lexer.peek_token ()->get_id ())) { @@ -2913,15 +2917,15 @@ Parser<ManagedTokenSource>::parse_generic_params (ParseFunction parsing_function if (param.is_error ()) { - // TODO: is it worth throwing away all params just because one failed? - rust_error_at (lexer.peek_token ()->get_locus (), error_msg.c_str ()); - return {}; + // TODO: is it worth throwing away all params just because one failed? + rust_error_at (lexer.peek_token ()->get_locus (), error_msg.c_str ()); + return {}; } params.push_back (std::move (param)); if (lexer.peek_token ()->get_id () != COMMA) - break; + break; // skip commas, including trailing commas lexer.skip_token (); @@ -3305,7 +3309,8 @@ Parser<ManagedTokenSource>::parse_for_lifetimes () return params; } - // cannot specify end token due to parsing problems with '>' tokens being nested + // cannot specify end token due to parsing problems with '>' tokens being + // nested params = parse_lifetime_params_objs (is_right_angle_tok); if (!skip_generics_right_angle ()) @@ -3662,7 +3667,7 @@ Parser<ManagedTokenSource>::parse_struct ( std::move (outer_attrs), locus)); default: rust_error_at (t->get_locus (), - "unexpected token '%s' in struct declaration", + "unexpected token %<%s%> in struct declaration", t->get_token_description ()); // skip somewhere? return nullptr; @@ -4081,10 +4086,11 @@ Parser<ManagedTokenSource>::parse_const_item ( lexer.skip_token (); break; default: - rust_error_at (ident_tok->get_locus (), - "expected item name (identifier or '_') in constant item " - "declaration - found '%s'", - ident_tok->get_token_description ()); + rust_error_at ( + ident_tok->get_locus (), + "expected item name (identifier or %<_%>) in constant item " + "declaration - found %<%s%>", + ident_tok->get_token_description ()); skip_after_semicolon (); return nullptr; } @@ -4342,14 +4348,13 @@ Parser<ManagedTokenSource>::parse_trait_item () break; case LEFT_CURLY: definition = parse_block_expr (); - // FIXME: are these outer attributes meant to be passed into the - // block? + /* FIXME: are these outer attributes meant to be passed into the + * block? */ break; default: rust_error_at (t->get_locus (), - "expected ';' or definiton at the end of trait %s " - "definition - found '%s' " - "instead", + "expected %<;%> or definiton at the end of trait %s " + "definition - found %<%s%> instead", is_method ? "method" : "function", t->get_token_description ()); // skip? @@ -4402,8 +4407,8 @@ Parser<ManagedTokenSource>::parse_trait_item () { return macro_invoc; } - // FIXME: macro invocations can only start with certain tokens. be more - // picky with these? + /* FIXME: macro invocations can only start with certain tokens. be more + * picky with these? */ } } } @@ -4739,16 +4744,17 @@ Parser<ManagedTokenSource>::parse_inherent_impl_item () outer_attrs)); default: rust_error_at (t->get_locus (), - "unexpected token '%s' in some sort of const " + "unexpected token %<%s%> in some sort of const " "item in inherent impl", t->get_token_description ()); lexer.skip_token (1); // TODO: is this right thing to do? return nullptr; } default: - rust_error_at (t->get_locus (), - "unrecognised token '%s' for item in inherent impl", - t->get_token_description ()); + rust_error_at ( + t->get_locus (), + "unrecognised token %<%s%> for item in inherent impl", + t->get_token_description ()); // skip? return nullptr; } @@ -4776,17 +4782,17 @@ Parser<ManagedTokenSource>::parse_inherent_impl_item () return parse_inherent_impl_function_or_method ( AST::Visibility::create_error (), std::move (outer_attrs)); default: - rust_error_at ( - t->get_locus (), - "unexpected token '%s' in some sort of const item in inherent impl", - t->get_token_description ()); + rust_error_at (t->get_locus (), + "unexpected token %<%s%> in some sort of const item " + "in inherent impl", + t->get_token_description ()); lexer.skip_token (1); // TODO: is this right thing to do? return nullptr; } gcc_unreachable (); default: rust_error_at (t->get_locus (), - "unrecognised token '%s' for item in inherent impl", + "unrecognised token %<%s%> for item in inherent impl", t->get_token_description ()); // skip? return nullptr; @@ -4959,7 +4965,7 @@ Parser<ManagedTokenSource>::parse_trait_impl_item () outer_attrs)); default: rust_error_at (t->get_locus (), - "unexpected token '%s' in some sort of const " + "unexpected token %<%s%> in some sort of const " "item in trait impl", t->get_token_description ()); lexer.skip_token (1); // TODO: is this right thing to do? @@ -4967,7 +4973,7 @@ Parser<ManagedTokenSource>::parse_trait_impl_item () } default: rust_error_at (t->get_locus (), - "unrecognised token '%s' for item in trait impl", + "unrecognised token %<%s%> for item in trait impl", t->get_token_description ()); // skip? return nullptr; @@ -4998,7 +5004,7 @@ Parser<ManagedTokenSource>::parse_trait_impl_item () default: rust_error_at ( t->get_locus (), - "unexpected token '%s' in some sort of const item in trait impl", + "unexpected token %<%s%> in some sort of const item in trait impl", t->get_token_description ()); lexer.skip_token (1); // TODO: is this right thing to do? return nullptr; @@ -5006,7 +5012,7 @@ Parser<ManagedTokenSource>::parse_trait_impl_item () gcc_unreachable (); default: rust_error_at (t->get_locus (), - "unrecognised token '%s' for item in trait impl", + "unrecognised token %<%s%> for item in trait impl", t->get_token_description ()); // skip? return nullptr; @@ -5345,8 +5351,7 @@ Parser<ManagedTokenSource>::parse_external_item () { rust_error_at (t->get_locus (), "expected comma or right parentheses in " - "named function parameters, " - "found '%s'", + "named function parameters, found %<%s%>", t->get_token_description ()); } else @@ -5399,9 +5404,10 @@ Parser<ManagedTokenSource>::parse_external_item () } default: // error - rust_error_at (t->get_locus (), - "unrecognised token '%s' in extern block item declaration", - t->get_token_description ()); + rust_error_at ( + t->get_locus (), + "unrecognised token %<%s%> in extern block item declaration", + t->get_token_description ()); skip_after_semicolon (); return nullptr; } @@ -5763,10 +5769,10 @@ Parser<ManagedTokenSource>::parse_path_generic_args () // skip any trailing commas if (lexer.peek_token ()->get_id () == COMMA) - lexer.skip_token (); + lexer.skip_token (); if (!skip_generics_right_angle ()) - return AST::GenericArgs::create_empty (); + return AST::GenericArgs::create_empty (); lifetime_args.shrink_to_fit (); type_args.shrink_to_fit (); @@ -5893,19 +5899,22 @@ Parser<ManagedTokenSource>::parse_type_path_function () std::unique_ptr<AST::Type> type = parse_type (); if (type == nullptr) { - // this is an error as there should've been a ')' there if there wasn't a type - rust_error_at (lexer.peek_token ()->get_locus (), "failed to parse type in parameters of type path function"); - // skip somewhere? - return AST::TypePathFunction::create_error (); + // this is an error as there should've been a ')' there if there + // wasn't a type + rust_error_at ( + lexer.peek_token ()->get_locus (), + "failed to parse type in parameters of type path function"); + // skip somewhere? + return AST::TypePathFunction::create_error (); } inputs.push_back (std::move (type)); // skip commas, including trailing commas if (lexer.peek_token ()->get_id () != COMMA) - break; + break; - lexer.skip_token (); + lexer.skip_token (); } if (!skip_token (RIGHT_PAREN)) @@ -6361,7 +6370,7 @@ Parser<ManagedTokenSource>::parse_method () // skip comma if it exists if (lexer.peek_token ()->get_id () == COMMA) - lexer.skip_token (); + lexer.skip_token (); // parse function parameters std::vector<AST::FunctionParam> function_params = parse_function_params (); @@ -6539,11 +6548,11 @@ Parser<ManagedTokenSource>::parse_expr_stmt_with_block ( expr_parsed = parse_labelled_loop_expr (std::move (outer_attrs)); break; default: - rust_error_at (t->get_locus (), - "could not recognise expr beginning with '%s' as an expr " - "with block in parsing " - "expr statement.", - t->get_token_description ()); + rust_error_at ( + t->get_locus (), + "could not recognise expr beginning with %<%s%> as an expr " + "with block in parsing expr statement.", + t->get_token_description ()); skip_after_next_block (); return nullptr; } @@ -6854,10 +6863,10 @@ Parser<ManagedTokenSource>::parse_closure_expr ( } break; default: - rust_error_at ( - t->get_locus (), - "unexpected token '%s' in closure expression - expected '|' or '||'", - t->get_token_description ()); + rust_error_at (t->get_locus (), + "unexpected token %<%s%> in closure expression - expected " + "%<|%> or %<||%>", + t->get_token_description ()); // skip somewhere? return nullptr; } @@ -6980,7 +6989,7 @@ Parser<ManagedTokenSource>::parse_literal_expr ( default: // error - cannot be a literal expr rust_error_at (t->get_locus (), - "unexpected token '%s' when parsing literal expression", + "unexpected token %<%s%> when parsing literal expression", t->get_token_description ()); // skip? return nullptr; @@ -7131,8 +7140,7 @@ Parser<ManagedTokenSource>::parse_if_expr ( { rust_error_at (lexer.peek_token ()->get_locus (), "if let expression probably exists, but is being parsed " - "as an if expression. This may " - "be a parser error."); + "as an if expression. This may be a parser error."); // skip somewhere? return nullptr; } @@ -7242,7 +7250,7 @@ Parser<ManagedTokenSource>::parse_if_expr ( default: // error - invalid token rust_error_at (t->get_locus (), - "unexpected token '%s' after else in if expression", + "unexpected token %<%s%> after else in if expression", t->get_token_description ()); // skip somewhere? return nullptr; @@ -7268,8 +7276,7 @@ Parser<ManagedTokenSource>::parse_if_let_expr ( { rust_error_at (lexer.peek_token ()->get_locus (), "if expression probably exists, but is being parsed as an " - "if let expression. This may " - "be a parser error."); + "if let expression. This may be a parser error."); // skip somewhere? return nullptr; } @@ -7405,7 +7412,7 @@ Parser<ManagedTokenSource>::parse_if_let_expr ( // error - invalid token rust_error_at ( t->get_locus (), - "unexpected token '%s' after else in if let expression", + "unexpected token %<%s%> after else in if let expression", t->get_token_description ()); // skip somewhere? return nullptr; @@ -7425,9 +7432,9 @@ Parser<ManagedTokenSource>::parse_loop_expr ( { Location locus = Linemap::unknown_location (); if (label.is_error ()) - locus = lexer.peek_token ()->get_locus (); + locus = lexer.peek_token ()->get_locus (); else - locus = label.get_locus (); + locus = label.get_locus (); skip_token (LOOP); // parse loop body, which is required @@ -7453,9 +7460,9 @@ Parser<ManagedTokenSource>::parse_while_loop_expr ( { Location locus = Linemap::unknown_location (); if (label.is_error ()) - locus = lexer.peek_token ()->get_locus (); + locus = lexer.peek_token ()->get_locus (); else - locus = label.get_locus (); + locus = label.get_locus (); skip_token (WHILE); // ensure it isn't a while let loop @@ -7508,9 +7515,9 @@ Parser<ManagedTokenSource>::parse_while_let_loop_expr ( { Location locus = Linemap::unknown_location (); if (label.is_error ()) - locus = lexer.peek_token ()->get_locus (); + locus = lexer.peek_token ()->get_locus (); else - locus = label.get_locus (); + locus = label.get_locus (); skip_token (WHILE); /* check for possible accidental recognition of a while loop as a while let @@ -7578,9 +7585,9 @@ Parser<ManagedTokenSource>::parse_for_loop_expr ( { Location locus = Linemap::unknown_location (); if (label.is_error ()) - locus = lexer.peek_token ()->get_locus (); + locus = lexer.peek_token ()->get_locus (); else - locus = label.get_locus (); + locus = label.get_locus (); skip_token (FOR); // parse pattern, which is required @@ -7644,7 +7651,7 @@ Parser<ManagedTokenSource>::parse_labelled_loop_expr ( { rust_error_at (lexer.peek_token ()->get_locus (), "expected lifetime in labelled loop expr (to parse loop " - "label) - found '%s'", + "label) - found %<%s%>", lexer.peek_token ()->get_token_description ()); // skip? return nullptr; @@ -7683,7 +7690,7 @@ Parser<ManagedTokenSource>::parse_labelled_loop_expr ( default: // error rust_error_at (t->get_locus (), - "unexpected token '%s' when parsing labelled loop", + "unexpected token %<%s%> when parsing labelled loop", t->get_token_description ()); // skip? return nullptr; @@ -8083,9 +8090,9 @@ Parser<ManagedTokenSource>::parse_array_expr ( { // single-element array expression std::vector<std::unique_ptr<AST::Expr> > exprs; - exprs.reserve (1); + exprs.reserve (1); exprs.push_back (std::move (initial_expr)); - exprs.shrink_to_fit (); + exprs.shrink_to_fit (); std::unique_ptr<AST::ArrayElemsValues> array_elems ( new AST::ArrayElemsValues (std::move (exprs))); @@ -8127,7 +8134,7 @@ Parser<ManagedTokenSource>::parse_array_expr ( skip_token (RIGHT_SQUARE); - exprs.shrink_to_fit (); + exprs.shrink_to_fit (); std::unique_ptr<AST::ArrayElemsValues> array_elems ( new AST::ArrayElemsValues (std::move (exprs))); @@ -8141,7 +8148,7 @@ Parser<ManagedTokenSource>::parse_array_expr ( // error rust_error_at ( lexer.peek_token ()->get_locus (), - "unexpected token '%s' in array expression (arrayelems)", + "unexpected token %<%s%> in array expression (arrayelems)", lexer.peek_token ()->get_token_description ()); // skip somewhere? return nullptr; @@ -8282,9 +8289,9 @@ Parser<ManagedTokenSource>::parse_grouped_or_tuple_expr ( // error const_TokenPtr t = lexer.peek_token (); rust_error_at (t->get_locus (), - "unexpected token '%s' in grouped or tuple expression " - "(parenthesised expression) - " - "expected ')' for grouped expr and ',' for tuple expr", + "unexpected token %<%s%> in grouped or tuple expression " + "(parenthesised expression) - expected %<)%> for grouped " + "expr and %<,%> for tuple expr", t->get_token_description ()); // skip somewhere? return nullptr; @@ -8462,8 +8469,8 @@ Parser<ManagedTokenSource>::parse_type () } case LEFT_PAREN: /* tuple type or parenthesised type - requires further disambiguation (the - * usual). ok apparently can be a parenthesised TraitBound too, so could be - * TraitObjectTypeOneBound or TraitObjectType */ + * usual). ok apparently can be a parenthesised TraitBound too, so could + * be TraitObjectTypeOneBound or TraitObjectType */ return parse_paren_prefixed_type (); case FOR: // TraitObjectTypeOneBound or BareFunctionType @@ -8612,7 +8619,7 @@ Parser<ManagedTokenSource>::parse_type () } } default: - rust_error_at (t->get_locus (), "unrecognised token '%s' in type", + rust_error_at (t->get_locus (), "unrecognised token %<%s%> in type", t->get_token_description ()); return nullptr; } @@ -8837,9 +8844,8 @@ Parser<ManagedTokenSource>::parse_for_prefixed_type () default: // error rust_error_at (t->get_locus (), - "unrecognised token '%s' in bare function type or trait " - "object type or trait " - "object type one bound", + "unrecognised token %<%s%> in bare function type or trait " + "object type or trait object type one bound", t->get_token_description ()); return nullptr; } @@ -9047,7 +9053,7 @@ Parser<ManagedTokenSource>::parse_raw_pointer_type () break; default: rust_error_at (t->get_locus (), - "unrecognised token '%s' in raw pointer type", + "unrecognised token %<%s%> in raw pointer type", t->get_token_description ()); return nullptr; } @@ -9118,7 +9124,7 @@ Parser<ManagedTokenSource>::parse_slice_or_array_type () // error rust_error_at ( t->get_locus (), - "unrecognised token '%s' in slice or array type after inner type", + "unrecognised token %<%s%> in slice or array type after inner type", t->get_token_description ()); return nullptr; } @@ -9241,8 +9247,8 @@ Parser<ManagedTokenSource>::parse_type_no_bounds () } case LEFT_PAREN: /* tuple type or parenthesised type - requires further disambiguation (the - * usual). ok apparently can be a parenthesised TraitBound too, so could be - * TraitObjectTypeOneBound */ + * usual). ok apparently can be a parenthesised TraitBound too, so could + * be TraitObjectTypeOneBound */ return parse_paren_prefixed_type_no_bounds (); case FOR: case ASYNC: @@ -9259,10 +9265,10 @@ Parser<ManagedTokenSource>::parse_type_no_bounds () /* cannot be one bound because lifetime prevents it from being * traitbound not allowed as type no bounds, only here for error * message */ - rust_error_at (lexer.peek_token ()->get_locus (), - "lifetime (probably lifetime bound, in type param " - "bounds, in ImplTraitType) is " - "not allowed in TypeNoBounds"); + rust_error_at ( + lexer.peek_token ()->get_locus (), + "lifetime (probably lifetime bound, in type param " + "bounds, in ImplTraitType) is not allowed in TypeNoBounds"); return nullptr; } else @@ -9351,7 +9357,7 @@ Parser<ManagedTokenSource>::parse_type_no_bounds () } default: rust_error_at (t->get_locus (), - "unrecognised token '%s' in type no bounds", + "unrecognised token %<%s%> in type no bounds", t->get_token_description ()); return nullptr; } @@ -9510,16 +9516,17 @@ Parser<ManagedTokenSource>::parse_literal_or_range_pattern () break; default: rust_error_at (range_lower->get_locus (), - "token type '%s' cannot be parsed as range pattern " + "token type %<%s%> cannot be parsed as range pattern " "bound or literal after minus symbol", range_lower->get_token_description ()); return nullptr; } break; default: - rust_error_at (range_lower->get_locus (), - "token type '%s' cannot be parsed as range pattern bound", - range_lower->get_token_description ()); + rust_error_at ( + range_lower->get_locus (), + "token type %<%s%> cannot be parsed as range pattern bound", + range_lower->get_token_description ()); return nullptr; } @@ -9613,7 +9620,7 @@ Parser<ManagedTokenSource>::parse_range_pattern_bound () range_lower_locus, true)); default: rust_error_at (range_lower->get_locus (), - "token type '%s' cannot be parsed as range pattern " + "token type %<%s%> cannot be parsed as range pattern " "bound after minus symbol", range_lower->get_token_description ()); return nullptr; @@ -9652,9 +9659,10 @@ Parser<ManagedTokenSource>::parse_range_pattern_bound () new AST::RangePatternBoundQualPath (std::move (path))); } default: - rust_error_at (range_lower->get_locus (), - "token type '%s' cannot be parsed as range pattern bound", - range_lower->get_token_description ()); + rust_error_at ( + range_lower->get_locus (), + "token type %<%s%> cannot be parsed as range pattern bound", + range_lower->get_token_description ()); return nullptr; } } @@ -9702,8 +9710,8 @@ Parser<ManagedTokenSource>::parse_pattern () } else { - rust_error_at (t->get_locus (), "unexpected token '-' in pattern - " - "did you forget an integer literal?"); + rust_error_at (t->get_locus (), "unexpected token %<-%> in pattern - " + "did you forget an integer literal"); return nullptr; } case UNDERSCORE: @@ -9834,7 +9842,7 @@ Parser<ManagedTokenSource>::parse_pattern () } } default: - rust_error_at (t->get_locus (), "unexpected token '%s' in pattern", + rust_error_at (t->get_locus (), "unexpected token %<%s%> in pattern", t->get_token_description ()); return nullptr; } @@ -9860,7 +9868,7 @@ Parser<ManagedTokenSource>::parse_reference_pattern () break; default: rust_error_at (t->get_locus (), - "unexpected token '%s' in reference pattern", + "unexpected token %<%s%> in reference pattern", t->get_token_description ()); return nullptr; } @@ -10060,7 +10068,7 @@ Parser<ManagedTokenSource>::parse_grouped_or_tuple_pattern () default: // error rust_error_at (t->get_locus (), - "unrecognised token '%s' in grouped or tuple pattern " + "unrecognised token %<%s%> in grouped or tuple pattern " "after first pattern", t->get_token_description ()); return nullptr; @@ -10446,7 +10454,7 @@ Parser<ManagedTokenSource>::parse_tuple_struct_items () default: // error rust_error_at (t->get_locus (), - "unexpected token '%s' in tuple struct items", + "unexpected token %<%s%> in tuple struct items", t->get_token_description ()); return nullptr; } @@ -10493,8 +10501,8 @@ Parser<ManagedTokenSource>::parse_struct_pattern_elems () } /* FIXME: this method of parsing prevents parsing any outer attributes on the - * .. - also there seems to be no distinction between having etc and not having - * etc. */ + * .. - also there seems to be no distinction between having etc and not + * having etc. */ if (lexer.peek_token ()->get_id () == DOT_DOT) { lexer.skip_token (); @@ -10588,7 +10596,7 @@ Parser<ManagedTokenSource>::parse_struct_pattern_field () default: // error rust_error_at (t->get_locus (), - "unrecognised token '%s' in struct pattern field", + "unrecognised token %<%s%> in struct pattern field", t->get_token_description ()); return nullptr; } @@ -10722,9 +10730,8 @@ Parser<ManagedTokenSource>::parse_stmt_or_expr_without_block () } default: rust_error_at (t2->get_locus (), - "unrecognised token '%s' after parsing unsafe - " - "expected beginning of " - "expression or statement", + "unrecognised token %<%s%> after parsing unsafe - " + "expected beginning of expression or statement", t->get_token_description ()); // skip somewhere? return ExprOrStmt::create_error (); @@ -10925,7 +10932,7 @@ Parser<ManagedTokenSource>::parse_path_based_stmt_or_expr ( default: rust_error_at ( t3->get_locus (), - "unrecognised token '%s' in macro invocation - (opening) " + "unrecognised token %<%s%> in macro invocation - (opening) " "delimiter expected", t3->get_token_description ()); return ExprOrStmt::create_error (); @@ -10946,7 +10953,7 @@ Parser<ManagedTokenSource>::parse_path_based_stmt_or_expr ( rust_error_at ( t3->get_locus (), "failed to parse token tree for macro invocation (or semi) - " - "found '%s'", + "found %<%s%>", t3->get_token_description ()); return ExprOrStmt::create_error (); } @@ -10995,12 +11002,14 @@ Parser<ManagedTokenSource>::parse_path_based_stmt_or_expr ( else { // tokens don't match opening delimiters, so produce error - rust_error_at ( - t2->get_locus (), - "unexpected token '%s' - expecting closing delimiter '%s' (for a " - "macro invocation)", - t2->get_token_description (), - (type == AST::PARENS ? ")" : (type == AST::SQUARE ? "]" : "}"))); + rust_error_at (t2->get_locus (), + "unexpected token %<%s%> - expecting closing " + "delimiter %<%s%> (for a " + "macro invocation)", + t2->get_token_description (), + (type == AST::PARENS + ? ")" + : (type == AST::SQUARE ? "]" : "}"))); return ExprOrStmt::create_error (); } } @@ -11176,7 +11185,7 @@ Parser<ManagedTokenSource>::parse_struct_expr_field () return nullptr; default: rust_error_at (t->get_locus (), - "unrecognised token '%s' as first token of struct expr " + "unrecognised token %<%s%> as first token of struct expr " "field - expected identifier or int literal", t->get_token_description ()); return nullptr; @@ -11219,10 +11228,11 @@ Parser<ManagedTokenSource>::parse_macro_invocation_maybe_semi ( type = AST::CURLY; break; default: - rust_error_at (t3->get_locus (), - "unrecognised token '%s' in macro invocation - (opening) " - "delimiter expected", - t3->get_token_description ()); + rust_error_at ( + t3->get_locus (), + "unrecognised token %<%s%> in macro invocation - (opening) " + "delimiter expected", + t3->get_token_description ()); return ExprOrStmt::create_error (); } lexer.skip_token (); @@ -11240,7 +11250,7 @@ Parser<ManagedTokenSource>::parse_macro_invocation_maybe_semi ( { rust_error_at (t3->get_locus (), "failed to parse token tree for macro invocation (or " - "semi) - found '%s'", + "semi) - found %<%s%>", t3->get_token_description ()); return ExprOrStmt::create_error (); } @@ -11291,7 +11301,7 @@ Parser<ManagedTokenSource>::parse_macro_invocation_maybe_semi ( // tokens don't match opening delimiters, so produce error rust_error_at ( t->get_locus (), - "unexpected token '%s' - expecting closing delimiter '%s' (for a " + "unexpected token %<%s%> - expecting closing delimiter %<%s%> (for a " "macro invocation)", t->get_token_description (), (type == AST::PARENS ? ")" : (type == AST::SQUARE ? "]" : "}"))); @@ -11304,7 +11314,7 @@ template <typename ManagedTokenSource> void Parser<ManagedTokenSource>::unexpected_token (const_TokenPtr t) { - rust_error_at (t->get_locus (), "unexpected %s\n", + rust_error_at (t->get_locus (), "unexpected token %<%s%>\n", t->get_token_description ()); } @@ -11349,7 +11359,7 @@ Parser<ManagedTokenSource>::expect_token (TokenId token_id) } else { - rust_error_at (t->get_locus (), "expecting %s but %s found!\n", + rust_error_at (t->get_locus (), "expecting %<%s%> but %<%s%> found\n", get_token_description (token_id), t->get_token_description ()); @@ -11594,7 +11604,7 @@ Parser<ManagedTokenSource>::null_denotation ( if (path.is_single_segment ()) { // have to return an identifier expression or something - /* HACK: may have to become permanent, but this is my + /* HACK: may have to become permanent, but this is my * current identifier expression */ return std::unique_ptr<AST::IdentifierExpr> ( new AST::IdentifierExpr (tok->get_str (), @@ -11953,7 +11963,7 @@ Parser<ManagedTokenSource>::null_denotation ( return parse_array_expr (std::move (outer_attrs), true); default: rust_error_at (tok->get_locus (), - "found unexpected token '%s' in null denotation", + "found unexpected token %<%s%> in null denotation", tok->get_token_description ()); return nullptr; } @@ -12271,7 +12281,7 @@ Parser<ManagedTokenSource>::left_denotation ( restrictions); default: rust_error_at (tok->get_locus (), - "found unexpected token '%s' in left denotation", + "found unexpected token %<%s%> in left denotation", tok->get_token_description ()); return nullptr; } @@ -12309,7 +12319,7 @@ get_lbp_for_arithmetic_or_logical_expr ( // WTF? should not happen, this is an error rust_error_at ( Location (), - "could not get LBP for ArithmeticOrLogicalExpr - unknown ExprType!"); + "could not get LBP for ArithmeticOrLogicalExpr - unknown ExprType"); return LBP_PLUS; } } @@ -12591,9 +12601,8 @@ get_lbp_for_comparison_expr (AST::ComparisonExpr::ExprType expr_type) return LBP_SMALLER_EQUAL; default: // WTF? should not happen, this is an error - rust_error_at ( - Location (), - "could not get LBP for ComparisonExpr - unknown ExprType!"); + rust_error_at (Location (), + "could not get LBP for ComparisonExpr - unknown ExprType"); return LBP_EQUAL; } } @@ -12878,7 +12887,7 @@ get_lbp_for_compound_assignment_expr ( // WTF? should not happen, this is an error rust_error_at ( Location (), - "could not get LBP for CompoundAssignmentExpr - unknown ExprType!"); + "could not get LBP for CompoundAssignmentExpr - unknown ExprType"); return LBP_PLUS; } } @@ -13168,8 +13177,9 @@ Parser<ManagedTokenSource>::parse_await_expr ( * as await */ if (!skip_token (IDENTIFIER)) { - rust_error_at (tok->get_locus (), "failed to skip 'await' in await expr " - "- this is probably a deep issue."); + rust_error_at (tok->get_locus (), + "failed to skip %<await%> in await expr " + "- this is probably a deep issue"); // skip somewhere? return nullptr; } @@ -13618,10 +13628,11 @@ Parser<ManagedTokenSource>::parse_struct_expr_struct_partial ( std::move (outer_attrs))); } default: - rust_error_at (t->get_locus (), - "unrecognised token '%s' in struct (or enum) expression - " - "expected '}', identifier, int literal, or '..'", - t->get_token_description ()); + rust_error_at ( + t->get_locus (), + "unrecognised token %<%s%> in struct (or enum) expression - " + "expected %<}%>, identifier, int literal, or %<..%>", + t->get_token_description ()); return nullptr; } } @@ -13649,9 +13660,9 @@ Parser<ManagedTokenSource>::parse_struct_expr_tuple_partial ( std::unique_ptr<AST::Expr> expr = parse_expr (); if (expr == nullptr) { - rust_error_at (t->get_locus (), - "failed to parse expression in struct " - "(or enum) expression tuple"); + rust_error_at ( + t->get_locus (), + "failed to parse expression in struct (or enum) expression tuple"); return nullptr; } exprs.push_back (std::move (expr)); @@ -13724,7 +13735,7 @@ Parser<ManagedTokenSource>::parse_path_in_expression_pratt (const_TokenPtr tok) gcc_fallthrough (); default: rust_error_at (tok->get_locus (), - "unrecognised token '%s' in path in expression", + "unrecognised token %<%s%> in path in expression", tok->get_token_description ()); return AST::PathInExpression::create_error (); } @@ -13847,10 +13858,10 @@ Parser<ManagedTokenSource>::parse_closure_expr_pratt ( break; } default: - rust_error_at ( - tok->get_locus (), - "unexpected token '%s' in closure expression - expected '|' or '||'", - tok->get_token_description ()); + rust_error_at (tok->get_locus (), + "unexpected token %<%s%> in closure expression - expected " + "%<|%> or %<||%>", + tok->get_token_description ()); // skip somewhere? return nullptr; } diff --git a/gcc/rust/rust-session-manager.cc b/gcc/rust/rust-session-manager.cc index d75204a..d76d816 100644 --- a/gcc/rust/rust-session-manager.cc +++ b/gcc/rust/rust-session-manager.cc @@ -235,41 +235,49 @@ void Session::init () { #ifndef TARGET_RUST_OS_INFO -# define TARGET_RUST_OS_INFO() +#define TARGET_RUST_OS_INFO() #endif //#define builtin_rust_info(KEY, VALUE) rust_add_target_info (KEY, VALUE) // might as well use c++ stuff -#define builtin_rust_info(KEY, VALUE) options.target_data.insert_key_value_pair(KEY, VALUE) - - // initialise target hooks - //targetrustm.rust_cpu_info(); - //targetrustm.rust_os_info(); - // ok, that's not working too well TODO - see if can salvage old implementation - TARGET_RUST_CPU_INFO (); - TARGET_RUST_OS_INFO (); - - /* note that due to issues with gcc targets, some implementations of those two macros above - * (TARGET_RUST_CPU_INFO and TARGET_RUST_OS_INFO) are not function calls, but actually inline - * substitutions. As such, they can't be stored with a function pointer in a "real" target hook. - * At least, that's my current understanding of it. */ - +#define builtin_rust_info(KEY, VALUE) \ + options.target_data.insert_key_value_pair (KEY, VALUE) + + // initialise target hooks + // targetrustm.rust_cpu_info(); + // targetrustm.rust_os_info(); + // ok, that's not working too well TODO - see if can salvage old + // implementation + TARGET_RUST_CPU_INFO (); + TARGET_RUST_OS_INFO (); + + /* note that due to issues with gcc targets, some implementations of those two + * macros above (TARGET_RUST_CPU_INFO and TARGET_RUST_OS_INFO) are not + * function calls, but actually inline substitutions. As such, they can't be + * stored with a function pointer in a "real" target hook. + * At least, that's my current understanding of it. */ + #undef builtin_rust_info - // target-independent values that should exist in all targets - options.target_data.insert_key_value_pair ("target_pointer_width", std::to_string (POINTER_SIZE)); - options.target_data.insert_key_value_pair ("target_endian", BYTES_BIG_ENDIAN ? "big" : "little"); + // target-independent values that should exist in all targets + options.target_data.insert_key_value_pair ("target_pointer_width", + std::to_string (POINTER_SIZE)); + options.target_data.insert_key_value_pair ("target_endian", BYTES_BIG_ENDIAN + ? "big" + : "little"); - // TODO: find min atomic width and max atomic width - // from it, add atomic-related stuff for sizes 8, 16, 32, 64, and 128 (if inside bounds) - // in rustc, min atomic width is a known quantity (or 8 if not known), and max is also a known quantity (or is pointer size if not known) - // TODO: add atomic pointer if some criteria is satisfied + // TODO: find min atomic width and max atomic width + // from it, add atomic-related stuff for sizes 8, 16, 32, 64, and 128 (if + // inside bounds) in rustc, min atomic width is a known quantity (or 8 if not + // known), and max is also a known quantity (or is pointer size if not known) + // TODO: add atomic pointer if some criteria is satisfied - // TODO: find whether target has "atomic cas" + // TODO: find whether target has "atomic cas" - // add debug_assertions if enabled and proc_macro if crate type has it or whatever + // add debug_assertions if enabled and proc_macro if crate type has it or + // whatever - // derived values from hook - options.target_data.init_derived_values (); + // derived values from hook + options.target_data.init_derived_values (); } /* Initialise default options. Actually called before handle_option, unlike init @@ -328,9 +336,9 @@ Session::enable_dump (std::string arg) * created */ if (arg == "all") { - rust_error_at ( - Location (), - "dumping all is not supported as of now. choose 'lex', 'parse', or 'target_options"); + rust_error_at (Location (), + "dumping all is not supported as of now. choose %<lex%>, " + "%<parse%>, or %<target_options%>"); return false; } else if (arg == "lex") @@ -356,25 +364,28 @@ Session::enable_dump (std::string arg) else if (arg == "resolution") { options.dump_option = CompileOptions::RESOLUTION_DUMP; - } - else if (arg == "target_options") { + } + else if (arg == "target_options") + { // special case - dump all target options, and then quit compilation - // nope, option handling called before init, so have to make this an actual compile option - //options.target_data.dump_target_options(); - //return false; + // nope, option handling called before init, so have to make this an + // actual compile option + // options.target_data.dump_target_options(); + // return false; options.dump_option = CompileOptions::TARGET_OPTION_DUMP; } else if (arg == "") { - rust_error_at (Location (), - "dump option was not given a name. choose 'lex', 'parse', or 'target_options'"); + rust_error_at (Location (), "dump option was not given a name. choose " + "%<lex%>, %<parse%>, or %<target_options%>"); return false; } else { rust_error_at (Location (), - "dump option '%s' was unrecognised. choose 'lex', 'parse', or 'target_options", - arg.c_str ()); + "dump option %<%s%> was unrecognised. choose %<lex%>, " + "%<parse%>, or %<target_options%>", + arg.c_str ()); return false; } return true; @@ -399,7 +410,7 @@ Session::parse_file (const char *filename) { RAIIFile file_wrap (filename); - if (file_wrap.get_raw() == nullptr) + if (file_wrap.get_raw () == nullptr) { rust_fatal_error (Location (), "cannot open filename %s: %m", filename); } @@ -420,7 +431,8 @@ Session::parse_file (const char *filename) { case CompileOptions::LEXER_DUMP: parser.debug_dump_lex_output (); - // TODO: rewrite lexer dump or something so that it allows for the crate to already be parsed + // TODO: rewrite lexer dump or something so that it allows for the crate + // to already be parsed break; case CompileOptions::PARSER_AST_DUMP: parser.debug_dump_ast_output (parsed_crate); @@ -583,7 +595,7 @@ contains_name (const std::vector<AST::Attribute> &attrs, std::string name) for (const auto &attr : attrs) { if (attr.get_path () == name) - return true; + return true; } return false; @@ -696,8 +708,7 @@ Session::injection (AST::Crate &crate) // create use tree and decl std::unique_ptr<AST::UseTreeGlob> use_tree ( new AST::UseTreeGlob (AST::UseTreeGlob::PATH_PREFIXED, - AST::SimplePath (std::move (segments)), - Location ())); + AST::SimplePath (std::move (segments)), Location ())); AST::Attribute prelude_attr (AST::SimplePath::from_str ("prelude_import"), nullptr); std::unique_ptr<AST::UseDeclaration> use_decl ( @@ -754,88 +765,91 @@ Session::resolution (AST::Crate &crate) fprintf (stderr, "finished name resolution\n"); } -void -TargetOptions::dump_target_options () const - { - fprintf (stderr, "\033[0;31m--PREPARING TO DUMP ALL TARGET OPTIONS--\n\033[0m"); - for (const auto& pairs : features) - { - for (const auto& value : pairs.second) - fprintf (stderr, "%s: \"%s\"\n", pairs.first.c_str (), value.c_str ()); - - if (pairs.second.empty ()) - fprintf (stderr, "%s\n", pairs.first.c_str ()); - } - if (features.empty ()) - fprintf (stderr, "No target options available!\n"); +void +TargetOptions::dump_target_options () const +{ + fprintf (stderr, + "\033[0;31m--PREPARING TO DUMP ALL TARGET OPTIONS--\n\033[0m"); + for (const auto &pairs : features) + { + for (const auto &value : pairs.second) + fprintf (stderr, "%s: \"%s\"\n", pairs.first.c_str (), value.c_str ()); - fprintf (stderr, "\033[0;31m--END OF TARGET OPTION DUMP--\n\033[0m"); - } + if (pairs.second.empty ()) + fprintf (stderr, "%s\n", pairs.first.c_str ()); + } + if (features.empty ()) + fprintf (stderr, "No target options available!\n"); -void -TargetOptions::init_derived_values () - { - // enable derived values based on target families - if (has_key_value_pair ("target_family", "unix")) - insert_key ("unix"); - if (has_key_value_pair ("target_family", "windows")) - insert_key ("windows"); - - // implicitly enable features - this should not be required in general - if (has_key_value_pair ("target_feature", "aes")) - enable_implicit_feature_reqs ("aes"); - if (has_key_value_pair ("target_feature", "avx")) - enable_implicit_feature_reqs ("sse4.2"); - if (has_key_value_pair ("target_feature", "avx2")) - enable_implicit_feature_reqs ("avx"); - if (has_key_value_pair ("target_feature", "pclmulqdq")) - enable_implicit_feature_reqs ("sse2"); - if (has_key_value_pair ("target_feature", "sha")) - enable_implicit_feature_reqs ("sse2"); - if (has_key_value_pair ("target_feature", "sse2")) - enable_implicit_feature_reqs ("sse"); - if (has_key_value_pair ("target_feature", "sse3")) - enable_implicit_feature_reqs ("sse2"); - if (has_key_value_pair ("target_feature", "sse4.1")) - enable_implicit_feature_reqs ("sse3"); - if (has_key_value_pair ("target_feature", "sse4.2")) - enable_implicit_feature_reqs ("sse4.1"); - if (has_key_value_pair ("target_feature", "ssse3")) - enable_implicit_feature_reqs ("sse3"); - } + fprintf (stderr, "\033[0;31m--END OF TARGET OPTION DUMP--\n\033[0m"); +} + +void +TargetOptions::init_derived_values () +{ + // enable derived values based on target families + if (has_key_value_pair ("target_family", "unix")) + insert_key ("unix"); + if (has_key_value_pair ("target_family", "windows")) + insert_key ("windows"); + + // implicitly enable features - this should not be required in general + if (has_key_value_pair ("target_feature", "aes")) + enable_implicit_feature_reqs ("aes"); + if (has_key_value_pair ("target_feature", "avx")) + enable_implicit_feature_reqs ("sse4.2"); + if (has_key_value_pair ("target_feature", "avx2")) + enable_implicit_feature_reqs ("avx"); + if (has_key_value_pair ("target_feature", "pclmulqdq")) + enable_implicit_feature_reqs ("sse2"); + if (has_key_value_pair ("target_feature", "sha")) + enable_implicit_feature_reqs ("sse2"); + if (has_key_value_pair ("target_feature", "sse2")) + enable_implicit_feature_reqs ("sse"); + if (has_key_value_pair ("target_feature", "sse3")) + enable_implicit_feature_reqs ("sse2"); + if (has_key_value_pair ("target_feature", "sse4.1")) + enable_implicit_feature_reqs ("sse3"); + if (has_key_value_pair ("target_feature", "sse4.2")) + enable_implicit_feature_reqs ("sse4.1"); + if (has_key_value_pair ("target_feature", "ssse3")) + enable_implicit_feature_reqs ("sse3"); +} -void -TargetOptions::enable_implicit_feature_reqs (std::string feature) - { - if (feature == "aes") - enable_implicit_feature_reqs ("sse2"); - else if (feature == "avx") - enable_implicit_feature_reqs ("sse4.2"); - else if (feature == "avx2") - enable_implicit_feature_reqs ("avx"); - else if (feature == "fma") - enable_implicit_feature_reqs ("avx"); - else if (feature == "pclmulqdq") - enable_implicit_feature_reqs ("sse2"); - else if (feature == "sha") - enable_implicit_feature_reqs ("sse2"); - else if (feature == "sse2") - enable_implicit_feature_reqs ("sse"); - else if (feature == "sse3") - enable_implicit_feature_reqs ("sse2"); - else if (feature == "sse4.1") - enable_implicit_feature_reqs ("sse3"); - else if (feature == "sse4.2") - enable_implicit_feature_reqs ("sse4.1"); - else if (feature == "ssse3") - enable_implicit_feature_reqs ("sse3"); - - if (!has_key_value_pair ("target_feature", feature)) { - insert_key_value_pair ("target_feature", feature); - - fprintf (stderr, "had to implicitly enable feature '%s'!", feature.c_str ()); +void +TargetOptions::enable_implicit_feature_reqs (std::string feature) +{ + if (feature == "aes") + enable_implicit_feature_reqs ("sse2"); + else if (feature == "avx") + enable_implicit_feature_reqs ("sse4.2"); + else if (feature == "avx2") + enable_implicit_feature_reqs ("avx"); + else if (feature == "fma") + enable_implicit_feature_reqs ("avx"); + else if (feature == "pclmulqdq") + enable_implicit_feature_reqs ("sse2"); + else if (feature == "sha") + enable_implicit_feature_reqs ("sse2"); + else if (feature == "sse2") + enable_implicit_feature_reqs ("sse"); + else if (feature == "sse3") + enable_implicit_feature_reqs ("sse2"); + else if (feature == "sse4.1") + enable_implicit_feature_reqs ("sse3"); + else if (feature == "sse4.2") + enable_implicit_feature_reqs ("sse4.1"); + else if (feature == "ssse3") + enable_implicit_feature_reqs ("sse3"); + + if (!has_key_value_pair ("target_feature", feature)) + { + insert_key_value_pair ("target_feature", feature); + + fprintf (stderr, "had to implicitly enable feature '%s'!", + feature.c_str ()); } - } +} // NOTEs: /* mrustc compile pipeline: |