Package: gnat-4.4
Version: 4.4.5-3
Severity: normal
Tags: upstream patch
Forwarded: http://gcc.gnu.org/bugzilla/show_bug.cgi?id=47818

I reported this bug to gcc bugzilla, but it is also applies to Debian
(gnat-4.4 and gcc-snapshot).

Compilation of code containing pragma Assert fails if restriction
No_Implementation_Pragmas is used, even with -gnat2005 or -gnat2012
flags:

% cat test.adb                                                                  
pragma Restrictions(No_Implementation_Pragmas);

procedure test(I : Integer) is
begin
  pragma Assert(I /= 1);
  null;
end;
% gcc -c test.adb -gnat2005                                                     
test.adb:5:03: violation of restriction "no_implementation_pragmas" at line 1

Source file gcc/ada/sem_prag.adb contains correct check for Pragma_Assert
(Ada_2005_Pragma). But this pragma is then rewritten as pragma Check and
restrictions (GNAT_Pragma) are tested again. This test fails and causes
compilation error.

Attached patch adds check in Pragma_Check case. If rewritten pragma Assert was
found then restrictions are not checked.

-- System Information:
Debian Release: wheezy/sid
  APT prefers unstable
  APT policy: (500, 'unstable'), (1, 'experimental')
Architecture: amd64 (x86_64)

Kernel: Linux 2.6.38-rc5+ (SMP w/2 CPU cores; PREEMPT)
Locale: LANG=uk_UA.UTF-8, LC_CTYPE=uk_UA.UTF-8 (charmap=UTF-8)
Shell: /bin/sh linked to /bin/dash

Versions of packages gnat-4.4 depends on:
ii  gcc-4.4                 4.4.5-12         The GNU C compiler
ii  gnat-4.4-base           4.4.5-3          The GNU Compiler Collection (gnat 
ii  libc6                   2.11.2-11        Embedded GNU C Library: Shared lib
ii  libc6-dev               2.11.2-11        Embedded GNU C Library: Developmen
ii  libgcc1                 1:4.6-20110125-1 GCC support library
ii  libgmp3c2               2:4.3.2+dfsg-1   Multiprecision arithmetic library
ii  libgnat-4.4             4.4.5-3          Runtime library for GNU Ada applic
ii  libgnatprj4.4           4.4.5-3          GNU Ada Project Manager
ii  libgnatvsn4.4           4.4.5-3          GNU Ada compiler version library
ii  libmpfr4                3.0.0-6          multiple precision floating-point 

gnat-4.4 recommends no packages.

Versions of packages gnat-4.4 suggests:
pn  ada-reference-manual         <none>      (no description available)
ii  gnat-4.4-doc                 4.4.4.nf1-1 documentation for the GNU Ada 95 C
ii  gnat-gps                     4.3-6       The GNAT Programming System - adva
ii  gprbuild                     1.3.0-2     a multi-language extensible build 

-- no debconf information
diff --git a/gcc/ada/sem_prag.adb b/gcc/ada/sem_prag.adb
index fd509c4..b5bae50 100644
--- a/gcc/ada/sem_prag.adb
+++ b/gcc/ada/sem_prag.adb
@@ -6477,7 +6477,16 @@ package body Sem_Prag is
             --  Set True if category of assertions referenced by Name enabled
 
          begin
-            GNAT_Pragma;
+            --  This could be a rewritten pragma Assert. If it is the case
+            --  then don't check restrictions, because they are different for
+            --  pragma Assert and were already checked.
+
+            if Nkind (Original_Node (N)) /= N_Pragma
+              or else Pragma_Name (Original_Node (N)) /= Name_Assert
+            then
+               GNAT_Pragma;
+            end if;
+
             Check_At_Least_N_Arguments (2);
             Check_At_Most_N_Arguments (3);
             Check_Optional_Identifier (Arg1, Name_Name);

Reply via email to