diff options
author | Eric Botcazou <ebotcazou@adacore.com> | 2018-01-10 23:14:49 +0000 |
---|---|---|
committer | Eric Botcazou <ebotcazou@gcc.gnu.org> | 2018-01-10 23:14:49 +0000 |
commit | 68dc87c3600fe0b6b629b45e5efc058c32b7bccc (patch) | |
tree | 03daab767b941cb7e519f462abf28e90a617ce76 | |
parent | 8cad5b143e23668e4b59596972b2249ce2d2d637 (diff) | |
download | gcc-68dc87c3600fe0b6b629b45e5efc058c32b7bccc.zip gcc-68dc87c3600fe0b6b629b45e5efc058c32b7bccc.tar.gz gcc-68dc87c3600fe0b6b629b45e5efc058c32b7bccc.tar.bz2 |
c-ada-spec.c (dump_number): Add FLOAT_P parameter.
* c-ada-spec.c (dump_number): Add FLOAT_P parameter.
Skip 'f' and 'F' characters if it is true.
(store_ada_macro): Minor tweak.
(dump_ada_macros) <CPP_COMMENT>: Likewise.
<CPP_WSTRING>: Likewise.
<CPP_STRING>: Output '&' in the buffer if not the first string.
<CPP_NUMBER>: Adjust calls to dump_number.
From-SVN: r256463
-rw-r--r-- | gcc/c-family/ChangeLog | 10 | ||||
-rw-r--r-- | gcc/c-family/c-ada-spec.c | 53 |
2 files changed, 44 insertions, 19 deletions
diff --git a/gcc/c-family/ChangeLog b/gcc/c-family/ChangeLog index d6b6085..1e490af 100644 --- a/gcc/c-family/ChangeLog +++ b/gcc/c-family/ChangeLog @@ -1,3 +1,13 @@ +2018-01-10 Eric Botcazou <ebotcazou@adacore.com> + + * c-ada-spec.c (dump_number): Add FLOAT_P parameter. + Skip 'f' and 'F' characters if it is true. + (store_ada_macro): Minor tweak. + (dump_ada_macros) <CPP_COMMENT>: Likewise. + <CPP_WSTRING>: Likewise. + <CPP_STRING>: Output '&' in the buffer if not the first string. + <CPP_NUMBER>: Adjust calls to dump_number. + 2018-01-10 David Malcolm <dmalcolm@redhat.com> PR c++/43486 diff --git a/gcc/c-family/c-ada-spec.c b/gcc/c-family/c-ada-spec.c index 070555e..914ded9 100644 --- a/gcc/c-family/c-ada-spec.c +++ b/gcc/c-family/c-ada-spec.c @@ -113,14 +113,15 @@ macro_length (const cpp_macro *macro, int *supported, int *buffer_len, } /* Dump all digits/hex chars from NUMBER to BUFFER and return a pointer - to the character after the last character written. */ + to the character after the last character written. If FLOAT_P is true, + this is a floating-point number. */ static unsigned char * -dump_number (unsigned char *number, unsigned char *buffer) +dump_number (unsigned char *number, unsigned char *buffer, bool float_p) { while (*number != '\0' - && *number != 'U' - && *number != 'u' + && *number != (float_p ? 'F' : 'U') + && *number != (float_p ? 'f' : 'u') && *number != 'l' && *number != 'L') *buffer++ = *number++; @@ -192,7 +193,8 @@ store_ada_macro (cpp_reader *pfile ATTRIBUTE_UNUSED, { const cpp_macro *macro = node->value.macro; - if (node->type == NT_MACRO && !(node->flags & NODE_BUILTIN) + if (node->type == NT_MACRO + && !(node->flags & NODE_BUILTIN) && macro->count && *NODE_NAME (node) != '_' && LOCATION_FILE (macro->line) == macro_source_file) @@ -345,7 +347,8 @@ dump_ada_macros (pretty_printer *pp, const char* file) is_one = prev_is_one; break; - case CPP_COMMENT: break; + case CPP_COMMENT: + break; case CPP_WSTRING: case CPP_STRING16: @@ -359,11 +362,18 @@ dump_ada_macros (pretty_printer *pp, const char* file) if (!macro->fun_like) supported = 0; else - buffer = cpp_spell_token (parse_in, token, buffer, false); + buffer + = cpp_spell_token (parse_in, token, buffer, false); break; case CPP_STRING: - is_string = 1; + if (is_string) + { + *buffer++ = '&'; + *buffer++ = ' '; + } + else + is_string = 1; { const unsigned char *s = token->val.str.text; @@ -428,7 +438,7 @@ dump_ada_macros (pretty_printer *pp, const char* file) *buffer++ = '1'; *buffer++ = '6'; *buffer++ = '#'; - buffer = dump_number (tmp + 2, buffer); + buffer = dump_number (tmp + 2, buffer, false); *buffer++ = '#'; break; @@ -436,19 +446,20 @@ dump_ada_macros (pretty_printer *pp, const char* file) case 'B': *buffer++ = '2'; *buffer++ = '#'; - buffer = dump_number (tmp + 2, buffer); + buffer = dump_number (tmp + 2, buffer, false); *buffer++ = '#'; break; default: - /* Dump floating constants unmodified. */ + /* Dump floating-point constant unmodified. */ if (strchr ((const char *)tmp, '.')) - buffer = dump_number (tmp, buffer); + buffer = dump_number (tmp, buffer, true); else { *buffer++ = '8'; *buffer++ = '#'; - buffer = dump_number (tmp + 1, buffer); + buffer + = dump_number (tmp + 1, buffer, false); *buffer++ = '#'; } break; @@ -456,19 +467,23 @@ dump_ada_macros (pretty_printer *pp, const char* file) break; case '1': - if (tmp[1] == '\0' || tmp[1] == 'l' || tmp[1] == 'u' - || tmp[1] == 'L' || tmp[1] == 'U') + if (tmp[1] == '\0' + || tmp[1] == 'u' + || tmp[1] == 'U' + || tmp[1] == 'l' + || tmp[1] == 'L') { is_one = 1; char_one = buffer; *buffer++ = '1'; + break; } - else - buffer = dump_number (tmp, buffer); - break; + /* fallthrough */ default: - buffer = dump_number (tmp, buffer); + buffer + = dump_number (tmp, buffer, + strchr ((const char *)tmp, '.')); break; } break; |