From 6ab36daccbd955cdb3caf5b7040ab99cdb6b4d14 Mon Sep 17 00:00:00 2001 From: Eric Botcazou Date: Sat, 8 Mar 2008 11:53:19 +0000 Subject: [PATCH] lang-specs.h: Pass -gnatwa if -Wall is passed. * lang-specs.h: Pass -gnatwa if -Wall is passed. * misc.c (gnat_handle_option) : Expand into -Wunused and -Wuninitialized. (gnat_post_options): Clear warn_unused_parameter. From-SVN: r133030 --- gcc/ada/ChangeLog | 7 +++++++ gcc/ada/lang-specs.h | 6 +++--- gcc/ada/misc.c | 15 +++++++++++++-- gcc/testsuite/ChangeLog | 4 ++++ gcc/testsuite/gnat.dg/uninit_func.adb | 13 +++++++++++++ 5 files changed, 40 insertions(+), 5 deletions(-) create mode 100644 gcc/testsuite/gnat.dg/uninit_func.adb diff --git a/gcc/ada/ChangeLog b/gcc/ada/ChangeLog index 77ceedae6ff..bbca1567488 100644 --- a/gcc/ada/ChangeLog +++ b/gcc/ada/ChangeLog @@ -1,3 +1,10 @@ +2008-03-08 Eric Botcazou + + * lang-specs.h: Pass -gnatwa if -Wall is passed. + * misc.c (gnat_handle_option) : Expand into -Wunused + and -Wuninitialized. + (gnat_post_options): Clear warn_unused_parameter. + 2008-03-08 Eric Botcazou * utils.c (finish_record_type): Clear DECL_BIT_FIELD on sufficiently diff --git a/gcc/ada/lang-specs.h b/gcc/ada/lang-specs.h index b6d9ce1be23..65326d4c5b2 100644 --- a/gcc/ada/lang-specs.h +++ b/gcc/ada/lang-specs.h @@ -6,7 +6,7 @@ * * * C Header File * * * - * Copyright (C) 1992-2007, Free Software Foundation, Inc. * + * Copyright (C) 1992-2008, Free Software Foundation, Inc. * * * * GNAT is free software; you can redistribute it and/or modify it under * * terms of the GNU General Public License as published by the Free Soft- * @@ -32,8 +32,8 @@ "\ %{pg:%{fomit-frame-pointer:%e-pg and -fomit-frame-pointer are incompatible}}\ %{!S:%{!c:%e-c or -S required for Ada}}\ - gnat1 %{I*} %{k8:-gnatk8} %{w:-gnatws} %{!Q:-quiet} %{nostdinc*}\ - %{nostdlib*}\ + gnat1 %{I*} %{k8:-gnatk8} %{Wall:-gnatwa} %{w:-gnatws} %{!Q:-quiet}\ + %{nostdinc*} %{nostdlib*}\ -dumpbase %{.adb:%b.adb}%{.ads:%b.ads}%{!.adb:%{!.ads:%b.ada}}\ %{O*} %{W*} %{w} %{p} %{pg:-p} %{a} %{f*} %{d*} %{g*&m*} " #if defined(TARGET_VXWORKS_RTP) diff --git a/gcc/ada/misc.c b/gcc/ada/misc.c index 4ddf10f23a9..3845ba8242d 100644 --- a/gcc/ada/misc.c +++ b/gcc/ada/misc.c @@ -249,7 +249,7 @@ gnat_parse_file (int set_yydebug ATTRIBUTE_UNUSED) from ARGV that it successfully decoded; 0 indicates failure. */ static int -gnat_handle_option (size_t scode, const char *arg, int value ATTRIBUTE_UNUSED) +gnat_handle_option (size_t scode, const char *arg, int value) { const struct cl_option *option = &cl_options[scode]; enum opt_code code = (enum opt_code) scode; @@ -271,8 +271,16 @@ gnat_handle_option (size_t scode, const char *arg, int value ATTRIBUTE_UNUSED) gnat_argc++; break; - /* All front ends are expected to accept this. */ case OPT_Wall: + set_Wunused (value); + + /* We save the value of warn_uninitialized, since if they put + -Wuninitialized on the command line, we need to generate a + warning about not using it without also specifying -O. */ + if (warn_uninitialized != 1) + warn_uninitialized = (value ? 2 : 0); + break; + /* These are used in the GCC Makefile. */ case OPT_Wmissing_prototypes: case OPT_Wstrict_prototypes: @@ -357,6 +365,9 @@ gnat_init_options (unsigned int argc, const char **argv) bool gnat_post_options (const char **pfilename ATTRIBUTE_UNUSED) { + /* ??? The warning machinery is outsmarted by Ada. */ + warn_unused_parameter = 0; + flag_inline_trees = 1; if (!flag_no_inline) diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog index 4915a4229f2..8a8c5edadf5 100644 --- a/gcc/testsuite/ChangeLog +++ b/gcc/testsuite/ChangeLog @@ -1,3 +1,7 @@ +2008-03-08 Eric Botcazou + + * gnat.dg/uninit_func.adb: New test. + 2008-03-08 Eric Botcazou * gnat.dg/pack4.adb: New test. diff --git a/gcc/testsuite/gnat.dg/uninit_func.adb b/gcc/testsuite/gnat.dg/uninit_func.adb new file mode 100644 index 00000000000..9c9ee341143 --- /dev/null +++ b/gcc/testsuite/gnat.dg/uninit_func.adb @@ -0,0 +1,13 @@ +-- { dg-do compile } +-- { dg-options "-O -Wall" } + +function uninit_func (A, B : Boolean) return Boolean is + C : Boolean; -- { dg-warning "may be used uninitialized" } +begin + if A then + C := False; + elsif B then + C := True; + end if; + return C; +end; -- 2.30.2