OSDN Git Service

2009-08-17 Thomas Quinot <quinot@adacore.com>
[pf3gnuchains/gcc-fork.git] / gcc / ada / sem_intr.adb
index 54ae2d2..42136b1 100644 (file)
@@ -6,19 +6,17 @@
 --                                                                          --
 --                                 B o d y                                  --
 --                                                                          --
---                                                                          --
---          Copyright (C) 1992-2001 Free Software Foundation, Inc.          --
+--          Copyright (C) 1992-2009, 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- --
--- ware  Foundation;  either version 2,  or (at your option) any later ver- --
+-- ware  Foundation;  either version 3,  or (at your option) any later ver- --
 -- sion.  GNAT is distributed in the hope that it will be useful, but WITH- --
 -- OUT ANY WARRANTY;  without even the  implied warranty of MERCHANTABILITY --
 -- or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License --
 -- for  more details.  You should have  received  a copy of the GNU General --
--- Public License  distributed with GNAT;  see file COPYING.  If not, write --
--- to  the Free Software Foundation,  59 Temple Place - Suite 330,  Boston, --
--- MA 02111-1307, USA.                                                      --
+-- Public License  distributed with GNAT; see file COPYING3.  If not, go to --
+-- http://www.gnu.org/licenses for a complete copy of the license.          --
 --                                                                          --
 -- GNAT was originally developed  by the GNAT team at  New York University. --
 -- Extensive contributions were provided by Ada Core Technologies Inc.      --
@@ -104,7 +102,9 @@ package body Sem_Intr is
       Arg1 : constant Node_Id   := First_Actual (N);
 
    begin
-      --  For Import_xxx calls, argument must be static string
+      --  For Import_xxx calls, argument must be static string. A string
+      --  literal is legal even in Ada83 mode, where such literals are
+      --  not static.
 
       if Cnam = Name_Import_Address
            or else
@@ -117,9 +117,12 @@ package body Sem_Intr is
          then
             null;
 
-         elsif not Is_Static_Expression (Arg1) then
-            Error_Msg_NE
-              ("call to & requires static string argument", N, Nam);
+         elsif Nkind (Arg1) /= N_String_Literal
+           and then not Is_Static_Expression (Arg1)
+         then
+            Error_Msg_FE
+              ("call to & requires static string argument!", N, Nam);
+            Why_Not_Static (Arg1);
 
          elsif String_Length (Strval (Expr_Value_S (Arg1))) = 0 then
             Error_Msg_NE
@@ -132,6 +135,15 @@ package body Sem_Intr is
               ("argument in call to & must be 31 characters or less", N, Nam);
          end if;
 
+      --  Check for the case of freeing a non-null object which will raise
+      --  Constraint_Error. Issue warning here, do the expansion in Exp_Intr.
+
+      elsif Cnam = Name_Free
+        and then Can_Never_Be_Null (Etype (Arg1))
+      then
+         Error_Msg_N
+           ("freeing `NOT NULL` object will raise Constraint_Error?", N);
+
       --  For now, no other special checks are required
 
       else
@@ -150,7 +162,7 @@ package body Sem_Intr is
       T2  : Entity_Id;
 
    begin
-      --  Aritnmetic operators
+      --  Arithmetic operators
 
       if Nam = Name_Op_Add
            or else
@@ -265,7 +277,6 @@ package body Sem_Intr is
       if not Is_Numeric_Type (T1) then
          Errint ("intrinsic operator can only apply to numeric types", E, N);
       end if;
-
    end Check_Intrinsic_Operator;
 
    --------------------------------
@@ -291,12 +302,13 @@ package body Sem_Intr is
 
       if Name_Buffer (1) /= 'O'
         and then Nam /= Name_Asm
+        and then Nam /= Name_To_Address
         and then Nam not in First_Intrinsic_Name .. Last_Intrinsic_Name
       then
          Errint ("unrecognized intrinsic subprogram", E, N);
 
       --  We always allow intrinsic specifications in language defined units
-      --  and in expanded code. We assume that the GNAT implemetors know what
+      --  and in expanded code. We assume that the GNAT implementors know what
       --  they are doing, and do not write or generate junk use of intrinsic!
 
       elsif not Comes_From_Source (E)
@@ -410,9 +422,7 @@ package body Sem_Intr is
              Ptyp1, N);
          return;
 
-      elsif Is_Modular_Integer_Type (Typ1)
-        and then Non_Binary_Modulus (Typ1)
-      then
+      elsif Non_Binary_Modulus (Typ1) then
          Errint
            ("shifts not allowed for non-binary modular types",
             Ptyp1, N);