aboutsummaryrefslogtreecommitdiff
path: root/gcc/ada/sem_ch9.adb
diff options
context:
space:
mode:
authorArnaud Charlet <charlet@gcc.gnu.org>2012-07-09 15:27:22 +0200
committerArnaud Charlet <charlet@gcc.gnu.org>2012-07-09 15:27:22 +0200
commitc1107fa376b716f93c9c6f349bb46e1e767d41d6 (patch)
tree3116306d0d98adfdfd391185637bd4a43a7a293d /gcc/ada/sem_ch9.adb
parentd27f3ff4c3165d5decf103e63336095730745f82 (diff)
downloadgcc-c1107fa376b716f93c9c6f349bb46e1e767d41d6.zip
gcc-c1107fa376b716f93c9c6f349bb46e1e767d41d6.tar.gz
gcc-c1107fa376b716f93c9c6f349bb46e1e767d41d6.tar.bz2
[multiple changes]
2012-07-09 Vincent Pucci <pucci@adacore.com> * sem_ch9.adb (Check_Node): Allow attributes that denote static function for lock-free implementation. (Is_Static_Function): New routine. 2012-07-09 Tristan Gingold <gingold@adacore.com> * tracebak.c: Adjust skip_frames on Win64. 2012-07-09 Tristan Gingold <gingold@adacore.com> * init.c: Add __gnat_adjust_context_for_raise for ia64/hpux. * raise-gcc.c: __gnat_cleanupunwind_handler: Do not call _Unwind_GetGR on hpux when using libgcc unwinder. Part of 2012-07-09 Vincent Pucci <pucci@adacore.com> * exp_attr.adb, sem_attr.adb: Minor reformatting. * par-ch13.adb, par-ch4.adb, par-util.adb: Reformatting considering that internal attribute names are not defined anymore in the main attribute names list. * snames.adb-tmpl (Get_Attribute_Id): Special processinf for names CPU, Dispatching_Domain and Interrupt_Priority. (Is_Internal_Attribute_Name): Minor reformatting. * snames.ads-tmpl: New list of internal attribute names. Internal attributes moved at the end of the attribute Id list. From-SVN: r189380
Diffstat (limited to 'gcc/ada/sem_ch9.adb')
-rw-r--r--gcc/ada/sem_ch9.adb63
1 files changed, 62 insertions, 1 deletions
diff --git a/gcc/ada/sem_ch9.adb b/gcc/ada/sem_ch9.adb
index 8c570449..6a9fedf2 100644
--- a/gcc/ada/sem_ch9.adb
+++ b/gcc/ada/sem_ch9.adb
@@ -244,12 +244,71 @@ package body Sem_Ch9 is
----------------
function Check_Node (N : Node_Id) return Traverse_Result is
+ function Is_Static_Function (Attr : Node_Id) return Boolean;
+ -- Given an attribute reference node Attr, return True if
+ -- Attr denotes a static function according to the rules in
+ -- (RM 4.9 (22)).
+
+ ------------------------
+ -- Is_Static_Function --
+ ------------------------
+
+ function Is_Static_Function
+ (Attr : Node_Id) return Boolean
+ is
+ Para : Node_Id;
+
+ begin
+ pragma Assert (Nkind (Attr) = N_Attribute_Reference);
+
+ case Attribute_Name (Attr) is
+ when Name_Min |
+ Name_Max |
+ Name_Pred |
+ Name_Succ |
+ Name_Value |
+ Name_Wide_Value |
+ Name_Wide_Wide_Value =>
+
+ -- A language-defined attribute denotes a static
+ -- function if the prefix denotes a static scalar
+ -- subtype, and if the parameter and result types
+ -- are scalar (RM 4.9 (22)).
+
+ if Is_Scalar_Type (Etype (Attr))
+ and then Is_Scalar_Type (Etype (Prefix (Attr)))
+ and then Is_Static_Subtype (Etype (Prefix (Attr)))
+ then
+ Para := First (Expressions (Attr));
+
+ while Present (Para) loop
+ if not Is_Scalar_Type (Etype (Para)) then
+ return False;
+ end if;
+
+ Next (Para);
+ end loop;
+
+ return True;
+
+ else
+ return False;
+ end if;
+
+ when others => return False;
+ end case;
+ end Is_Static_Function;
+
+ -- Start of processing for Check_Node
+
begin
if Is_Procedure then
- -- Function calls and attribute references must be static
+ -- Attribute references must be static or denote a static
+ -- function.
if Nkind (N) = N_Attribute_Reference
and then not Is_Static_Expression (N)
+ and then not Is_Static_Function (N)
then
if Complain then
Error_Msg_N
@@ -258,6 +317,8 @@ package body Sem_Ch9 is
return Abandon;
+ -- Function calls must be static
+
elsif Nkind (N) = N_Function_Call
and then not Is_Static_Expression (N)
then