summaryrefslogtreecommitdiff
path: root/gcc/c-family
diff options
context:
space:
mode:
authordmalcolm <dmalcolm@138bc75d-0d04-0410-961f-82ee72b054a4>2016-01-14 19:10:17 +0000
committerdmalcolm <dmalcolm@138bc75d-0d04-0410-961f-82ee72b054a4>2016-01-14 19:10:17 +0000
commita7ed45837eacff818524fdca94ce0c589aee9374 (patch)
tree5d6ecf5555c474502a0f17a07628d03e228b3ab7 /gcc/c-family
parentca5b12a4daf636c4c33ad670a90f4b16ec7bd089 (diff)
downloadgcc-a7ed45837eacff818524fdca94ce0c589aee9374.tar.gz
PR preprocessor/69177 and PR c++/68819: libcpp fallbacks and -Wmisleading-indentation
gcc/c-family/ChangeLog: PR c++/68819 * c-indentation.c (get_visual_column): Add location_t param. Handle the column number being zero by effectively disabling the warning, with an "inform". (should_warn_for_misleading_indentation): Add location_t argument for all uses of get_visual_column. gcc/testsuite/ChangeLog: PR c++/68819 PR preprocessor/69177 * gcc.dg/plugin/location-overflow-test-1.c: New test case. * gcc.dg/plugin/location-overflow-test-2.c: New test case. * gcc.dg/plugin/location_overflow_plugin.c: New test plugin. * gcc.dg/plugin/plugin.exp (plugin_test_list): Add the above. libcpp/ChangeLog: PR preprocessor/69177 * line-map.c (LINE_MAP_MAX_LOCATION_WITH_PACKED_RANGES): New constant. (LINE_MAP_MAX_LOCATION_WITH_COLS): Add note about unit tests to comment. (can_be_stored_compactly_p): Reduce threshold from LINE_MAP_MAX_LOCATION_WITH_COLS to LINE_MAP_MAX_LOCATION_WITH_PACKED_RANGES. (get_combined_adhoc_loc): Likewise. (get_range_from_loc): Likewise. (linemap_line_start): Ensure that a new ordinary map is created when transitioning from range-packing being enabled to disabled, at the LINE_MAP_MAX_LOCATION_WITH_PACKED_RANGES threshold. Set range_bits to 0 for new ordinary maps when beyond this limit. Prevent the "increase the column bits of a freshly created map" optimization if the range bits has reduced. git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@232379 138bc75d-0d04-0410-961f-82ee72b054a4
Diffstat (limited to 'gcc/c-family')
-rw-r--r--gcc/c-family/ChangeLog9
-rw-r--r--gcc/c-family/c-indentation.c31
2 files changed, 35 insertions, 5 deletions
diff --git a/gcc/c-family/ChangeLog b/gcc/c-family/ChangeLog
index d8282d9de47..e3b9654c85b 100644
--- a/gcc/c-family/ChangeLog
+++ b/gcc/c-family/ChangeLog
@@ -1,3 +1,12 @@
+2016-01-14 David Malcolm <dmalcolm@redhat.com>
+
+ PR c++/68819
+ * c-indentation.c (get_visual_column): Add location_t param.
+ Handle the column number being zero by effectively disabling the
+ warning, with an "inform".
+ (should_warn_for_misleading_indentation): Add location_t argument
+ for all uses of get_visual_column.
+
2016-01-10 Patrick Palka <ppalka@gcc.gnu.org>
PR c++/69029
diff --git a/gcc/c-family/c-indentation.c b/gcc/c-family/c-indentation.c
index cd9637dc3fe..521f9924fd0 100644
--- a/gcc/c-family/c-indentation.c
+++ b/gcc/c-family/c-indentation.c
@@ -36,10 +36,30 @@ extern cpp_options *cpp_opts;
on the line. */
static bool
-get_visual_column (expanded_location exploc,
+get_visual_column (expanded_location exploc, location_t loc,
unsigned int *out,
unsigned int *first_nws)
{
+ /* PR c++/68819: if the column number is zero, we presumably
+ had a location_t > LINE_MAP_MAX_LOCATION_WITH_COLS, and so
+ we have no column information.
+ Act as if no conversion was possible, triggering the
+ error-handling path in the caller. */
+ if (!exploc.column)
+ {
+ static bool issued_note = false;
+ if (!issued_note)
+ {
+ /* Notify the user the first time this happens. */
+ issued_note = true;
+ inform (loc,
+ "-Wmisleading-indentation is disabled from this point"
+ " onwards, since column-tracking was disabled due to"
+ " the size of the code/headers");
+ }
+ return false;
+ }
+
int line_len;
const char *line = location_get_source_line (exploc.file, exploc.line,
&line_len);
@@ -297,7 +317,7 @@ should_warn_for_misleading_indentation (const token_indent_info &guard_tinfo,
gcc_assert (guard_exploc.line == next_stmt_exploc.line);
unsigned int guard_vis_column;
unsigned int guard_line_first_nws;
- if (!get_visual_column (guard_exploc,
+ if (!get_visual_column (guard_exploc, guard_loc,
&guard_vis_column,
&guard_line_first_nws))
return false;
@@ -357,14 +377,15 @@ should_warn_for_misleading_indentation (const token_indent_info &guard_tinfo,
the case for input files containing #line directives, and these
are often for autogenerated sources (e.g. from .md files), where
it's not clear that it's meaningful to look at indentation. */
- if (!get_visual_column (next_stmt_exploc, &next_stmt_vis_column,
+ if (!get_visual_column (next_stmt_exploc, next_stmt_loc,
+ &next_stmt_vis_column,
&next_stmt_line_first_nws))
return false;
- if (!get_visual_column (body_exploc,
+ if (!get_visual_column (body_exploc, body_loc,
&body_vis_column,
&body_line_first_nws))
return false;
- if (!get_visual_column (guard_exploc,
+ if (!get_visual_column (guard_exploc, guard_loc,
&guard_vis_column,
&guard_line_first_nws))
return false;