Common Joined UInteger Var(diagnostics_minimum_margin_width) Init(6)
Set minimum width of left margin of source code when showing source.
+fdiagnostics-show-nesting
+Common Var(flag_diagnostics_show_nesting) Init(1)
+Use indentation to show nesting of diagnostics in text output.
+
+fdiagnostics-show-nesting-locations
+Common Var(flag_diagnostics_show_nesting_locations) Init(1)
+Show location information when showing nested diagnostics.
+
+fdiagnostics-show-nesting-levels
+Common Var(flag_diagnostics_show_nesting_levels) Init(0)
+Show nesting levels as numbers when showing nested diagnostics.
+
fdisable-
Common Joined RejectNegative Var(common_deferred_options) Defer
-fdisable-[tree|rtl|ipa]-<pass>=range1+range2 Disable an optimization pass.
fdiagnostics-minimum-margin-width=
UrlSuffix(gcc/Diagnostic-Message-Formatting-Options.html#index-fdiagnostics-minimum-margin-width)
+fdiagnostics-show-nesting
+UrlSuffix(gcc/Diagnostic-Message-Formatting-Options.html#index-fdiagnostics-show-nesting)
+
+fdiagnostics-show-nesting-locations
+UrlSuffix(gcc/Diagnostic-Message-Formatting-Options.html#index-fdiagnostics-show-nesting-locations)
+
+fdiagnostics-show-nesting-levels
+UrlSuffix(gcc/Diagnostic-Message-Formatting-Options.html#index-fdiagnostics-show-nesting-levels)
+
fdisable-
UrlSuffix(gcc/Developer-Options.html#index-fdisable-)
(m_reference_printer->get_url_format ());
}
+void
+context::set_show_nesting (bool val)
+{
+ for (auto sink_ : m_sinks)
+ if (sink_->follows_reference_printer_p ())
+ if (auto text_sink_ = sink_->dyn_cast_text_sink ())
+ text_sink_->set_show_nesting (val);
+}
+
+void
+context::set_show_nesting_locations (bool val)
+{
+ for (auto sink_ : m_sinks)
+ if (sink_->follows_reference_printer_p ())
+ if (auto text_sink_ = sink_->dyn_cast_text_sink ())
+ text_sink_->set_show_locations_in_nesting (val);
+}
+
+void
+context::set_show_nesting_levels (bool val)
+{
+ for (auto sink_ : m_sinks)
+ if (sink_->follows_reference_printer_p ())
+ if (auto text_sink_ = sink_->dyn_cast_text_sink ())
+ text_sink_->set_show_nesting_levels (val);
+}
+
/* Create the file_cache, if not already created, and tell it how to
translate files on input. */
void
}
void set_show_path_depths (bool val) { m_show_path_depths = val; }
void set_show_option_requested (bool val) { m_show_option_requested = val; }
+ void set_show_nesting (bool val);
+ void set_show_nesting_locations (bool val);
+ void set_show_nesting_levels (bool val);
void set_max_errors (int val) { m_max_errors = val; }
void set_escape_format (enum diagnostics_escape_format val)
{
}
}
-// For ease of comparison with experimental-nesting-show-levels=yes
+// For ease of comparison with show-nesting-levels=yes
static void
add_nesting_level_attr (xml::element &element,
const scheme_name_and_params &parsed_arg) const
{
bool show_color = pp_show_color (dc.get_reference_printer ());
- bool show_nesting = false;
+ bool show_nesting = true;
bool show_locations_in_nesting = true;
bool show_levels = false;
for (auto& iter : parsed_arg.m_kvs)
return nullptr;
continue;
}
- if (key == "experimental-nesting")
+ if (key == "show-nesting")
{
if (!parse_bool_value (ctxt, unparsed_arg, key, value,
show_nesting))
return nullptr;
continue;
}
- if (key == "experimental-nesting-show-locations")
+ if (key == "show-nesting-locations")
{
if (!parse_bool_value (ctxt, unparsed_arg, key, value,
show_locations_in_nesting))
return nullptr;
continue;
}
- if (key == "experimental-nesting-show-levels")
+ if (key == "show-nesting-levels")
{
if (!parse_bool_value (ctxt, unparsed_arg, key, value, show_levels))
return nullptr;
/* Key not found. */
auto_vec<const char *> known_keys;
known_keys.safe_push ("color");
- known_keys.safe_push ("experimental-nesting");
- known_keys.safe_push ("experimental-nesting-show-locations");
- known_keys.safe_push ("experimental-nesting-show-levels");
+ known_keys.safe_push ("show-nesting");
+ known_keys.safe_push ("show-nesting-locations");
+ known_keys.safe_push ("show-nesting-levels");
ctxt.report_unknown_key (unparsed_arg, key, get_scheme_name (),
known_keys);
return nullptr;
public:
virtual ~sink () {}
+ virtual text_sink *dyn_cast_text_sink () { return nullptr; }
+
virtual void dump_kind (FILE *out) const = 0;
virtual void dump (FILE *out, int indent) const;
{}
~text_sink ();
+ text_sink *dyn_cast_text_sink () final override { return this; }
+
void dump_kind (FILE *out) const override
{
fprintf (out, "text_sink");
-fno-diagnostics-show-cwe
-fno-diagnostics-show-rules
-fno-diagnostics-show-highlight-colors
+-fno-diagnostics-show-nesting
+-fno-diagnostics-show-nesting-locations
+-fdiagnostics-show-nesting-levels
-fdiagnostics-minimum-margin-width=@var{width}
-fdiagnostics-parseable-fixits -fdiagnostics-generate-patch
-fdiagnostics-show-template-tree -fno-elide-type
-fdiagnostics-urls=never
-fdiagnostics-path-format=separate-events
-fdiagnostics-text-art-charset=none
--fno-diagnostics-show-event-links}
+-fno-diagnostics-show-event-links
+-fno-diagnostics-show-nesting}
In the future, if GCC changes the default appearance of its diagnostics, the
corresponding option to disable the new behavior will be added to this list.
The default is @samp{emoji}, except when the environment variable @env{LANG}
is set to @samp{C}, in which case the default is @samp{ascii}.
+@opindex fno-diagnostics-show-nesting
+@opindex fdiagnostics-show-nesting
+@item -fno-diagnostics-show-nesting
+Some GCC diagnostics have an internal tree-like structure of nested
+sub-diagnostics, such as for problems when instantiating C++ templates.
+
+By default GCC uses indentation and bullet points in its text output to
+show the nesting structure of these diagnostics, moves location
+information to separate lines to make the structure clearer, and
+eliminates redundant repeated information.
+
+Selecting @option{-fno-diagnostics-show-nesting} suppresses this
+indentation, reformatting, and elision, restoring an older `look'' for the
+diagnostics.
+
+@opindex fno-diagnostics-show-nesting-locations
+@opindex fdiagnostics-show-nesting-locations
+@item -fno-diagnostics-show-nesting-locations
+
+When @option{fdiagnostics-show-nesting} is enabled, file names and
+line- and column- numbers are displayed on separate lines from the
+messages. This location information can be disabled altogether with
+@option{-fno-diagnostics-show-nesting-locations}.
+This option exists for use by GCC developers, for writing DejaGnu test cases.
+
+@opindex fdiagnostics-show-nesting-levels
+@opindex fno-diagnostics-show-nesting-levels
+@item -fdiagnostics-show-nesting-levels
+When @option{fdiagnostics-show-nesting} is enabled, use
+@option{fdiagnostics-show-nesting-levels} to also display numbers
+showing the depth of the nesting.
+This option exists for use by GCC developers for debugging nested
+diagnostics, but may be of use to plugin authors.
+
@opindex fdiagnostics-format
@item -fdiagnostics-format=@var{FORMAT}
Select a different format for printing diagnostics.
Override colorization settings from @option{-fdiagnostics-color} for this
text output.
-@item experimental-nesting=@r{[}yes@r{|}no@r{]}
-Enable an experimental mode that emphasizes hierarchical relationships
-within diagnostics messages, displaying location information on separate
-lines.
+@item show-nesting=@r{[}yes@r{|}no@r{]}
+Enable a mode that emphasizes hierarchical relationships
+within diagnostics messages, as per @option{-fdiagnostics-show-nesting}.
+Defaults to @code{yes}.
-@item experimental-nesting-show-locations=@r{[}yes@r{|}no@r{]}
-If @code{experimental-nesting=yes}, then by default locations are
+@item show-nesting-locations=@r{[}yes@r{|}no@r{]}
+If @code{show-nesting=yes}, then by default locations are
shown; set this key to @code{no} to disable printing such locations.
This exists for use by GCC developers, for writing DejaGnu test cases.
-@item experimental-nesting-show-levels=@r{[}yes@r{|}no@r{]}
-This is a debugging option for use with @code{experimental-nesting=yes}.
+@item show-nesting-levels=@r{[}yes@r{|}no@r{]}
+This is a debugging option for use with @code{show-nesting=yes}.
Set this key to @code{yes} to print explicit nesting levels in the output.
This exists for use by GCC developers.
case OPT_fdiagnostics_show_line_numbers:
case OPT_fdiagnostics_show_option:
case OPT_fdiagnostics_show_location_:
+ case OPT_fdiagnostics_show_nesting:
+ case OPT_fdiagnostics_show_nesting_locations:
+ case OPT_fdiagnostics_show_nesting_levels:
case OPT_fshow_column:
case OPT_fcommon:
case OPT_fgnu_tm:
case OPT_fdiagnostics_show_line_numbers:
case OPT_fdiagnostics_show_option:
case OPT_fdiagnostics_show_location_:
+ case OPT_fdiagnostics_show_nesting:
+ case OPT_fdiagnostics_show_nesting_locations:
+ case OPT_fdiagnostics_show_nesting_levels:
case OPT_fshow_column:
case OPT_fPIC:
case OPT_fpic:
case OPT_fdiagnostics_show_line_numbers:
case OPT_fdiagnostics_show_option:
case OPT_fdiagnostics_show_location_:
+ case OPT_fdiagnostics_show_nesting:
+ case OPT_fdiagnostics_show_nesting_locations:
+ case OPT_fdiagnostics_show_nesting_levels:
case OPT_fshow_column:
break;
default:
"-fdiagnostics-urls=never",
"-fdiagnostics-path-format=separate-events",
"-fdiagnostics-text-art-charset=none",
- "-fno-diagnostics-show-event-links"
+ "-fno-diagnostics-show-event-links",
+ "-fno-diagnostics-show-nesting"
/* We don't put "-fno-diagnostics-show-highlight-colors" here
as -fdiagnostics-color=never makes it redundant. */
};
dc->set_show_option_requested (value);
break;
+ case OPT_fdiagnostics_show_nesting:
+ dc->set_show_nesting (value);
+ break;
+
+ case OPT_fdiagnostics_show_nesting_locations:
+ dc->set_show_nesting_locations (value);
+ break;
+
+ case OPT_fdiagnostics_show_nesting_levels:
+ dc->set_show_nesting_levels (value);
+ break;
+
case OPT_fdiagnostics_minimum_margin_width_:
dc->get_source_printing_options ().min_margin_width = value;
break;
case OPT_fdiagnostics_show_line_numbers:
case OPT_fdiagnostics_color_:
case OPT_fdiagnostics_format_:
+ case OPT_fdiagnostics_show_nesting:
+ case OPT_fdiagnostics_show_nesting_locations:
+ case OPT_fdiagnostics_show_nesting_levels:
case OPT_fverbose_asm:
case OPT____:
case OPT__sysroot_:
// { dg-do compile { target c++17 } }
// { dg-options "-fconcepts" }
-// { dg-additional-options "-fdiagnostics-set-output=text:experimental-nesting=yes,experimental-nesting-show-locations=no" }
+// { dg-additional-options "-fdiagnostics-set-output=text:show-nesting=yes,show-nesting-locations=no" }
struct dog {};
struct cat {};
// { dg-do compile { target c++17 } }
// { dg-options "-fconcepts" }
-// { dg-additional-options "-fdiagnostics-set-output=text:experimental-nesting=yes,experimental-nesting-show-locations=no" }
+// { dg-additional-options "-fdiagnostics-set-output=text:show-nesting=yes,show-nesting-locations=no" }
// { dg-additional-options "-fconcepts-diagnostics-depth=3" }
struct dog {};
// { dg-do compile { target c++17 } }
// { dg-options "-fconcepts" }
-// { dg-additional-options "-fdiagnostics-set-output=text:experimental-nesting=yes,experimental-nesting-show-locations=no" }
+// { dg-additional-options "-fdiagnostics-set-output=text:show-nesting=yes,show-nesting-locations=no" }
struct dog{};
struct cat{};
--- /dev/null
+/* { dg-do compile } */
+/* { dg-options "-fno-diagnostics-show-nesting" } */
+
+extern void foo (void);
+
+void test_nesting (void)
+{
+ foo (); /* { dg-error "top-level error" } */
+}
--- /dev/null
+/* { dg-do compile } */
+/* { dg-options "-fdiagnostics-show-nesting" } */
+
+extern void foo (void);
+
+void test_nesting (void)
+{
+ foo (); /* { dg-error "top-level error" } */
+}
+
+/* { dg-begin-multiline-output "" }
+ * child 0
+ * grandchild 0 0
+ * grandchild 0 1
+ * grandchild 0 2
+ * child 1
+ * grandchild 1 0
+ * grandchild 1 1
+ * grandchild 1 2
+ * child 2
+ * grandchild 2 0
+ * grandchild 2 1
+ * grandchild 2 2
+ { dg-end-multiline-output "" } */
/* { dg-do compile } */
-/* { dg-options "-fdiagnostics-set-output=text:experimental-nesting=yes,experimental-nesting-show-levels=yes" } */
+/* { dg-options "-fdiagnostics-set-output=text:show-nesting=yes,show-nesting-levels=yes" } */
extern void foo (void);
/* { dg-do compile } */
-/* { dg-options "-fdiagnostics-set-output=text:experimental-nesting=yes -fdiagnostics-text-art-charset=unicode" } */
+/* { dg-options "-fdiagnostics-set-output=text:show-nesting=yes -fdiagnostics-text-art-charset=unicode" } */
extern void foo (void);
/* { dg-do compile } */
-/* { dg-options "-fdiagnostics-set-output=text:experimental-nesting=yes" } */
+/* { dg-options "-fdiagnostics-set-output=text:show-nesting=yes" } */
extern void foo (void);
diagnostic-test-graphs-html.c \
diagnostic-test-graphs-sarif.c } \
{ diagnostic_plugin_test_nesting.cc \
+ diagnostic-test-nesting-show-nesting.c \
+ diagnostic-test-nesting-no-show-nesting.c \
diagnostic-test-nesting-text-plain.c \
diagnostic-test-nesting-text-indented.c \
diagnostic-test-nesting-text-indented-show-levels.c \
= global_options_init.x_flag_show_column;
global_dc->set_show_highlight_colors
(global_options_init.x_flag_diagnostics_show_highlight_colors);
+ global_dc->set_show_nesting
+ (global_options_init.x_flag_diagnostics_show_nesting);
+ global_dc->set_show_nesting_locations
+ (global_options_init.x_flag_diagnostics_show_nesting_locations);
+ global_dc->set_show_nesting_levels
+ (global_options_init.x_flag_diagnostics_show_nesting_levels);
global_dc->set_internal_error_callback (internal_error_function);
const unsigned lang_mask = lang_hooks.option_lang_mask ();
global_dc->set_option_id_manager