#include "config.h"
#include "system.h"
#include "coretypes.h"
+#include "c-common.h"
#include "tm.h"
#include "intl.h"
#include "tree.h"
#include "trans-mem.h"
#include "flags.h"
#include "c-pragma.h"
-#include "c-common.h"
#include "c-objc.h"
#include "tm_p.h"
#include "obstack.h"
#undef catenate_messages
}
-/* Mapping for cpp message reasons to the options that enable them. */
-
-struct reason_option_codes_t
-{
- const int reason; /* cpplib message reason. */
- const int option_code; /* gcc option that controls this message. */
-};
-
-static const struct reason_option_codes_t option_codes[] = {
- {CPP_W_BUILTIN_MACRO_REDEFINED, OPT_Wbuiltin_macro_redefined},
- {CPP_W_C90_C99_COMPAT, OPT_Wc90_c99_compat},
- {CPP_W_COMMENTS, OPT_Wcomment},
- {CPP_W_CXX_OPERATOR_NAMES, OPT_Wc___compat},
- {CPP_W_DATE_TIME, OPT_Wdate_time},
- {CPP_W_DEPRECATED, OPT_Wdeprecated},
- {CPP_W_ENDIF_LABELS, OPT_Wendif_labels},
- {CPP_W_INVALID_PCH, OPT_Winvalid_pch},
- {CPP_W_LITERAL_SUFFIX, OPT_Wliteral_suffix},
- {CPP_W_LONG_LONG, OPT_Wlong_long},
- {CPP_W_MISSING_INCLUDE_DIRS, OPT_Wmissing_include_dirs},
- {CPP_W_MULTICHAR, OPT_Wmultichar},
- {CPP_W_NORMALIZE, OPT_Wnormalized_},
- {CPP_W_PEDANTIC, OPT_Wpedantic},
- {CPP_W_TRADITIONAL, OPT_Wtraditional},
- {CPP_W_TRIGRAPHS, OPT_Wtrigraphs},
- {CPP_W_UNDEF, OPT_Wundef},
- {CPP_W_UNUSED_MACROS, OPT_Wunused_macros},
- {CPP_W_VARIADIC_MACROS, OPT_Wvariadic_macros},
- {CPP_W_WARNING_DIRECTIVE, OPT_Wcpp},
- {CPP_W_NONE, 0}
-};
-
/* Return the gcc option code associated with the reason for a cpp
message, or 0 if none. */
static int
c_option_controlling_cpp_error (int reason)
{
- const struct reason_option_codes_t *entry;
+ const struct cpp_reason_option_codes_t *entry;
- for (entry = option_codes; entry->reason != CPP_W_NONE; entry++)
+ for (entry = cpp_reason_option_codes; entry->reason != CPP_W_NONE; entry++)
{
if (entry->reason == reason)
return entry->option_code;
Warn about boolean expression compared with an integer value different from true/false
Wbuiltin-macro-redefined
-C ObjC C++ ObjC++ CPP(warn_builtin_macro_redefined) Var(cpp_warn_builtin_macro_redefined) Init(1) Warning
+C ObjC C++ ObjC++ CPP(warn_builtin_macro_redefined) CppReason(CPP_W_BUILTIN_MACRO_REDEFINED) Var(cpp_warn_builtin_macro_redefined) Init(1) Warning
Warn when a built-in preprocessor macro is undefined or redefined
Wc90-c99-compat
-C ObjC CPP(cpp_warn_c90_c99_compat) Var(warn_c90_c99_compat) Init(-1) Warning
+C ObjC CPP(cpp_warn_c90_c99_compat) CppReason(CPP_W_C90_C99_COMPAT) Var(warn_c90_c99_compat) Init(-1) Warning
Warn about features not present in ISO C90, but present in ISO C99
Wc99-c11-compat
Warn about features not present in ISO C99, but present in ISO C11
Wc++-compat
-C ObjC Var(warn_cxx_compat) CPP(warn_cxx_operator_names) Init(0) Warning
+C ObjC Var(warn_cxx_compat) CPP(warn_cxx_operator_names) CppReason(CPP_W_CXX_OPERATOR_NAMES) Init(0) Warning
Warn about C constructs that are not in the common subset of C and C++
Wc++0x-compat
Warn about variables that might be changed by \"longjmp\" or \"vfork\"
Wcomment
-C ObjC C++ ObjC++ CPP(warn_comments) Var(cpp_warn_comment) Init(0) Warning LangEnabledBy(C ObjC C++ ObjC++,Wall)
+C ObjC C++ ObjC++ CPP(warn_comments) CppReason(CPP_W_COMMENTS) Var(cpp_warn_comment) Init(0) Warning LangEnabledBy(C ObjC C++ ObjC++,Wall)
Warn about possibly nested block comments, and C++ comments spanning more than one physical line
Wcomments
C++ ObjC++ Var(warn_conversion_null) Init(1) Warning
Warn for converting NULL from/to a non-pointer type
+Wcpp
+C ObjC C++ ObjC++ CppReason(CPP_W_WARNING_DIRECTIVE)
+; Documented in common.opt
+
Wctor-dtor-privacy
C++ ObjC++ Var(warn_ctor_dtor_privacy) Warning
Warn when all constructors and destructors are private
+Wdate-time
+C ObjC C++ ObjC++ CPP(warn_date_time) CppReason(CPP_W_DATE_TIME) Var(cpp_warn_date_time) Init(0) Warning
+Warn about __TIME__, __DATE__ and __TIMESTAMP__ usage
+
Wdeclaration-after-statement
C ObjC Var(warn_declaration_after_statement) Init(-1) Warning
Warn when a declaration is found after a statement
;
Wdeprecated
-C C++ ObjC ObjC++ CPP(cpp_warn_deprecated) Var(warn_deprecated) Init(1) Warning
+C C++ ObjC ObjC++ CPP(cpp_warn_deprecated) CppReason(CPP_W_DEPRECATED) Var(warn_deprecated) Init(1) Warning
Warn if a deprecated compiler feature, class, method, or field is used
Wdesignated-init
Warn about an empty body in an if or else statement
Wendif-labels
-C ObjC C++ ObjC++ CPP(warn_endif_labels) Var(cpp_warn_endif_labels) Init(1) Warning LangEnabledBy(C ObjC C++ ObjC++,Wpedantic)
+C ObjC C++ ObjC++ CPP(warn_endif_labels) CppReason(CPP_W_ENDIF_LABELS) Var(cpp_warn_endif_labels) Init(1) Warning LangEnabledBy(C ObjC C++ ObjC++,Wpedantic)
Warn about stray tokens after #elif and #endif
Wenum-compare
Warn about invalid uses of the \"offsetof\" macro
Winvalid-pch
-C ObjC C++ ObjC++ CPP(warn_invalid_pch) Var(cpp_warn_invalid_pch) Init(0) Warning
+C ObjC C++ ObjC++ CPP(warn_invalid_pch) CppReason(CPP_W_INVALID_PCH) Var(cpp_warn_invalid_pch) Init(0) Warning
Warn about PCH files that are found but not used
Wjump-misses-init
Warn when a jump misses a variable initialization
Wliteral-suffix
-C++ ObjC++ CPP(warn_literal_suffix) Var(cpp_warn_literal_suffix) Init(1) Warning
+C++ ObjC++ CPP(warn_literal_suffix) CppReason(CPP_W_LITERAL_SUFFIX) Var(cpp_warn_literal_suffix) Init(1) Warning
Warn when a string or character literal is followed by a ud-suffix which does not begin with an underscore.
Wlogical-op
Warn when logical not is used on the left hand side operand of a comparison
Wlong-long
-C ObjC C++ ObjC++ CPP(cpp_warn_long_long) Var(warn_long_long) Init(-1) Warning LangEnabledBy(C ObjC,Wc90-c99-compat)
+C ObjC C++ ObjC++ CPP(cpp_warn_long_long) CppReason(CPP_W_LONG_LONG) Var(warn_long_long) Init(-1) Warning LangEnabledBy(C ObjC,Wc90-c99-compat)
Do not warn about using \"long long\" when -pedantic
Wmain
;
Wmissing-include-dirs
-C ObjC C++ ObjC++ CPP(warn_missing_include_dirs) Var(cpp_warn_missing_include_dirs) Init(0) Warning
+C ObjC C++ ObjC++ CPP(warn_missing_include_dirs) CppReason(CPP_W_MISSING_INCLUDE_DIRS) Var(cpp_warn_missing_include_dirs) Init(0) Warning
Warn about user-specified include directories that do not exist
Wmissing-parameter-type
C ObjC C++ ObjC++ Ignore Warn(switch %qs is no longer supported)
Wmultichar
-C ObjC C++ ObjC++ CPP(warn_multichar) Var(cpp_warn_multichar) Init(0) Warning
+C ObjC C++ ObjC++ CPP(warn_multichar) CppReason(CPP_W_MULTICHAR) Var(cpp_warn_multichar) Init(0) Warning
Warn about use of multi-character character constants
Wnarrowing
;
Wnormalized=
-C ObjC C++ ObjC++ RejectNegative Joined Warning CPP(warn_normalize) Init(normalized_C) Var(cpp_warn_normalize) Enum(cpp_normalize_level)
+C ObjC C++ ObjC++ RejectNegative Joined Warning CPP(warn_normalize) CppReason(CPP_W_NORMALIZE) Init(normalized_C) Var(cpp_warn_normalize) Enum(cpp_normalize_level)
-Wnormalized=<none|id|nfc|nfkc> Warn about non-normalised Unicode strings
; Required for these enum values.
Warn about possibly missing parentheses
Wpedantic
-C ObjC C++ ObjC++ CPP(cpp_pedantic) Warning
+C ObjC C++ ObjC++ CPP(cpp_pedantic) CppReason(CPP_W_PEDANTIC) Warning
; Documented in common.opt
Wpmf-conversions
C ObjC C++ ObjC++ Var(warn_pragmas) Init(1) Warning
Warn about misuses of pragmas
-Wdate-time
-C ObjC C++ ObjC++ CPP(warn_date_time) Var(cpp_warn_date_time) Init(0) Warning
-Warn about __TIME__, __DATE__ and __TIMESTAMP__ usage
-
Wproperty-assign-default
ObjC ObjC++ Var(warn_property_assign_default) Init(1) Warning
Warn if a property for an Objective-C object has no assign semantics specified
; Documented in common.opt
Wtraditional
-C ObjC CPP(cpp_warn_traditional) Var(warn_traditional) Init(0) Warning
+C ObjC CPP(cpp_warn_traditional) CppReason(CPP_W_TRADITIONAL) Var(warn_traditional) Init(0) Warning
Warn about features not present in traditional C
Wtraditional-conversion
Warn of prototypes causing type conversions different from what would happen in the absence of prototype
Wtrigraphs
-C ObjC C++ ObjC++ CPP(warn_trigraphs) Var(cpp_warn_trigraphs) Init(2) Warning LangEnabledBy(C ObjC C++ ObjC++,Wall)
+C ObjC C++ ObjC++ CPP(warn_trigraphs) CppReason(CPP_W_TRIGRAPHS) Var(cpp_warn_trigraphs) Init(2) Warning LangEnabledBy(C ObjC C++ ObjC++,Wall)
Warn if trigraphs are encountered that might affect the meaning of the program
Wundeclared-selector
Warn about @selector()s without previously declared methods
Wundef
-C ObjC C++ ObjC++ CPP(warn_undef) Var(cpp_warn_undef) Init(0) Warning
+C ObjC C++ ObjC++ CPP(warn_undef) CppReason(CPP_W_UNDEF) Var(cpp_warn_undef) Init(0) Warning
Warn if an undefined macro is used in an #if directive
Wuninitialized
Warn when typedefs locally defined in a function are not used
Wunused-macros
-C ObjC C++ ObjC++ Var(cpp_warn_unused_macros) Warning
+C ObjC C++ ObjC++ CppReason(CPP_W_UNUSED_MACROS) Var(cpp_warn_unused_macros) Warning
Warn about macros defined in the main file that are not used
Wunused-result
Warn if a caller of a function, marked with attribute warn_unused_result, does not use its return value
Wvariadic-macros
-C ObjC C++ ObjC++ CPP(warn_variadic_macros) Var(cpp_warn_variadic_macros) Init(0) Warning LangEnabledBy(C ObjC C++ ObjC++,Wpedantic)
+C ObjC C++ ObjC++ CPP(warn_variadic_macros) CppReason(CPP_W_VARIADIC_MACROS) Var(cpp_warn_variadic_macros) Init(0) Warning LangEnabledBy(C ObjC C++ ObjC++,Wpedantic)
Warn about using variadic macros
Wvariadic-macros
print " OPT_SPECIAL_input_file"
print "};"
print ""
+print "#ifdef GCC_C_COMMON_H"
+print "/* Mapping from cpp message reasons to the options that enable them. */"
+print "#include <cpplib.h>"
+print "struct cpp_reason_option_codes_t"
+print "{"
+print " const int reason; /* cpplib message reason. */"
+print " const int option_code; /* gcc option that controls this message. */"
+print "};"
+print ""
+print "static const struct cpp_reason_option_codes_t cpp_reason_option_codes[] = {"
+for (i = 0; i < n_opts; i++) {
+ # With identical flags, pick only the last one. The
+ # earlier loop ensured that it has all flags merged,
+ # and a nonempty help text if one of the texts was nonempty.
+ while( i + 1 != n_opts && opts[i] == opts[i + 1] ) {
+ i++;
+ }
+ cpp_reason = nth_arg(0, opt_args("CppReason", flags[i]));
+ if (cpp_reason != "") {
+ cpp_reason = cpp_reason ",";
+ printf(" {%-40s %s},\n", cpp_reason, opt_enum(opts[i]))
+ }
+}
+printf(" {%-40s 0},\n", "CPP_W_NONE,")
+print "};"
+print "#endif"
+print ""
print "#endif /* OPTIONS_H */"
}