aboutsummaryrefslogtreecommitdiff
path: root/gcc
diff options
context:
space:
mode:
authorEd Schonberg <schonberg@adacore.com>2018-10-09 15:04:53 +0000
committerPierre-Marie de Rodat <pmderodat@gcc.gnu.org>2018-10-09 15:04:53 +0000
commit0ffbef9f3553b6f9841f01ac5ff61850af63b219 (patch)
tree7f1033869d9a3a083734be3e352ad606478c95ba /gcc
parent33b43b0d8cd2de722d177ef823930500948a7487 (diff)
downloadgcc-0ffbef9f3553b6f9841f01ac5ff61850af63b219.zip
gcc-0ffbef9f3553b6f9841f01ac5ff61850af63b219.tar.gz
gcc-0ffbef9f3553b6f9841f01ac5ff61850af63b219.tar.bz2
[Ada] Spurious warning on uninitialized entity during code generation
This patch suppresses a spurious warning coming from the GCC backend, on an aggregate that cannot be built in place and for which a temporary variable must be created. If the type of the aggregate is a packed boolean array, the generated code may appear to use an uninitialized value for a component of the array, when in fact the code simply sets a single bit of that array. 2018-10-09 Ed Schonberg <schonberg@adacore.com> gcc/ada/ * exp_aggr.adb (Expand_Array_Aggregate): If it is not possible to build in place an aggregate with component associations, set the Warnings_Off flag on the generated temporary, to prevent spurious warnings from the backend when compiling with the -Wuninitialized gcc flag. gcc/testsuite/ * gnat.dg/warn18.adb: New testcase. From-SVN: r264960
Diffstat (limited to 'gcc')
-rw-r--r--gcc/ada/ChangeLog8
-rw-r--r--gcc/ada/exp_aggr.adb1
-rw-r--r--gcc/testsuite/ChangeLog4
-rw-r--r--gcc/testsuite/gnat.dg/warn18.adb13
4 files changed, 26 insertions, 0 deletions
diff --git a/gcc/ada/ChangeLog b/gcc/ada/ChangeLog
index d63cc5a..f6925bc 100644
--- a/gcc/ada/ChangeLog
+++ b/gcc/ada/ChangeLog
@@ -1,3 +1,11 @@
+2018-10-09 Ed Schonberg <schonberg@adacore.com>
+
+ * exp_aggr.adb (Expand_Array_Aggregate): If it is not possible
+ to build in place an aggregate with component associations, set
+ the Warnings_Off flag on the generated temporary, to prevent
+ spurious warnings from the backend when compiling with the
+ -Wuninitialized gcc flag.
+
2018-09-30 Alexandre Oliva <oliva@adacore.com>
* gcc-interface/lang-specs.h (default_compilers): When given
diff --git a/gcc/ada/exp_aggr.adb b/gcc/ada/exp_aggr.adb
index f65230f..1928cb9 100644
--- a/gcc/ada/exp_aggr.adb
+++ b/gcc/ada/exp_aggr.adb
@@ -6354,6 +6354,7 @@ package body Exp_Aggr is
Defining_Identifier => Tmp,
Object_Definition => New_Occurrence_Of (Typ, Loc));
Set_No_Initialization (Tmp_Decl, True);
+ Set_Warnings_Off (Tmp);
-- If we are within a loop, the temporary will be pushed on the
-- stack at each iteration. If the aggregate is the expression
diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog
index eed63b2..8f84ace 100644
--- a/gcc/testsuite/ChangeLog
+++ b/gcc/testsuite/ChangeLog
@@ -1,3 +1,7 @@
+2018-10-09 Ed Schonberg <schonberg@adacore.com>
+
+ * gnat.dg/warn18.adb: New testcase.
+
2018-10-09 Martin Liska <mliska@suse.cz>
* c-c++-common/asan/pr64820.c: Add line number to scanned
diff --git a/gcc/testsuite/gnat.dg/warn18.adb b/gcc/testsuite/gnat.dg/warn18.adb
new file mode 100644
index 0000000..c990575
--- /dev/null
+++ b/gcc/testsuite/gnat.dg/warn18.adb
@@ -0,0 +1,13 @@
+-- { dg-do compile }
+-- { dg-options "-Wuninitialized" }
+
+with Ada.Text_IO; use Ada.Text_IO;
+
+procedure Warn18 is
+ type Set is array (Natural range <>) of Boolean;
+ pragma Pack (Set);
+
+ O : constant Set (0 .. 255) := (28 => True, others => False);
+begin
+ Put_Line (O (1)'Img);
+end Warn18;