]> git.ipfire.org Git - thirdparty/gcc.git/commit
ada: Reject nonconfirming size clauses on objects of floating-point types
authorEric Botcazou <ebotcazou@adacore.com>
Wed, 15 Oct 2025 14:23:26 +0000 (16:23 +0200)
committerMarc Poulhiès <dkm@gcc.gnu.org>
Mon, 3 Nov 2025 14:15:17 +0000 (15:15 +0100)
commitd5c0cf67b5d34661d461b39cc1683b97bb49e64e
tree4f29a6ccb10d71eb4e4602faa95208a9a352ee67
parent1c484bd921bd10caf4cb922638fda01eff575626
ada: Reject nonconfirming size clauses on objects of floating-point types

The RM 13.1(7/5) subclause contains the following sentences: "If the size
of an object is greater than that of its subtype, the additional bits are
padding bits. For an elementary object, these padding bits are normally
read and updated along with the others."

GNAT implements it only for objects of integer and fixed-point types.
For objects of floating-point types, the padding bits are ignored (and
therefore not initialized) with a warning:

  warning: 32 bits of "F" unused [enabled by default]

Implementing it for objects of floating-point types does not seem worth the
hassle, so rejecting nonconfirming size clauses is probably the cleanest
approach (clauses giving the object a size lower than that of its subtype
are already rejected for objects of floating-point types).

gcc/ada/ChangeLog:

* sem_ch13.adb (Analyze_Attribute_Definition_Clause)
<Attribute_Size>: Tweak wording of existing error message for the
size of all elementary objects.  Move error handling for aliased
objects into the block for objects and give a similar error for
(nonaliased) floating-point objects.
gcc/ada/sem_ch13.adb