Skip to content

Commit 136c428

Browse files
committed
Merge commit '8fc4e6c397e1ce64bec6f9fed148950821cc79e7' into HEAD
Accordingly also adjust #2086 "break rust 💥" code, to avoid: [...]/source-gcc/gcc/rust/resolve/rust-ast-resolve-expr.cc: In member function ‘virtual void Rust::Resolver::ResolveExpr::visit(Rust::AST::IdentifierExpr&)’: [...]/source-gcc/gcc/rust/resolve/rust-ast-resolve-expr.cc:164:42: error: invalid conversion from ‘void (*)(diagnostic_context*, diagnostic_info*, diagnostic_t)’ to ‘diagnostic_finalizer_fn’ {aka ‘void (*)(diagnostic_context*, con iagnostic_info*, diagnostic_t)’} [-fpermissive] 164 | diagnostic_finalizer (global_dc) = funny_ice_finalizer; | ^~~~~~~~~~~~~~~~~~~ | | | void (*)(diagnostic_context*, diagnostic_info*, diagnostic_t)
2 parents d374f52 + 8fc4e6c commit 136c428

22 files changed

+92
-85
lines changed

gcc/c-family/c-opts.cc

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -168,7 +168,7 @@ c_common_option_lang_mask (void)
168168
/* Diagnostic finalizer for C/C++/Objective-C/Objective-C++. */
169169
static void
170170
c_diagnostic_finalizer (diagnostic_context *context,
171-
diagnostic_info *diagnostic,
171+
const diagnostic_info *diagnostic,
172172
diagnostic_t)
173173
{
174174
char *saved_prefix = pp_take_prefix (context->printer);

gcc/cp/cp-tree.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8083,7 +8083,7 @@ extern void cxx_print_type (FILE *, tree, int);
80838083
extern void cxx_print_identifier (FILE *, tree, int);
80848084
extern void cxx_print_error_function (diagnostic_context *,
80858085
const char *,
8086-
struct diagnostic_info *);
8086+
const diagnostic_info *);
80878087

80888088
/* in typeck.cc */
80898089
/* Says how we should behave when comparing two arrays one of which

gcc/cp/error.cc

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -101,8 +101,10 @@ static void print_instantiation_partial_context (diagnostic_context *,
101101
struct tinst_level *,
102102
location_t);
103103
static void maybe_print_constraint_context (diagnostic_context *);
104-
static void cp_diagnostic_starter (diagnostic_context *, diagnostic_info *);
105-
static void cp_print_error_function (diagnostic_context *, diagnostic_info *);
104+
static void cp_diagnostic_starter (diagnostic_context *,
105+
const diagnostic_info *);
106+
static void cp_print_error_function (diagnostic_context *,
107+
const diagnostic_info *);
106108

107109
static bool cp_printer (pretty_printer *, text_info *, const char *,
108110
int, bool, bool, bool, bool *, const char **);
@@ -3530,7 +3532,7 @@ eh_spec_to_string (tree p, int /*v*/)
35303532
/* Langhook for print_error_function. */
35313533
void
35323534
cxx_print_error_function (diagnostic_context *context, const char *file,
3533-
diagnostic_info *diagnostic)
3535+
const diagnostic_info *diagnostic)
35343536
{
35353537
char *prefix;
35363538
if (file)
@@ -3544,7 +3546,7 @@ cxx_print_error_function (diagnostic_context *context, const char *file,
35443546

35453547
static void
35463548
cp_diagnostic_starter (diagnostic_context *context,
3547-
diagnostic_info *diagnostic)
3549+
const diagnostic_info *diagnostic)
35483550
{
35493551
diagnostic_report_current_module (context, diagnostic_location (diagnostic));
35503552
cp_print_error_function (context, diagnostic);
@@ -3559,7 +3561,7 @@ cp_diagnostic_starter (diagnostic_context *context,
35593561
a diagnostic message. Called from cp_diagnostic_starter. */
35603562
static void
35613563
cp_print_error_function (diagnostic_context *context,
3562-
diagnostic_info *diagnostic)
3564+
const diagnostic_info *diagnostic)
35633565
{
35643566
/* If we are in an instantiation context, current_function_decl is likely
35653567
to be wrong, so just rely on print_instantiation_full_context. */

gcc/diagnostic-format-json.cc

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -43,12 +43,12 @@ class json_output_format : public diagnostic_output_format
4343
m_cur_children_array = nullptr;
4444
}
4545
void
46-
on_begin_diagnostic (diagnostic_info *) final override
46+
on_begin_diagnostic (const diagnostic_info &) final override
4747
{
4848
/* No-op. */
4949
}
5050
void
51-
on_end_diagnostic (diagnostic_info *diagnostic,
51+
on_end_diagnostic (const diagnostic_info &diagnostic,
5252
diagnostic_t orig_diag_kind) final override;
5353
void on_diagram (const diagnostic_diagram &) final override
5454
{
@@ -188,7 +188,7 @@ json_from_metadata (const diagnostic_metadata *metadata)
188188
within current diagnostic group. */
189189

190190
void
191-
json_output_format::on_end_diagnostic (diagnostic_info *diagnostic,
191+
json_output_format::on_end_diagnostic (const diagnostic_info &diagnostic,
192192
diagnostic_t orig_diag_kind)
193193
{
194194
json::object *diag_obj = new json::object ();
@@ -202,7 +202,7 @@ json_output_format::on_end_diagnostic (diagnostic_info *diagnostic,
202202
"must-not-happen"
203203
};
204204
/* Lose the trailing ": ". */
205-
const char *kind_text = diagnostic_kind_text[diagnostic->kind];
205+
const char *kind_text = diagnostic_kind_text[diagnostic.kind];
206206
size_t len = strlen (kind_text);
207207
gcc_assert (len > 2);
208208
gcc_assert (kind_text[len - 2] == ':');
@@ -217,15 +217,15 @@ json_output_format::on_end_diagnostic (diagnostic_info *diagnostic,
217217
diag_obj->set_string ("message", pp_formatted_text (m_context.printer));
218218
pp_clear_output_area (m_context.printer);
219219

220-
if (char *option_text = m_context.make_option_name (diagnostic->option_index,
220+
if (char *option_text = m_context.make_option_name (diagnostic.option_index,
221221
orig_diag_kind,
222-
diagnostic->kind))
222+
diagnostic.kind))
223223
{
224224
diag_obj->set_string ("option", option_text);
225225
free (option_text);
226226
}
227227

228-
if (char *option_url = m_context.make_option_url (diagnostic->option_index))
228+
if (char *option_url = m_context.make_option_url (diagnostic.option_index))
229229
{
230230
diag_obj->set_string ("option_url", option_url);
231231
free (option_url);
@@ -249,7 +249,7 @@ json_output_format::on_end_diagnostic (diagnostic_info *diagnostic,
249249
diag_obj->set_integer ("column-origin", m_context.m_column_origin);
250250
}
251251

252-
const rich_location *richloc = diagnostic->richloc;
252+
const rich_location *richloc = diagnostic.richloc;
253253

254254
json::array *loc_array = new json::array ();
255255
diag_obj->set ("locations", loc_array);
@@ -280,9 +280,9 @@ json_output_format::on_end_diagnostic (diagnostic_info *diagnostic,
280280
TODO: inlining information
281281
TODO: macro expansion information. */
282282

283-
if (diagnostic->metadata)
283+
if (diagnostic.metadata)
284284
{
285-
json::object *metadata_obj = json_from_metadata (diagnostic->metadata);
285+
json::object *metadata_obj = json_from_metadata (diagnostic.metadata);
286286
diag_obj->set ("metadata", metadata_obj);
287287
}
288288

gcc/diagnostic-format-sarif.cc

Lines changed: 29 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,7 @@ class sarif_invocation : public sarif_object
4848
{}
4949

5050
void add_notification_for_ice (diagnostic_context *context,
51-
diagnostic_info *diagnostic,
51+
const diagnostic_info &diagnostic,
5252
sarif_builder *builder);
5353
void prepare_to_flush (diagnostic_context *context);
5454

@@ -67,7 +67,7 @@ class sarif_result : public sarif_object
6767

6868
void
6969
on_nested_diagnostic (diagnostic_context *context,
70-
diagnostic_info *diagnostic,
70+
const diagnostic_info &diagnostic,
7171
diagnostic_t orig_diag_kind,
7272
sarif_builder *builder);
7373
void on_diagram (diagnostic_context *context,
@@ -90,7 +90,7 @@ class sarif_ice_notification : public sarif_object
9090
{
9191
public:
9292
sarif_ice_notification (diagnostic_context *context,
93-
diagnostic_info *diagnostic,
93+
const diagnostic_info &diagnostic,
9494
sarif_builder *builder);
9595
};
9696

@@ -159,15 +159,16 @@ class sarif_builder
159159
public:
160160
sarif_builder (diagnostic_context *context);
161161

162-
void end_diagnostic (diagnostic_context *context, diagnostic_info *diagnostic,
162+
void end_diagnostic (diagnostic_context *context,
163+
const diagnostic_info &diagnostic,
163164
diagnostic_t orig_diag_kind);
164165
void emit_diagram (diagnostic_context *context,
165166
const diagnostic_diagram &diagram);
166167
void end_group ();
167168

168169
void flush_to_file (FILE *outf);
169170

170-
json::array *make_locations_arr (diagnostic_info *diagnostic);
171+
json::array *make_locations_arr (const diagnostic_info &diagnostic);
171172
json::object *make_location_object (const rich_location &rich_loc,
172173
const logical_location *logical_loc);
173174
json::object *make_message_object (const char *msg) const;
@@ -177,7 +178,7 @@ class sarif_builder
177178

178179
private:
179180
sarif_result *make_result_object (diagnostic_context *context,
180-
diagnostic_info *diagnostic,
181+
const diagnostic_info &diagnostic,
181182
diagnostic_t orig_diag_kind);
182183
void set_any_logical_locs_arr (json::object *location_obj,
183184
const logical_location *logical_loc);
@@ -208,7 +209,7 @@ class sarif_builder
208209
json::object *make_tool_component_reference_object_for_cwe () const;
209210
json::object *
210211
make_reporting_descriptor_object_for_warning (diagnostic_context *context,
211-
diagnostic_info *diagnostic,
212+
const diagnostic_info &diagnostic,
212213
diagnostic_t orig_diag_kind,
213214
const char *option_text);
214215
json::object *make_reporting_descriptor_object_for_cwe_id (int cwe_id) const;
@@ -275,7 +276,7 @@ sarif_object::get_or_create_properties ()
275276

276277
void
277278
sarif_invocation::add_notification_for_ice (diagnostic_context *context,
278-
diagnostic_info *diagnostic,
279+
const diagnostic_info &diagnostic,
279280
sarif_builder *builder)
280281
{
281282
m_success = false;
@@ -310,15 +311,15 @@ sarif_invocation::prepare_to_flush (diagnostic_context *context)
310311

311312
void
312313
sarif_result::on_nested_diagnostic (diagnostic_context *context,
313-
diagnostic_info *diagnostic,
314+
const diagnostic_info &diagnostic,
314315
diagnostic_t /*orig_diag_kind*/,
315316
sarif_builder *builder)
316317
{
317318
/* We don't yet generate meaningful logical locations for notes;
318319
sometimes these will related to current_function_decl, but
319320
often they won't. */
320321
json::object *location_obj
321-
= builder->make_location_object (*diagnostic->richloc, NULL);
322+
= builder->make_location_object (*diagnostic.richloc, NULL);
322323
json::object *message_obj
323324
= builder->make_message_object (pp_formatted_text (context->printer));
324325
pp_clear_output_area (context->printer);
@@ -366,7 +367,7 @@ sarif_result::add_related_location (json::object *location_obj)
366367
DIAGNOSTIC is an internal compiler error. */
367368

368369
sarif_ice_notification::sarif_ice_notification (diagnostic_context *context,
369-
diagnostic_info *diagnostic,
370+
const diagnostic_info &diagnostic,
370371
sarif_builder *builder)
371372
{
372373
/* "locations" property (SARIF v2.1.0 section 3.58.4). */
@@ -416,10 +417,10 @@ sarif_builder::sarif_builder (diagnostic_context *context)
416417

417418
void
418419
sarif_builder::end_diagnostic (diagnostic_context *context,
419-
diagnostic_info *diagnostic,
420+
const diagnostic_info &diagnostic,
420421
diagnostic_t orig_diag_kind)
421422
{
422-
if (diagnostic->kind == DK_ICE || diagnostic->kind == DK_ICE_NOBT)
423+
if (diagnostic.kind == DK_ICE || diagnostic.kind == DK_ICE_NOBT)
423424
{
424425
m_invocation_obj->add_notification_for_ice (context, diagnostic, this);
425426
return;
@@ -528,16 +529,16 @@ make_rule_id_for_diagnostic_kind (diagnostic_t diag_kind)
528529

529530
sarif_result *
530531
sarif_builder::make_result_object (diagnostic_context *context,
531-
diagnostic_info *diagnostic,
532+
const diagnostic_info &diagnostic,
532533
diagnostic_t orig_diag_kind)
533534
{
534535
sarif_result *result_obj = new sarif_result ();
535536

536537
/* "ruleId" property (SARIF v2.1.0 section 3.27.5). */
537538
/* Ideally we'd have an option_name for these. */
538539
if (char *option_text
539-
= context->make_option_name (diagnostic->option_index,
540-
orig_diag_kind, diagnostic->kind))
540+
= context->make_option_name (diagnostic.option_index,
541+
orig_diag_kind, diagnostic.kind))
541542
{
542543
/* Lazily create reportingDescriptor objects for and add to m_rules_arr.
543544
Set ruleId referencing them. */
@@ -569,10 +570,10 @@ sarif_builder::make_result_object (diagnostic_context *context,
569570
free (rule_id);
570571
}
571572

572-
if (diagnostic->metadata)
573+
if (diagnostic.metadata)
573574
{
574575
/* "taxa" property (SARIF v2.1.0 section 3.27.8). */
575-
if (int cwe_id = diagnostic->metadata->get_cwe ())
576+
if (int cwe_id = diagnostic.metadata->get_cwe ())
576577
{
577578
json::array *taxa_arr = new json::array ();
578579
json::object *cwe_id_obj
@@ -581,11 +582,11 @@ sarif_builder::make_result_object (diagnostic_context *context,
581582
result_obj->set ("taxa", taxa_arr);
582583
}
583584

584-
diagnostic->metadata->maybe_add_sarif_properties (*result_obj);
585+
diagnostic.metadata->maybe_add_sarif_properties (*result_obj);
585586
}
586587

587588
/* "level" property (SARIF v2.1.0 section 3.27.10). */
588-
if (const char *sarif_level = maybe_get_sarif_level (diagnostic->kind))
589+
if (const char *sarif_level = maybe_get_sarif_level (diagnostic.kind))
589590
result_obj->set_string ("level", sarif_level);
590591

591592
/* "message" property (SARIF v2.1.0 section 3.27.11). */
@@ -599,7 +600,7 @@ sarif_builder::make_result_object (diagnostic_context *context,
599600
result_obj->set ("locations", locations_arr);
600601

601602
/* "codeFlows" property (SARIF v2.1.0 section 3.27.18). */
602-
if (const diagnostic_path *path = diagnostic->richloc->get_path ())
603+
if (const diagnostic_path *path = diagnostic.richloc->get_path ())
603604
{
604605
json::array *code_flows_arr = new json::array ();
605606
json::object *code_flow_obj = make_code_flow_object (*path);
@@ -612,7 +613,7 @@ sarif_builder::make_result_object (diagnostic_context *context,
612613
group. */
613614

614615
/* "fixes" property (SARIF v2.1.0 section 3.27.30). */
615-
const rich_location *richloc = diagnostic->richloc;
616+
const rich_location *richloc = diagnostic.richloc;
616617
if (richloc->get_num_fixit_hints ())
617618
{
618619
json::array *fix_arr = new json::array ();
@@ -630,7 +631,7 @@ sarif_builder::make_result_object (diagnostic_context *context,
630631
json::object *
631632
sarif_builder::
632633
make_reporting_descriptor_object_for_warning (diagnostic_context *context,
633-
diagnostic_info *diagnostic,
634+
const diagnostic_info &diagnostic,
634635
diagnostic_t /*orig_diag_kind*/,
635636
const char *option_text)
636637
{
@@ -643,7 +644,7 @@ make_reporting_descriptor_object_for_warning (diagnostic_context *context,
643644
it seems redundant compared to "id". */
644645

645646
/* "helpUri" property (SARIF v2.1.0 section 3.49.12). */
646-
if (char *option_url = context->make_option_url (diagnostic->option_index))
647+
if (char *option_url = context->make_option_url (diagnostic.option_index))
647648
{
648649
reporting_desc->set_string ("helpUri", option_url);
649650
free (option_url);
@@ -725,15 +726,15 @@ make_tool_component_reference_object_for_cwe () const
725726
- a "notification" object (SARIF v2.1.0 section 3.58.4). */
726727

727728
json::array *
728-
sarif_builder::make_locations_arr (diagnostic_info *diagnostic)
729+
sarif_builder::make_locations_arr (const diagnostic_info &diagnostic)
729730
{
730731
json::array *locations_arr = new json::array ();
731732
const logical_location *logical_loc = NULL;
732733
if (auto client_data_hooks = m_context->get_client_data_hooks ())
733734
logical_loc = client_data_hooks->get_current_logical_location ();
734735

735736
json::object *location_obj
736-
= make_location_object (*diagnostic->richloc, logical_loc);
737+
= make_location_object (*diagnostic.richloc, logical_loc);
737738
locations_arr->append (location_obj);
738739
return locations_arr;
739740
}
@@ -1704,12 +1705,12 @@ class sarif_output_format : public diagnostic_output_format
17041705
m_builder.end_group ();
17051706
}
17061707
void
1707-
on_begin_diagnostic (diagnostic_info *) final override
1708+
on_begin_diagnostic (const diagnostic_info &) final override
17081709
{
17091710
/* No-op, */
17101711
}
17111712
void
1712-
on_end_diagnostic (diagnostic_info *diagnostic,
1713+
on_end_diagnostic (const diagnostic_info &diagnostic,
17131714
diagnostic_t orig_diag_kind) final override
17141715
{
17151716
m_builder.end_diagnostic (&m_context, diagnostic, orig_diag_kind);

0 commit comments

Comments
 (0)