aboutsummaryrefslogtreecommitdiff
path: root/gcc/doc
diff options
context:
space:
mode:
authorDJ Delorie <dj@gcc.gnu.org>2006-01-18 15:02:42 -0500
committerDJ Delorie <dj@gcc.gnu.org>2006-01-18 15:02:42 -0500
commit79cf599406a6a51e2fdd47810fdba89e04cbf1cc (patch)
treefc2b70d94a779eb0814d5f4a6c95145347b94e16 /gcc/doc
parentf9fe7aed71e486669af301c0beb0c58bc303ee39 (diff)
downloadgcc-79cf599406a6a51e2fdd47810fdba89e04cbf1cc.zip
gcc-79cf599406a6a51e2fdd47810fdba89e04cbf1cc.tar.gz
gcc-79cf599406a6a51e2fdd47810fdba89e04cbf1cc.tar.bz2
c-pragma.c (handle_pragma_diagnostic): New.
* c-pragma.c (handle_pragma_diagnostic): New. (init_pragma): Register it. * doc/extend.texi: Document it. * diagnostic.def: Add DK_UNSPECIFIED and DK_IGNORED. * diagnostic.h (diagnostic_classify_diagnostic): Declare. (diagnostic_context): Add classify_diagnostic[]. * diagnostic.c (diagnostic_count_diagnostic): Don't count warnings as errors if they're overridden to DK_WARNING. (diagnostic_initialize): Initialize classify_diagnostic[]. (diagnostic_set_kind_override): New. (diagnostic_report_diagnostic): Check for kind changes. * opts.c (common_handle_option): Take lang_mask. Update callers. Handle OPT_Werror_. * common.opt (Werror=): New. * doc/invoke.texi: Document -Werror=* From-SVN: r109907
Diffstat (limited to 'gcc/doc')
-rw-r--r--gcc/doc/extend.texi48
-rw-r--r--gcc/doc/invoke.texi20
2 files changed, 65 insertions, 3 deletions
diff --git a/gcc/doc/extend.texi b/gcc/doc/extend.texi
index 0c2f39c..9d5a8f6 100644
--- a/gcc/doc/extend.texi
+++ b/gcc/doc/extend.texi
@@ -1,5 +1,5 @@
@c Copyright (C) 1988, 1989, 1992, 1993, 1994, 1996, 1998, 1999, 2000,
-@c 2001, 2002, 2003, 2004, 2005 Free Software Foundation, Inc.
+@c 2001, 2002, 2003, 2004, 2005, 2006 Free Software Foundation, Inc.
@c This is part of the GCC manual.
@c For copying conditions, see the file gcc.texi.
@@ -9290,6 +9290,7 @@ for further explanation.
* Symbol-Renaming Pragmas::
* Structure-Packing Pragmas::
* Weak Pragmas::
+* Diagnostic Pragmas::
@end menu
@node ARM Pragmas
@@ -9530,6 +9531,51 @@ It is an error if @var{symbol2} is not defined in the current
translation unit.
@end table
+@node Diagnostic Pragmas
+@subsection Diagnostic Pragmas
+
+GCC allows the user to selectively enable or disable certain types of
+diagnostics, and change the kind of the diagnostic. For example, a
+project's policy might require that all sources compile with
+@option{-Werror} but certain files might have exceptions allowing
+specific types of warnings. Or, a project might selectively enable
+diagnostics and treat them as errors depending on which preprocessor
+macros are defined.
+
+@table @code
+@item #pragma GCC diagnostic @var{kind} @var{option}
+@cindex pragma, diagnostic
+
+Modifies the disposition of a diagnostic. Note that not all
+diagnostics are modifyiable; at the moment only warnings (normally
+controlled by @samp{-W...}) can be controlled, and not all of them.
+Use @option{-fdiagnostics-show-option} to determine which diagnostics
+are controllable and which option controls them.
+
+@var{kind} is @samp{error} to treat this diagnostic as an error,
+@samp{warning} to treat it like a warning (even if @option{-Werror} is
+in effect), or @samp{ignored} if the diagnostic is to be ignored.
+@var{option} is a double quoted string which matches the command line
+option.
+
+@example
+#pragma GCC diagnostic warning "-Wformat"
+#pragma GCC diagnostic error "-Walways-true"
+#pragma GCC diagnostic ignored "-Walways-true"
+@end example
+
+Note that these pragmas override any command line options. Also,
+while it is syntactically valid to put these pragmas anywhere in your
+sources, the only supported location for them is before any data or
+functions are defined. Doing otherwise may result in unpredictable
+results depending on how the optimizer manages your sources. If the
+same option is listed multiple times, the last one specified is the
+one that is in effect. This pragma is not intended to be a general
+purpose replacement for command line options, but for implementing
+strict control over project policies.
+
+@end table
+
@node Unnamed Fields
@section Unnamed struct/union fields within structs/unions
@cindex struct
diff --git a/gcc/doc/invoke.texi b/gcc/doc/invoke.texi
index 629e4a9..924c121 100644
--- a/gcc/doc/invoke.texi
+++ b/gcc/doc/invoke.texi
@@ -1,5 +1,5 @@
@c Copyright (C) 1988, 1989, 1992, 1993, 1994, 1995, 1996, 1997, 1998, 1999,
-@c 2000, 2001, 2002, 2003, 2004, 2005 Free Software Foundation, Inc.
+@c 2000, 2001, 2002, 2003, 2004, 2005, 2006 Free Software Foundation, Inc.
@c This is part of the GCC manual.
@c For copying conditions, see the file gcc.texi.
@@ -226,7 +226,7 @@ Objective-C and Objective-C++ Dialects}.
-Wc++-compat -Wcast-align -Wcast-qual -Wchar-subscripts -Wcomment @gol
-Wconversion -Wno-deprecated-declarations @gol
-Wdisabled-optimization -Wno-div-by-zero -Wno-endif-labels @gol
--Werror -Werror-implicit-function-declaration @gol
+-Werror -Werror-* -Werror-implicit-function-declaration @gol
-Wfatal-errors -Wfloat-equal -Wformat -Wformat=2 @gol
-Wno-format-extra-args -Wformat-nonliteral @gol
-Wformat-security -Wformat-y2k @gol
@@ -3411,6 +3411,22 @@ This option is only supported for C and Objective-C@.
@opindex Werror
Make all warnings into errors.
+@item -Werror=
+@opindex Werror=
+Make the specified warning into an errors. The specifier for a
+warning is appended, for example @option{-Werror=switch} turns the
+warnings controlled by @option{-Wswitch} into errors. This switch
+takes a negative form, to be used to negate @option{-Werror} for
+specific warnings, for example @option{-Wno-error=switch} makes
+@option{-Wswitch} warnings not be errors, even when @option{-Werror}
+is in effect. You can use the @option{-fdiagnostics-show-option}
+option to have each controllable warning amended with the option which
+controls it, to determine what to use with this option.
+
+Note that specifying @option{-Werror=}@var{foo} automatically implies
+@option{-W}@var{foo}. However, @option{-Wno-error=}@var{foo} does not
+imply anything.
+
@item -Wstack-protector
@opindex Wstack-protector
This option is only active when @option{-fstack-protector} is active. It