This is the mail archive of the mailing list for the GCC project.

Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

[Ada] Place exported constants in read-only memory

We interpret 13.3(19) conservatively and basically disallow any optimizations 
for an object covered by it.  But that's overkill for constants and prevents 
them from being placed in read-only memory.

Tested on i586-suse-linux, applied on the mainline.

2009-04-21  Eric Botcazou  <>

	* gcc-interface/decl.c (gnat_to_gnu_entity) <object>: Do not make
	constant objects covered by 13.3(19) volatile.

Eric Botcazou
Index: gcc-interface/decl.c
--- gcc-interface/decl.c	(revision 146452)
+++ gcc-interface/decl.c	(working copy)
@@ -967,15 +967,12 @@ gnat_to_gnu_entity (Entity_Id gnat_entit
 	/* Make a volatile version of this object's type if we are to make
 	   the object volatile.  We also interpret 13.3(19) conservatively
-	   and disallow any optimizations for an object covered by it.  */
+	   and disallow any optimizations for such a non-constant object.  */
 	if ((Treat_As_Volatile (gnat_entity)
-	     || (Is_Exported (gnat_entity)
-		 /* Exclude exported constants created by the compiler,
-		    which should boil down to static dispatch tables and
-		    make it possible to put them in read-only memory.  */
-		 && (Comes_From_Source (gnat_entity) || !const_flag))
-	     || Is_Imported (gnat_entity)
-	     || Present (Address_Clause (gnat_entity)))
+	     || (!const_flag
+		 && (Is_Exported (gnat_entity)
+		     || Is_Imported (gnat_entity)
+		     || Present (Address_Clause (gnat_entity)))))
 	    && !TYPE_VOLATILE (gnu_type))
 	  gnu_type = build_qualified_type (gnu_type,
 					   (TYPE_QUALS (gnu_type)

Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]