Add assertion for access attributes
authorEric Botcazou <ebotcazou@gcc.gnu.org>
Sat, 9 May 2020 21:08:18 +0000 (23:08 +0200)
committerEric Botcazou <ebotcazou@gcc.gnu.org>
Sat, 9 May 2020 21:08:18 +0000 (23:08 +0200)
* gcc-interface/trans.c (Attribute_to_gnu) <Attr_Access>: Assert
that the prefix is not a type.

gcc/ada/ChangeLog
gcc/ada/gcc-interface/trans.c

index 538973eac9adbebed77a7e38b8305618de11c493..5e8372658b21f6cb5a7f199066863caff678f209 100644 (file)
@@ -1,3 +1,8 @@
+2020-05-09  Eric Botcazou  <ebotcazou@adacore.com>
+
+       * gcc-interface/trans.c (Attribute_to_gnu) <Attr_Access>: Assert that
+       the prefix is not a type.
+
 2020-05-09  Eric Botcazou  <ebotcazou@adacore.com>
 
        * gcc-interface/ada-tree.h (TYPE_PACKED_ARRAY_TYPE_P): Rename into...
index a2f06d774d3bb2362dcd4bac88e74b4fec1913d4..48c038049565ced364101fa7e40220c2810d4e4a 100644 (file)
@@ -2302,6 +2302,9 @@ Attribute_to_gnu (Node_Id gnat_node, tree *gnu_result_type_p, int attribute)
     case Attr_Access:
     case Attr_Unchecked_Access:
     case Attr_Code_Address:
+      /* Taking the address of a type does not make sense.  */
+      gcc_assert (TREE_CODE (gnu_prefix) != TYPE_DECL);
+
       gnu_result_type = get_unpadded_type (Etype (gnat_node));
       gnu_result
        = build_unary_op (((attribute == Attr_Address