diff options
author | Mark Wielaard <mark@klomp.org> | 2020-05-22 01:10:50 +0200 |
---|---|---|
committer | Mark Wielaard <mark@klomp.org> | 2020-06-04 01:22:52 +0200 |
commit | 9eea5d2ddf73037e21b59bcd8084ba969ae10174 (patch) | |
tree | fc247b15b760343e12c8472d91d08634b9340557 /gcc/tree-ssa-phiopt.c | |
parent | 34e4962aed08b38f37e37242234bfbbd1b897f39 (diff) | |
download | gcc-9eea5d2ddf73037e21b59bcd8084ba969ae10174.zip gcc-9eea5d2ddf73037e21b59bcd8084ba969ae10174.tar.gz gcc-9eea5d2ddf73037e21b59bcd8084ba969ae10174.tar.bz2 |
Provide diagnostic hints for missing C inttypes.h string constants.
This adds a flag to c_parser so we know when we were trying to
construct a string literal. If there is a parse error and we were
constructing a string literal, and the next token is an unknown
identifier name, and we know there is a standard header that defines
that name as a string literal, then add a missing header hint to
the error messsage.
The list of macro names are also used when providing a hint for
missing identifiers.
gcc/c-family/ChangeLog:
* known-headers.cc (get_string_macro_hint): New function.
(get_stdlib_header_for_name): Use get_string_macro_hint.
(get_c_stdlib_header_for_string_macro_name): New function.
* known-headers.h (get_c_stdlib_header_for_string_macro_name):
New function declaration.
gcc/c/ChangeLog:
* c-parser.c (struct c_parser): Add seen_string_literal
bitfield.
(c_parser_consume_token): Reset seen_string_literal.
(c_parser_error_richloc): Add name_hint if seen_string_literal
and next token is a CPP_NAME and we have a missing header
suggestion for the name.
(c_parser_string_literal): Set seen_string_literal.
gcc/testsuite/ChangeLog:
* gcc.dg/spellcheck-inttypes.c: New test.
* g++.dg/spellcheck-inttypes.C: Likewise.
Diffstat (limited to 'gcc/tree-ssa-phiopt.c')
0 files changed, 0 insertions, 0 deletions