+Sun Dec 21 16:13:55 1997 Nick Clifton <nickc@cygnus.com
+
+ * c-pragma.c (handle_pragma_token): Generate warning messages
+ about unknown pragmas if warn_unknown_pragmas is set.
+
+ * c-decl.c (c_decode_option): Parse -Wunknown-pragmas command
+ line option to set variable: warn_unknown_pragmas.
+
Sun Dec 21 15:51:10 1997 Manfred Hollstein <manfred@lts.sel.alcatel.de>
* m68k/mot3300.h (ASM_BYTE_OP): Don't include '\t' in the
int warn_main;
+/* Warn about #pragma directives that are not recognised. */
+
+int warn_unknown_pragmas = 0; /* Tri state variable. */
+
/* Warn about comparison of signed and unsigned values.
If -1, neither -Wsign-compare nor -Wno-sign-compare has been specified. */
warn_sign_compare = 1;
else if (!strcmp (p, "-Wno-sign-compare"))
warn_sign_compare = 0;
+ else if (!strcmp (p, "-Wunknown-pragmas"))
+ /* Set to greater than 1, so that even unknown pragmas in system
+ headers will be warned about. */
+ warn_unknown_pragmas = 2;
+ else if (!strcmp (p, "-Wno-unknown-pragmas"))
+ warn_unknown_pragmas = 0;
else if (!strcmp (p, "-Wall"))
{
/* We save the value of warn_uninitialized, since if they put
/* We set this to 2 here, but 1 in -Wmain, so -ffreestanding can turn
it off only if it's not explicit. */
warn_main = 2;
+ /* Only warn about unknown pragmas that are not in system headers. */
+ warn_unknown_pragmas = 1;
}
else
return 0;
/* Handle #pragma, system V.4 style. Supports #pragma weak and #pragma pack.
- Copyright (C) 1992 Free Software Foundation, Inc.
+ Copyright (C) 1992, 1997 Free Software Foundation, Inc.
This file is part of GNU CC.
the Free Software Foundation, 59 Temple Place - Suite 330,
Boston, MA 02111-1307, USA. */
-#include <stdio.h>
#include "config.h"
+#include <stdio.h>
#include "tree.h"
#include "except.h"
#include "function.h"
if (HANDLE_PRAGMA_WEAK)
handle_pragma_weak (state, name, value);
-#endif /* HANDLE_PRAMA_WEAK */
+#endif /* HANDLE_PRAGMA_WEAK */
}
type = state = ps_start;
else if (strcmp (IDENTIFIER_POINTER (token), "weak") == 0)
type = state = ps_weak;
else
- type = state = ps_done;
+ {
+ type = state = ps_done;
+
+ /* Issue a warning message if we have been asked to do so.
+ Ignoring unknown pragmas in system header file unless
+ an explcit -Wunknown-pragmas has been given. */
+ if (warn_unknown_pragmas > 1
+ || (warn_unknown_pragmas && ! in_system_header))
+ warning ("ignoring pragma: %s", string);
+ }
}
else
type = state = ps_done;
extern int warn_uninitialized;
+/* Zero if unknown pragmas are ignored
+ One if the compiler should warn about an unknown pragma not in
+ a system include file.
+ Greater than one if the compiler should warn for all unknown
+ pragmas. */
+
+extern int warn_unknown_pragmas;
+
/* Nonzero means warn about all declarations which shadow others. */
extern int warn_shadow;
-Wsign-compare -Wstrict-prototypes -Wswitch -Wsynth
-Wtemplate-debugging -Wtraditional -Wtrigraphs
-Wundef -Wuninitialized -Wunused -Wwrite-strings
+-Wunknown-pragmas
@end smallexample
@item Debugging Options
When using templates in a C++ program, warn if debugging is not yet
fully available (C++ only).
+@item -Wunknown-pragmas
+@cindex warning for unknown pragmas
+@cindex unknown pragmas, warning
+@cindex pragmas, warning of unknown
+Warn when a #pragma directive is encountered which is not understood by
+GCC. If this command line option is used, warnings will even be issued
+for unknown pragmas in system header files. This is not the case if
+the warnings were only enabled by the @samp{-Wall} command line option.
+
@item -Wall
All of the above @samp{-W} options combined. This enables all the
warnings about constructions that some users consider questionable, and