No functional change intended.
gcc/c-family/ChangeLog:
* c-common.cc: Update for renaming of diagnostic_option_id to
diagnostics::option_id.
* c-common.h: Likewise.
* c-cppbuiltin.cc: Likewise.
* known-headers.cc: Likewise.
* known-headers.h: Likewise.
gcc/c/ChangeLog:
* c-decl.cc: Update for renaming of diagnostic_option_id to
diagnostics::option_id.
* c-errors.cc: Likewise.
* c-tree.h: Likewise.
gcc/cobol/ChangeLog:
* util.cc: Update for renaming of diagnostic_option_id to
diagnostics::option_id.
gcc/cp/ChangeLog:
* cp-tree.h: Update for renaming of diagnostic_option_id to
diagnostics::option_id.
* decl.cc: Likewise.
* error.cc: Likewise.
* name-lookup.cc: Likewise.
gcc/ChangeLog:
* diagnostic-core.h: Include "diagnostics/option-id.h".
(struct diagnostic_option_id): Move there, renaming to
diagnostics::option_id.
* diagnostic-global-context.cc: Update for renaming of
diagnostic_option_id to diagnostics::option_id.
* diagnostic.cc: Likewise.
* diagnostic.h: Likewise.
* diagnostics/context.h: Likewise.
* diagnostics/diagnostic-info.h: Likewise.
* diagnostics/lazy-paths.cc: Likewise.
* diagnostics/option-classifier.cc: Likewise.
* diagnostics/option-classifier.h: Likewise.
* diagnostics/option-id.h: New file, taken from material in
diagnostic-core.h.
* diagnostics/selftest-context.cc: Update for renaming of
diagnostic_option_id to diagnostics::option_id.
* diagnostics/selftest-context.h: Likewise.
* ipa-pure-const.cc: Likewise.
* lto-wrapper.cc: Likewise.
* opts-common.cc: Likewise.
* opts-diagnostic.h: Likewise.
* opts.cc: Likewise.
* substring-locations.cc: Likewise.
* substring-locations.h: Likewise.
gcc/fortran/ChangeLog:
* cpp.cc: Update for renaming of
diagnostic_option_id to diagnostics::option_id.
Signed-off-by: David Malcolm <dmalcolm@redhat.com>
/* Return the gcc option code associated with the reason for a cpp
message, or 0 if none. */
-static diagnostic_option_id
+static diagnostics::option_id
c_option_controlling_cpp_diagnostic (enum cpp_warning_reason reason)
{
const struct cpp_reason_option_codes_t *entry;
extern void fe_file_change (const line_map_ordinary *);
extern void c_parse_error (const char *, enum cpp_ttype, tree, unsigned char,
rich_location *richloc);
-extern diagnostic_option_id get_option_for_builtin_define (const char *macro_name);
+extern diagnostics::option_id get_option_for_builtin_define (const char *macro_name);
/* In c-ppoutput.cc */
extern void init_pp_output (FILE *);
/* Given NAME, return the command-line option that would make it be
a builtin define, or 0 if unrecognized. */
-diagnostic_option_id
+diagnostics::option_id
get_option_for_builtin_define (const char *name)
{
if (!strcmp (name, "_OPENACC"))
/* suggest_missing_option's ctor. */
-suggest_missing_option::suggest_missing_option (location_t loc,
- const char *macro_name,
- diagnostic_option_id option_id)
+suggest_missing_option::
+suggest_missing_option (location_t loc,
+ const char *macro_name,
+ diagnostics::option_id option_id)
: deferred_diagnostic (loc), m_name_str (macro_name), m_option_id (option_id)
{
gcc_assert (macro_name);
{
public:
suggest_missing_option (location_t loc, const char *name,
- diagnostic_option_id option_id);
+ diagnostics::option_id option_id);
~suggest_missing_option ();
private:
const char *m_name_str;
- diagnostic_option_id m_option_id;
+ diagnostics::option_id m_option_id;
};
#endif /* GCC_KNOWN_HEADERS_H */
/* Next, look for exact matches for builtin defines that would have been
defined if the user had passed a command-line option (e.g. -fopenmp
for "_OPENMP"). */
- diagnostic_option_id option_id
+ diagnostics::option_id option_id
= get_option_for_builtin_define (IDENTIFIER_POINTER (name));
if (option_id.m_idx > 0)
return name_hint
bool
pedwarn_c23 (location_t location,
- diagnostic_option_id option_id,
+ diagnostics::option_id option_id,
const char *gmsgid, ...)
{
diagnostic_info diagnostic;
bool
pedwarn_c11 (location_t location,
- diagnostic_option_id option_id,
+ diagnostics::option_id option_id,
const char *gmsgid, ...)
{
diagnostic_info diagnostic;
bool
pedwarn_c99 (location_t location,
- diagnostic_option_id option_id,
+ diagnostics::option_id option_id,
const char *gmsgid, ...)
{
diagnostic_info diagnostic;
bool
pedwarn_c90 (location_t location,
- diagnostic_option_id option_id,
+ diagnostics::option_id option_id,
const char *gmsgid, ...)
{
diagnostic_info diagnostic;
extern bool tag_exists_p (enum tree_code, tree);
/* In c-errors.cc */
-extern bool pedwarn_c90 (location_t, diagnostic_option_id, const char *, ...)
+extern bool pedwarn_c90 (location_t, diagnostics::option_id, const char *, ...)
ATTRIBUTE_GCC_DIAG(3,4);
-extern bool pedwarn_c99 (location_t, diagnostic_option_id, const char *, ...)
+extern bool pedwarn_c99 (location_t, diagnostics::option_id, const char *, ...)
ATTRIBUTE_GCC_DIAG(3,4);
-extern bool pedwarn_c11 (location_t, diagnostic_option_id, const char *, ...)
+extern bool pedwarn_c11 (location_t, diagnostics::option_id, const char *, ...)
ATTRIBUTE_GCC_DIAG(3,4);
-extern bool pedwarn_c23 (location_t, diagnostic_option_id, const char *, ...)
+extern bool pedwarn_c23 (location_t, diagnostics::option_id, const char *, ...)
ATTRIBUTE_GCC_DIAG(3,4);
extern void add_note_about_new_keyword (location_t loc,
tree keyword_id);
}
#endif
-static const diagnostic_option_id option_zero;
+static const diagnostics::option_id option_zero;
size_t parse_error_inc();
void gcc_location_dump() {
extern void maybe_warn_cpp0x (cpp0x_warn_str str,
location_t = input_location);
extern bool pedwarn_cxx98 (location_t,
- diagnostic_option_id option_id,
+ diagnostics::option_id option_id,
const char *, ...) ATTRIBUTE_GCC_DIAG(3,4);
extern location_t location_of (tree);
extern void qualified_name_lookup_error (tree, tree, tree,
has_errored = true;
emit_diagnostic (diag_kind,
DECL_SOURCE_LOCATION (decl),
- /*diagnostic_option_id=*/0,
+ /*diagnostics::option_id=*/0,
"friend declaration of %qD specifies default "
"arguments and isn%'t a definition", decl);
}
C++0x. */
bool
pedwarn_cxx98 (location_t location,
- diagnostic_option_id option_id,
+ diagnostics::option_id option_id,
const char *gmsgid, ...)
{
diagnostic_info diagnostic;
/* Look for exact matches for builtin defines that would have been
defined if the user had passed a command-line option (e.g. -fopenmp
for "_OPENMP"). */
- diagnostic_option_id option_id
+ diagnostics::option_id option_id
= get_option_for_builtin_define (IDENTIFIER_POINTER (name));
if (option_id.m_idx > 0)
return name_hint
#define GCC_DIAGNOSTIC_CORE_H
#include "bversion.h"
+#include "diagnostics/option-id.h"
/* Constants used to discriminate diagnostics. */
typedef enum
class metadata; /* See diagnostics/metadata.h. */
} // namespace diagnostics
-/* A class to use for the ID of an option that controls
- a particular diagnostic.
- This is just a wrapper around "int", but better documents
- the intent of the code. */
-
-struct diagnostic_option_id
-{
- diagnostic_option_id () : m_idx (0) {}
-
- diagnostic_option_id (int idx) : m_idx (idx) {}
- /* Ideally we'd take an enum opt_code here, but we don't
- want to depend on its decl. */
-
- bool operator== (diagnostic_option_id other) const
- {
- return m_idx == other.m_idx;
- }
-
- int m_idx;
-};
-
extern const char *progname;
extern const char *trim_filename (const char *);
extern void internal_error_no_backtrace (const char *, ...)
ATTRIBUTE_GCC_DIAG(1,2) ATTRIBUTE_NORETURN;
/* Pass one of the OPT_W* from options.h as the first parameter. */
-extern bool warning (diagnostic_option_id,
+extern bool warning (diagnostics::option_id,
const char *, ...) ATTRIBUTE_GCC_DIAG(2,3);
extern bool warning_n (location_t,
- diagnostic_option_id,
+ diagnostics::option_id,
unsigned HOST_WIDE_INT,
const char *, const char *, ...)
ATTRIBUTE_GCC_DIAG(4,6) ATTRIBUTE_GCC_DIAG(5,6);
extern bool warning_n (rich_location *,
- diagnostic_option_id,
+ diagnostics::option_id,
unsigned HOST_WIDE_INT,
const char *, const char *, ...)
ATTRIBUTE_GCC_DIAG(4, 6) ATTRIBUTE_GCC_DIAG(5, 6);
extern bool warning_at (location_t,
- diagnostic_option_id,
+ diagnostics::option_id,
const char *, ...)
ATTRIBUTE_GCC_DIAG(3,4);
extern bool warning_at (rich_location *,
- diagnostic_option_id,
+ diagnostics::option_id,
const char *, ...)
ATTRIBUTE_GCC_DIAG(3,4);
extern bool warning_meta (rich_location *,
const diagnostics::metadata &,
- diagnostic_option_id,
+ diagnostics::option_id,
const char *, ...)
ATTRIBUTE_GCC_DIAG(4,5);
extern void error (const char *, ...) ATTRIBUTE_GCC_DIAG(1,2);
ATTRIBUTE_NORETURN;
/* Pass one of the OPT_W* from options.h as the second parameter. */
extern bool pedwarn (location_t,
- diagnostic_option_id,
+ diagnostics::option_id,
const char *, ...)
ATTRIBUTE_GCC_DIAG(3,4);
extern bool pedwarn (rich_location *,
- diagnostic_option_id,
+ diagnostics::option_id,
const char *, ...)
ATTRIBUTE_GCC_DIAG(3,4);
extern bool permerror (location_t, const char *, ...) ATTRIBUTE_GCC_DIAG(2,3);
extern bool permerror (rich_location *, const char *,
...) ATTRIBUTE_GCC_DIAG(2,3);
extern bool permerror_opt (location_t,
- diagnostic_option_id,
+ diagnostics::option_id,
const char *, ...)
ATTRIBUTE_GCC_DIAG(3,4);
extern bool permerror_opt (rich_location *,
- diagnostic_option_id,
+ diagnostics::option_id,
const char *, ...)
ATTRIBUTE_GCC_DIAG(3,4);
extern void sorry (const char *, ...) ATTRIBUTE_GCC_DIAG(1,2);
extern void verbatim (const char *, ...) ATTRIBUTE_GCC_DIAG(1,2);
extern bool emit_diagnostic (diagnostic_t,
location_t,
- diagnostic_option_id,
+ diagnostics::option_id,
const char *, ...) ATTRIBUTE_GCC_DIAG(4,5);
extern bool emit_diagnostic (diagnostic_t,
rich_location *,
- diagnostic_option_id,
+ diagnostics::option_id,
const char *, ...) ATTRIBUTE_GCC_DIAG(4,5);
extern bool emit_diagnostic_valist (diagnostic_t,
location_t,
- diagnostic_option_id,
+ diagnostics::option_id,
const char *, va_list *)
ATTRIBUTE_GCC_DIAG (4,0);
extern bool emit_diagnostic_valist_meta (diagnostic_t,
rich_location *,
const diagnostics::metadata *,
- diagnostic_option_id,
+ diagnostics::option_id,
const char *,
va_list *) ATTRIBUTE_GCC_DIAG (5,0);
extern bool seen_error (void);
bool
emit_diagnostic (diagnostic_t kind,
location_t location,
- diagnostic_option_id option_id,
+ diagnostics::option_id option_id,
const char *gmsgid, ...)
{
auto_diagnostic_group d;
bool
emit_diagnostic (diagnostic_t kind,
rich_location *richloc,
- diagnostic_option_id option_id,
+ diagnostics::option_id option_id,
const char *gmsgid, ...)
{
auto_diagnostic_group d;
bool
emit_diagnostic_valist (diagnostic_t kind,
location_t location,
- diagnostic_option_id option_id,
+ diagnostics::option_id option_id,
const char *gmsgid, va_list *ap)
{
rich_location richloc (line_table, location);
emit_diagnostic_valist_meta (diagnostic_t kind,
rich_location *richloc,
const diagnostics::metadata *metadata,
- diagnostic_option_id option_id,
+ diagnostics::option_id option_id,
const char *gmsgid, va_list *ap)
{
return global_dc->diagnostic_impl (richloc, metadata, option_id,
to the relevant language specification but is likely to be buggy anyway.
Returns true if the warning was printed, false if it was inhibited. */
bool
-warning (diagnostic_option_id option_id, const char *gmsgid, ...)
+warning (diagnostics::option_id option_id, const char *gmsgid, ...)
{
auto_diagnostic_group d;
va_list ap;
bool
warning_at (location_t location,
- diagnostic_option_id option_id,
+ diagnostics::option_id option_id,
const char *gmsgid, ...)
{
auto_diagnostic_group d;
bool
warning_at (rich_location *richloc,
- diagnostic_option_id option_id,
+ diagnostics::option_id option_id,
const char *gmsgid, ...)
{
gcc_assert (richloc);
bool
warning_meta (rich_location *richloc,
const diagnostics::metadata &metadata,
- diagnostic_option_id option_id,
+ diagnostics::option_id option_id,
const char *gmsgid, ...)
{
gcc_assert (richloc);
bool
warning_n (rich_location *richloc,
- diagnostic_option_id option_id,
+ diagnostics::option_id option_id,
unsigned HOST_WIDE_INT n,
const char *singular_gmsgid, const char *plural_gmsgid, ...)
{
bool
warning_n (location_t location,
- diagnostic_option_id option_id,
+ diagnostics::option_id option_id,
unsigned HOST_WIDE_INT n,
const char *singular_gmsgid, const char *plural_gmsgid, ...)
{
bool
pedwarn (location_t location,
- diagnostic_option_id option_id,
+ diagnostics::option_id option_id,
const char *gmsgid, ...)
{
auto_diagnostic_group d;
bool
pedwarn (rich_location *richloc,
- diagnostic_option_id option_id,
+ diagnostics::option_id option_id,
const char *gmsgid, ...)
{
gcc_assert (richloc);
bool
permerror_opt (location_t location,
- diagnostic_option_id option_id,
+ diagnostics::option_id option_id,
const char *gmsgid, ...)
{
auto_diagnostic_group d;
bool
permerror_opt (rich_location *richloc,
- diagnostic_option_id option_id,
+ diagnostics::option_id option_id,
const char *gmsgid, ...)
{
gcc_assert (richloc);
return true;
}
-/* Returns whether warning OPTION_ID is enabled at LOC. */
+/* Returns whether warning OPT_ID is enabled at LOC. */
bool
diagnostics::context::warning_enabled_at (location_t loc,
- diagnostic_option_id option_id)
+ diagnostics::option_id opt_id)
{
if (!diagnostic_report_warnings_p (this, loc))
return false;
rich_location richloc (line_table, loc);
diagnostic_info diagnostic = {};
- diagnostic.m_option_id = option_id;
+ diagnostic.m_option_id = opt_id;
diagnostic.m_richloc = &richloc;
diagnostic.m_message.m_richloc = &richloc;
diagnostic.m_kind = DK_WARNING;
emit_diagnostic_with_group (diagnostic_t kind,
rich_location &richloc,
const diagnostics::metadata *metadata,
- diagnostic_option_id option_id,
+ diagnostics::option_id opt_id,
const char *gmsgid, ...)
{
begin_group ();
va_list ap;
va_start (ap, gmsgid);
- bool ret = emit_diagnostic_with_group_va (kind, richloc, metadata, option_id,
+ bool ret = emit_diagnostic_with_group_va (kind, richloc, metadata, opt_id,
gmsgid, &ap);
va_end (ap);
emit_diagnostic_with_group_va (diagnostic_t kind,
rich_location &richloc,
const diagnostics::metadata *metadata,
- diagnostic_option_id option_id,
+ diagnostics::option_id opt_id,
const char *gmsgid, va_list *ap)
{
begin_group ();
- bool ret = diagnostic_impl (&richloc, metadata, option_id,
+ bool ret = diagnostic_impl (&richloc, metadata, opt_id,
gmsgid, ap, kind);
end_group ();
bool
diagnostics::context::diagnostic_impl (rich_location *richloc,
const diagnostics::metadata *metadata,
- diagnostic_option_id option_id,
+ diagnostics::option_id opt_id,
const char *gmsgid,
va_list *ap, diagnostic_t kind)
{
{
diagnostic_set_info (&diagnostic, gmsgid, ap, richloc,
m_permissive ? DK_WARNING : DK_ERROR);
- diagnostic.m_option_id = (option_id.m_idx != -1 ? option_id : m_opt_permissive);
+ diagnostic.m_option_id = (opt_id.m_idx != -1 ? opt_id : m_opt_permissive);
}
else
{
diagnostic_set_info (&diagnostic, gmsgid, ap, richloc, kind);
if (kind == DK_WARNING || kind == DK_PEDWARN)
- diagnostic.m_option_id = option_id;
+ diagnostic.m_option_id = opt_id;
}
diagnostic.m_metadata = metadata;
return report_diagnostic (&diagnostic);
bool
diagnostics::context::diagnostic_n_impl (rich_location *richloc,
const diagnostics::metadata *metadata,
- diagnostic_option_id option_id,
+ diagnostics::option_id opt_id,
unsigned HOST_WIDE_INT n,
const char *singular_gmsgid,
const char *plural_gmsgid,
const char *text = ngettext (singular_gmsgid, plural_gmsgid, gtn);
diagnostic_set_info_translated (&diagnostic, text, ap, richloc, kind);
if (kind == DK_WARNING)
- diagnostic.m_option_id = option_id;
+ diagnostic.m_option_id = opt_id;
diagnostic.m_metadata = metadata;
return report_diagnostic (&diagnostic);
}
inline void
diagnostic_set_option_id (diagnostic_info *info,
- diagnostic_option_id option_id)
+ diagnostics::option_id opt_id)
{
- info->m_option_id = option_id;
+ info->m_option_id = opt_id;
}
/* Diagnostic related functions. */
/* Force diagnostics controlled by OPTIDX to be kind KIND. */
inline diagnostic_t
diagnostic_classify_diagnostic (diagnostics::context *context,
- diagnostic_option_id option_id,
+ diagnostics::option_id opt_id,
diagnostic_t kind,
location_t where)
{
- return context->classify_diagnostic (option_id, kind, where);
+ return context->classify_diagnostic (opt_id, kind, where);
}
inline void
extern int num_digits (int);
inline bool
-warning_enabled_at (location_t loc, diagnostic_option_id option_id)
+warning_enabled_at (location_t loc, diagnostics::option_id opt_id)
{
- return global_dc->warning_enabled_at (loc, option_id);
+ return global_dc->warning_enabled_at (loc, opt_id);
}
inline bool
-option_unspecified_p (diagnostic_option_id option_id)
+option_unspecified_p (diagnostics::option_id opt_id)
{
- return global_dc->option_unspecified_p (option_id);
+ return global_dc->option_unspecified_p (opt_id);
}
extern char *get_cwe_url (int cwe);
public:
virtual ~option_manager () {}
- /* Return 1 if option OPTION_ID is enabled, 0 if it is disabled,
+ /* Return 1 if option OPT_ID is enabled, 0 if it is disabled,
or -1 if it isn't a simple on-off switch
(or if the value is unknown, typically set later in target). */
- virtual int option_enabled_p (diagnostic_option_id option_id) const = 0;
+ virtual int option_enabled_p (option_id opt_id) const = 0;
- /* Return malloced memory for the name of the option OPTION_ID
+ /* Return malloced memory for the name of the option OPT_ID
which enabled a diagnostic, originally of type ORIG_DIAG_KIND but
possibly converted to DIAG_KIND by options such as -Werror.
May return NULL if no name is to be printed.
May be passed 0 as well as the index of a particular option. */
- virtual char *make_option_name (diagnostic_option_id option_id,
+ virtual char *make_option_name (option_id opt_id,
diagnostic_t orig_diag_kind,
diagnostic_t diag_kind) const = 0;
a diagnostic.
May return NULL if no URL is available.
May be passed 0 as well as the index of a particular option. */
- virtual char *make_option_url (diagnostic_option_id option_id) const = 0;
+ virtual char *make_option_url (option_id opt_id) const = 0;
};
/* A bundle of options relating to printing the user's source code
void push_nesting_level ();
void pop_nesting_level ();
- bool warning_enabled_at (location_t loc, diagnostic_option_id option_id);
+ bool warning_enabled_at (location_t loc, option_id opt_id);
- bool option_unspecified_p (diagnostic_option_id option_id) const
+ bool option_unspecified_p (option_id opt_id) const
{
- return m_option_classifier.option_unspecified_p (option_id);
+ return m_option_classifier.option_unspecified_p (opt_id);
}
bool emit_diagnostic_with_group (diagnostic_t kind,
rich_location &richloc,
const metadata *metadata,
- diagnostic_option_id option_id,
+ option_id opt_id,
const char *gmsgid, ...)
ATTRIBUTE_GCC_DIAG(6,7);
bool emit_diagnostic_with_group_va (diagnostic_t kind,
rich_location &richloc,
const metadata *metadata,
- diagnostic_option_id option_id,
+ option_id opt_id,
const char *gmsgid, va_list *ap)
ATTRIBUTE_GCC_DIAG(6,0);
report_global_digraph (const digraphs::lazy_digraph &);
diagnostic_t
- classify_diagnostic (diagnostic_option_id option_id,
+ classify_diagnostic (option_id opt_id,
diagnostic_t new_kind,
location_t where)
{
return m_option_classifier.classify_diagnostic (this,
- option_id,
+ opt_id,
new_kind,
where);
}
}
/* Option-related member functions. */
- inline bool option_enabled_p (diagnostic_option_id option_id) const
+ inline bool option_enabled_p (option_id opt_id) const
{
if (!m_option_mgr)
return true;
- return m_option_mgr->option_enabled_p (option_id);
+ return m_option_mgr->option_enabled_p (opt_id);
}
- inline char *make_option_name (diagnostic_option_id option_id,
+ inline char *make_option_name (option_id opt_id,
diagnostic_t orig_diag_kind,
diagnostic_t diag_kind) const
{
if (!m_option_mgr)
return nullptr;
- return m_option_mgr->make_option_name (option_id,
+ return m_option_mgr->make_option_name (opt_id,
orig_diag_kind,
diag_kind);
}
- inline char *make_option_url (diagnostic_option_id option_id) const
+ inline char *make_option_url (option_id opt_id) const
{
if (!m_option_mgr)
return nullptr;
- return m_option_mgr->make_option_url (option_id);
+ return m_option_mgr->make_option_url (opt_id);
}
void
}
bool diagnostic_impl (rich_location *, const metadata *,
- diagnostic_option_id, const char *,
+ option_id, const char *,
va_list *, diagnostic_t) ATTRIBUTE_GCC_DIAG(5,0);
bool diagnostic_n_impl (rich_location *, const metadata *,
- diagnostic_option_id, unsigned HOST_WIDE_INT,
+ option_id, unsigned HOST_WIDE_INT,
const char *, const char *, va_list *,
diagnostic_t) ATTRIBUTE_GCC_DIAG(7,0);
void set_main_input_filename (const char *filename);
void
- set_permissive_option (diagnostic_option_id opt_permissive)
+ set_permissive_option (option_id opt_permissive)
{
m_opt_permissive = opt_permissive;
}
private:
/* The option to associate with turning permerrors into warnings,
if any. */
- diagnostic_option_id m_opt_permissive;
+ option_id m_opt_permissive;
/* True if errors are fatal. */
bool m_fatal_errors;
/* The kind of diagnostic it is about. */
diagnostic_t m_kind;
/* Which OPT_* directly controls this diagnostic. */
- diagnostic_option_id m_option_id;
+ option_id m_option_id;
/* Inlining context containing locations for each call site along
the inlining stack. */
/* Implementation of diagnostics::option_manager for which all
options are disabled, for use in selftests.
- Note that this is *not* called for diagnostic_option_id (0), which
+ Note that this is *not* called for option_id (0), which
means "always warn" */
class all_warnings_disabled : public diagnostics::option_manager
{
public:
- int option_enabled_p (diagnostic_option_id) const final override
+ int option_enabled_p (diagnostics::option_id) const final override
{
/* Treat all options as disabled. */
return 0;
}
- char *make_option_name (diagnostic_option_id,
+ char *make_option_name (diagnostics::option_id,
diagnostic_t,
diagnostic_t) const final override
{
return nullptr;
}
- char *make_option_url (diagnostic_option_id) const final override
+ char *make_option_url (diagnostics::option_id) const final override
{
return nullptr;
}
test_rich_location rich_loc (*event_pp);
ASSERT_FALSE (rich_loc.m_path.generated_p ());
- diagnostic_option_id option_id (42); // has to be non-zero
+ diagnostics::option_id opt_id (42); // has to be non-zero
bool emitted
= dc.emit_diagnostic_with_group (DK_WARNING, rich_loc, nullptr,
- option_id,
+ opt_id,
"this warning should be skipped");
ASSERT_FALSE (emitted);
ASSERT_FALSE (rich_loc.m_path.generated_p ());
diagnostic_t
option_classifier::classify_diagnostic (const context *dc,
- diagnostic_option_id option_id,
+ option_id opt_id,
diagnostic_t new_kind,
location_t where)
{
diagnostic_t old_kind;
- if (option_id.m_idx < 0
- || option_id.m_idx >= m_n_opts
+ if (opt_id.m_idx < 0
+ || opt_id.m_idx >= m_n_opts
|| new_kind >= DK_LAST_DIAGNOSTIC_KIND)
return DK_UNSPECIFIED;
- old_kind = m_classify_diagnostic[option_id.m_idx];
+ old_kind = m_classify_diagnostic[opt_id.m_idx];
/* Handle pragmas separately, since we need to keep track of *where*
the pragmas were. */
/* Record the command-line status, so we can reset it back on DK_POP. */
if (old_kind == DK_UNSPECIFIED)
{
- old_kind = (!dc->option_enabled_p (option_id)
+ old_kind = (!dc->option_enabled_p (opt_id)
? DK_IGNORED : DK_ANY);
- m_classify_diagnostic[option_id.m_idx] = old_kind;
+ m_classify_diagnostic[opt_id.m_idx] = old_kind;
}
classification_change_t *p;
FOR_EACH_VEC_ELT_REVERSE (m_classification_history, i, p)
- if (p->option == option_id.m_idx)
+ if (p->option == opt_id.m_idx)
{
old_kind = p->kind;
break;
}
classification_change_t v
- = { where, option_id.m_idx, new_kind };
+ = { where, opt_id.m_idx, new_kind };
m_classification_history.safe_push (v);
}
else
- m_classify_diagnostic[option_id.m_idx] = new_kind;
+ m_classify_diagnostic[opt_id.m_idx] = new_kind;
return old_kind;
}
continue;
}
- diagnostic_option_id option = p->option;
+ option_id opt_id = p->option;
/* The option 0 is for all the diagnostics. */
- if (option == 0 || option == diagnostic->m_option_id)
+ if (opt_id == 0 || opt_id == diagnostic->m_option_id)
{
diagnostic_t kind = p->kind;
if (kind != DK_UNSPECIFIED)
is empty, revert to the state based on command line parameters. */
void pop (location_t where);
- bool option_unspecified_p (diagnostic_option_id option_id) const
+ bool option_unspecified_p (option_id opt_id) const
{
- return get_current_override (option_id) == DK_UNSPECIFIED;
+ return get_current_override (opt_id) == DK_UNSPECIFIED;
}
- diagnostic_t get_current_override (diagnostic_option_id option_id) const
+ diagnostic_t get_current_override (option_id opt_id) const
{
- gcc_assert (option_id.m_idx < m_n_opts);
- return m_classify_diagnostic[option_id.m_idx];
+ gcc_assert (opt_id.m_idx < m_n_opts);
+ return m_classify_diagnostic[opt_id.m_idx];
}
diagnostic_t
classify_diagnostic (const context *context,
- diagnostic_option_id option_id,
+ option_id opt_id,
diagnostic_t new_kind,
location_t where);
--- /dev/null
+/* Declaration of struct diagnostics::option_id.
+ Copyright (C) 2024-2025 Free Software Foundation, Inc.
+ Contributed by David Malcolm <dmalcolm@redhat.com>.
+
+This file is part of GCC.
+
+GCC is free software; you can redistribute it and/or modify it under
+the terms of the GNU General Public License as published by the Free
+Software Foundation; either version 3, or (at your option) any later
+version.
+
+GCC is distributed in the hope that it will be useful, but WITHOUT ANY
+WARRANTY; without even the implied warranty of MERCHANTABILITY or
+FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
+for more details.
+
+You should have received a copy of the GNU General Public License
+along with GCC; see the file COPYING3. If not see
+<http://www.gnu.org/licenses/>. */
+
+#ifndef GCC_DIAGNOSTICS_OPTION_ID_H
+#define GCC_DIAGNOSTICS_OPTION_ID_H
+
+namespace diagnostics {
+
+/* A class to use for the ID of an option that controls
+ a particular diagnostic.
+ This is just a wrapper around "int", but better documents
+ the intent of the code. */
+
+struct option_id
+{
+ option_id () : m_idx (0) {}
+
+ option_id (int idx) : m_idx (idx) {}
+ /* Ideally we'd take an enum opt_code here, but we don't
+ want to depend on its decl. */
+
+ bool operator== (option_id other) const
+ {
+ return m_idx == other.m_idx;
+ }
+
+ int m_idx;
+};
+
+} // namespace diagnostics
+
+#endif /* ! GCC_DIAGNOSTICS_OPTION_ID_H */
test_context::report (diagnostic_t kind,
rich_location &richloc,
const metadata *metadata_,
- diagnostic_option_id option,
+ option_id opt_id,
const char * fmt, ...)
{
va_list ap;
va_start (ap, fmt);
begin_group ();
- bool result = diagnostic_impl (&richloc, metadata_, option, fmt, &ap, kind);
+ bool result = diagnostic_impl (&richloc, metadata_, opt_id, fmt, &ap, kind);
end_group ();
va_end (ap);
return result;
report (diagnostic_t kind,
rich_location &richloc,
const metadata *,
- diagnostic_option_id option,
+ option_id opt_id,
const char * fmt, ...) ATTRIBUTE_GCC_DIAG(6,7);
const char *test_show_locus (rich_location &richloc);
/* Return the gcc option code associated with the reason for a cpp
message, or 0 if none. */
-static diagnostic_option_id
+static diagnostics::option_id
cb_cpp_diagnostic_cpp_option (enum cpp_warning_reason reason)
{
const struct cpp_reason_option_codes_t *entry;
by the function. */
static hash_set<tree> *
-suggest_attribute (diagnostic_option_id option, tree decl, bool known_finite,
+suggest_attribute (diagnostics::option_id option, tree decl, bool known_finite,
hash_set<tree> *warned_about,
const char * attrib_name)
{
: gcc_diagnostic_option_manager (0 /* lang_mask */)
{
}
- int option_enabled_p (diagnostic_option_id) const final override
+ int option_enabled_p (diagnostics::option_id) const final override
{
return true;
}
- char *make_option_name (diagnostic_option_id,
+ char *make_option_name (diagnostics::option_id,
diagnostic_t,
diagnostic_t) const final override
{
int
compiler_diagnostic_option_manager::
-option_enabled_p (diagnostic_option_id opt_id) const
+option_enabled_p (diagnostics::option_id opt_id) const
{
return option_enabled (opt_id.m_idx, m_lang_mask, m_opts);
}
class gcc_diagnostic_option_manager : public diagnostics::option_manager
{
public:
- char *make_option_url (diagnostic_option_id option_id) const final override;
+ char *make_option_url (diagnostics::option_id option_id) const final override;
protected:
gcc_diagnostic_option_manager (unsigned lang_mask)
{
}
- int option_enabled_p (diagnostic_option_id option_id) const final override;
- char *make_option_name (diagnostic_option_id option_id,
+ int option_enabled_p (diagnostics::option_id option_id) const final override;
+ char *make_option_name (diagnostics::option_id option_id,
diagnostic_t orig_diag_kind,
diagnostic_t diag_kind) const final override;
char *
compiler_diagnostic_option_manager::
-make_option_name (diagnostic_option_id option_id,
+make_option_name (diagnostics::option_id option_id,
diagnostic_t orig_diag_kind,
diagnostic_t diag_kind) const
{
char *
gcc_diagnostic_option_manager::
-make_option_url (diagnostic_option_id option_id) const
+make_option_url (diagnostics::option_id option_id) const
{
if (option_id.m_idx)
{
Return true if a warning was emitted, false otherwise. */
bool
-format_string_diagnostic_t::emit_warning_n_va (diagnostic_option_id option_id,
+format_string_diagnostic_t::emit_warning_n_va (diagnostics::option_id option_id,
unsigned HOST_WIDE_INT n,
const char *singular_gmsgid,
const char *plural_gmsgid,
/* Singular-only version of the above. */
bool
-format_string_diagnostic_t::emit_warning_va (diagnostic_option_id option_id,
+format_string_diagnostic_t::emit_warning_va (diagnostics::option_id option_id,
const char *gmsgid,
va_list *ap) const
{
/* Variadic version of the above (singular only). */
bool
-format_string_diagnostic_t::emit_warning (diagnostic_option_id option_id,
+format_string_diagnostic_t::emit_warning (diagnostics::option_id option_id,
const char *gmsgid,
...) const
{
/* Variadic version of the above (singular vs plural). */
bool
-format_string_diagnostic_t::emit_warning_n (diagnostic_option_id option_id,
+format_string_diagnostic_t::emit_warning_n (diagnostics::option_id option_id,
unsigned HOST_WIDE_INT n,
const char *singular_gmsgid,
const char *plural_gmsgid,
/* Functions for emitting a warning about a format string. */
- bool emit_warning_va (diagnostic_option_id option_id,
+ bool emit_warning_va (diagnostics::option_id option_id,
const char *gmsgid,
va_list *ap) const
ATTRIBUTE_GCC_DIAG (3, 0);
- bool emit_warning_n_va (diagnostic_option_id option_id,
+ bool emit_warning_n_va (diagnostics::option_id option_id,
unsigned HOST_WIDE_INT n,
const char *singular_gmsgid,
const char *plural_gmsgid,
va_list *ap) const
ATTRIBUTE_GCC_DIAG (4, 0) ATTRIBUTE_GCC_DIAG (5, 0);
- bool emit_warning (diagnostic_option_id option_id,
+ bool emit_warning (diagnostics::option_id option_id,
const char *gmsgid, ...) const
ATTRIBUTE_GCC_DIAG (3, 4);
- bool emit_warning_n (diagnostic_option_id option_id,
+ bool emit_warning_n (diagnostics::option_id option_id,
unsigned HOST_WIDE_INT n,
const char *singular_gmsgid,
const char *plural_gmsgid, ...) const