]> git.ipfire.org Git - thirdparty/gcc.git/commitdiff
decl.c (gnat_to_gnu_entity): Move code dealing with volatileness to after code dealin...
authorEric Botcazou <ebotcazou@adacore.com>
Tue, 7 Oct 2008 08:10:27 +0000 (08:10 +0000)
committerEric Botcazou <ebotcazou@gcc.gnu.org>
Tue, 7 Oct 2008 08:10:27 +0000 (08:10 +0000)
* gcc-interface/decl.c (gnat_to_gnu_entity) <object>: Move code
dealing with volatileness to after code dealing with renaming.

From-SVN: r140924

gcc/ada/ChangeLog
gcc/ada/gcc-interface/decl.c
gcc/testsuite/ChangeLog
gcc/testsuite/gnat.dg/addr4.adb [new file with mode: 0644]
gcc/testsuite/gnat.dg/addr5.adb [new file with mode: 0644]

index 271fdcae77f0120aaab8731a847471274ce4492e..d384ff538b2a3603d5fff1cbcf7cfb55a8c11d7a 100644 (file)
@@ -1,3 +1,8 @@
+2008-10-07  Eric Botcazou  <ebotcazou@adacore.com>
+
+       * gcc-interface/decl.c (gnat_to_gnu_entity) <object>: Move code
+       dealing with volatileness to after code dealing with renaming.
+
 2008-10-06  Eric Botcazou  <ebotcazou@adacore.com>
 
        * gcc-interface/decl.c (gnat_to_gnu_entity) <object>: Minor tweaks.
index b140f987f16c9213b1f5414c2ce2c8a2b1225f79..cdee227760825eda9ee9b87a3b946534545924f0 100644 (file)
@@ -828,22 +828,6 @@ gnat_to_gnu_entity (Entity_Id gnat_entity, tree gnu_expr, int definition)
                                     "PAD", false, definition,
                                     gnu_size ? true : false);
 
-       /* 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.  */
-       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)))
-           && !TYPE_VOLATILE (gnu_type))
-         gnu_type = build_qualified_type (gnu_type,
-                                          (TYPE_QUALS (gnu_type)
-                                           | TYPE_QUAL_VOLATILE));
-
        /* If this is a renaming, avoid as much as possible to create a new
           object.  However, in several cases, creating it is required.
           This processing needs to be applied to the raw expression so
@@ -991,22 +975,38 @@ gnat_to_gnu_entity (Entity_Id gnat_entity, tree gnu_expr, int definition)
              }
          }
 
-       /* If this is an aliased object whose nominal subtype is unconstrained,
-          the object is a record that contains both the template and
-          the object.  If there is an initializer, it will have already
-          been converted to the right type, but we need to create the
-          template if there is no initializer.  */
-       else if (definition
-                && TREE_CODE (gnu_type) == RECORD_TYPE
-                && (TYPE_CONTAINS_TEMPLATE_P (gnu_type)
-                    /* Beware that padding might have been introduced
-                       via maybe_pad_type above.  */
-                    || (TYPE_IS_PADDING_P (gnu_type)
-                        && TREE_CODE (TREE_TYPE (TYPE_FIELDS (gnu_type)))
-                           == RECORD_TYPE
-                        && TYPE_CONTAINS_TEMPLATE_P
-                           (TREE_TYPE (TYPE_FIELDS (gnu_type)))))
-                && !gnu_expr)
+       /* 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.  */
+       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)))
+           && !TYPE_VOLATILE (gnu_type))
+         gnu_type = build_qualified_type (gnu_type,
+                                          (TYPE_QUALS (gnu_type)
+                                           | TYPE_QUAL_VOLATILE));
+
+       /* If we are defining an aliased object whose nominal subtype is
+          unconstrained, the object is a record that contains both the
+          template and the object.  If there is an initializer, it will
+          have already been converted to the right type, but we need to
+          create the template if there is no initializer.  */
+       if (definition
+           && !gnu_expr
+           && TREE_CODE (gnu_type) == RECORD_TYPE
+           && (TYPE_CONTAINS_TEMPLATE_P (gnu_type)
+               /* Beware that padding might have been introduced
+                  via maybe_pad_type above.  */
+               || (TYPE_IS_PADDING_P (gnu_type)
+                   && TREE_CODE (TREE_TYPE (TYPE_FIELDS (gnu_type)))
+                      == RECORD_TYPE
+                   && TYPE_CONTAINS_TEMPLATE_P
+                      (TREE_TYPE (TYPE_FIELDS (gnu_type))))))
          {
            tree template_field
              = TYPE_IS_PADDING_P (gnu_type)
index d9f4f297826ad83b515b800a6370c1860da1b4b7..1c76fb09b99582c7d6d88328cb4c3cc572a66646 100644 (file)
@@ -1,3 +1,8 @@
+2008-10-07  Eric Botcazou  <ebotcazou@adacore.com>
+
+       * gnat.dg/addr4.adb: New test.
+       * gnat.dg/addr5.adb: Likewise.
+
 2008-10-06  Adam Nemet  <anemet@caviumnetworks.com>
 
        * gcc.target/mips/mips.exp (dg-mips-options): Set mips_new_gp to
diff --git a/gcc/testsuite/gnat.dg/addr4.adb b/gcc/testsuite/gnat.dg/addr4.adb
new file mode 100644 (file)
index 0000000..8bb3f2c
--- /dev/null
@@ -0,0 +1,12 @@
+-- { dg-do compile }
+-- { dg-options "-g" }
+
+procedure Addr4 is
+   function F return String is begin return ""; end F;
+   S1 : String renames F;
+   subtype ST is String (1 .. S1'Length);
+   S2 : ST;
+   for S2'Address use S1'Address;
+begin
+   null;
+end;
diff --git a/gcc/testsuite/gnat.dg/addr5.adb b/gcc/testsuite/gnat.dg/addr5.adb
new file mode 100644 (file)
index 0000000..e331dfd
--- /dev/null
@@ -0,0 +1,10 @@
+-- { dg-do compile }
+-- { dg-options "-g" }
+
+procedure Addr5 (Len : Integer) is
+  S : aliased String (1 .. Len) := (others => ' ');
+  C : Character;
+  for C'Address use S'Address;
+begin
+  null;
+end;