diff options
author | dmalcolm <dmalcolm@138bc75d-0d04-0410-961f-82ee72b054a4> | 2015-05-12 20:57:38 +0000 |
---|---|---|
committer | dmalcolm <dmalcolm@138bc75d-0d04-0410-961f-82ee72b054a4> | 2015-05-12 20:57:38 +0000 |
commit | e5f01cbafce70120afe8f73df099dcc2796adcd7 (patch) | |
tree | 59ac6b4ba6d59fb6b6bc0da54eaa2c8c9b71068d /gcc/c-family/c-common.h | |
parent | 5c5c1f00cfc6fb2f2e6e3721629ee0391a9a95b4 (diff) | |
download | gcc-e5f01cbafce70120afe8f73df099dcc2796adcd7.tar.gz |
Implement -Wmisleading-indentation
gcc/ChangeLog:
* doc/invoke.texi (Warning Options): Add -Wmisleading-indentation.
(-Wmisleading-indentation): New option.
* Makefile.in (C_COMMON_OBJS): Add c-family/c-indentation.o.
gcc/c-family/ChangeLog:
* c-common.h (warn_for_misleading_indentation): New prototype.
* c-indentation.c: New file.
* c.opt (Wmisleading-indentation): New option.
gcc/c/ChangeLog:
* c-parser.c (c_parser_if_body): Add param "if_loc", use it
to add a call to warn_for_misleading_indentation.
(c_parser_else_body): Likewise, adding param "else_loc".
(c_parser_if_statement): Check for misleading indentation.
(c_parser_while_statement): Likewise.
(c_parser_for_statement): Likewise.
gcc/cp/ChangeLog:
* parser.c (cp_parser_selection_statement): Add location and
guard_kind arguments to calls to
cp_parser_implicitly_scoped_statement.
(cp_parser_iteration_statement): Likewise for calls to
cp_parser_already_scoped_statement.
(cp_parser_implicitly_scoped_statement): Add "guard_loc" and
"guard_kind" params; use them to warn for misleading
indentation.
(cp_parser_already_scoped_statement): Likewise.
gcc/testsuite/ChangeLog:
* c-c++-common/Wmisleading-indentation.c: New testcase.
* c-c++-common/Wmisleading-indentation-2.c: New testcase.
* c-c++-common/Wmisleading-indentation-2.md: New file.
libcpp/ChangeLog:
* directives.c (do_line): Set seen_line_directive on line_table.
(do_linemarker): Likewise.
* include/line-map.h (struct line_maps): Add new field
"seen_line_directive".
git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@223098 138bc75d-0d04-0410-961f-82ee72b054a4
Diffstat (limited to 'gcc/c-family/c-common.h')
-rw-r--r-- | gcc/c-family/c-common.h | 8 |
1 files changed, 8 insertions, 0 deletions
diff --git a/gcc/c-family/c-common.h b/gcc/c-family/c-common.h index 5c1fa7b9868..444d80d3fed 100644 --- a/gcc/c-family/c-common.h +++ b/gcc/c-family/c-common.h @@ -1429,4 +1429,12 @@ extern bool contains_cilk_spawn_stmt (tree); extern tree cilk_for_number_of_iterations (tree); extern bool check_no_cilk (tree, const char *, const char *, location_t loc = UNKNOWN_LOCATION); +/* In c-indentation.c. */ +extern void +warn_for_misleading_indentation (location_t guard_loc, + location_t body_loc, + location_t next_stmt_loc, + enum cpp_ttype next_tok_type, + const char *guard_kind); + #endif /* ! GCC_C_COMMON_H */ |