aboutsummaryrefslogtreecommitdiff
path: root/gcc/ada
diff options
context:
space:
mode:
authorJustin Squirek <squirek@adacore.com>2019-07-11 08:02:21 +0000
committerPierre-Marie de Rodat <pmderodat@gcc.gnu.org>2019-07-11 08:02:21 +0000
commitae59bda92bbab1a02562683dd54fb9c287307a9e (patch)
tree2fec8a1049e64dc94bc9bf90a5de2a40440b46e9 /gcc/ada
parent4ae83b58d2316f22d6874b6901fa61fe0f823e3f (diff)
downloadgcc-ae59bda92bbab1a02562683dd54fb9c287307a9e.zip
gcc-ae59bda92bbab1a02562683dd54fb9c287307a9e.tar.gz
gcc-ae59bda92bbab1a02562683dd54fb9c287307a9e.tar.bz2
[Ada] Pragma Unreferenced triggers undefined reference
This patch corrects the generation of protected body declarations so that instances of pragma Unreferenced applied to formals don't falsly trigger undefined references. 2019-07-11 Justin Squirek <squirek@adacore.com> gcc/ada/ * exp_ch9.adb (Build_Private_Protected_Declaration): Add exception for the moving of pragmas to internally generated specs for pragma Unreferenced. gcc/testsuite/ * gnat.dg/unreferenced2.adb: New testcase. From-SVN: r273392
Diffstat (limited to 'gcc/ada')
-rw-r--r--gcc/ada/ChangeLog6
-rw-r--r--gcc/ada/exp_ch9.adb11
2 files changed, 16 insertions, 1 deletions
diff --git a/gcc/ada/ChangeLog b/gcc/ada/ChangeLog
index a39069c..b51a3cc 100644
--- a/gcc/ada/ChangeLog
+++ b/gcc/ada/ChangeLog
@@ -1,3 +1,9 @@
+2019-07-11 Justin Squirek <squirek@adacore.com>
+
+ * exp_ch9.adb (Build_Private_Protected_Declaration): Add
+ exception for the moving of pragmas to internally generated
+ specs for pragma Unreferenced.
+
2019-07-11 Bob Duff <duff@adacore.com>
* doc/gnat_ugn/gnat_utility_programs.rst: Fix inconsistent
diff --git a/gcc/ada/exp_ch9.adb b/gcc/ada/exp_ch9.adb
index 7eb6eb5..077063f 100644
--- a/gcc/ada/exp_ch9.adb
+++ b/gcc/ada/exp_ch9.adb
@@ -3493,6 +3493,8 @@ package body Exp_Ch9 is
procedure Move_Pragmas (From : Node_Id; To : Node_Id);
-- Find all suitable source pragmas at the top of subprogram body From's
-- declarations and insert them after arbitrary node To.
+ --
+ -- Very similar to Move_Pragmas in sem_ch6 ???
---------------------
-- Analyze_Pragmas --
@@ -3544,7 +3546,14 @@ package body Exp_Ch9 is
Next_Decl := Next (Decl);
- if Nkind (Decl) = N_Pragma then
+ -- We add an exception here for Unreferenced pragmas since the
+ -- internally generated spec gets analyzed within
+ -- Build_Private_Protected_Declaration and will lead to spurious
+ -- warnings due to the way references are checked.
+
+ if Nkind (Decl) = N_Pragma
+ and then Pragma_Name_Unmapped (Decl) /= Name_Unreferenced
+ then
Remove (Decl);
Insert_After (Insert_Nod, Decl);
Insert_Nod := Decl;