Commit ff0889eb by Bob Duff Committed by Pierre-Marie de Rodat

[Ada] Alignment may be specified as zero

An Alignment clause or an aspect_specification for Alignment may be
specified as 0, which is treated the same as 1.

2019-08-14  Bob Duff  <duff@adacore.com>

gcc/ada/

	* sem_ch13.adb (Get_Alignment_Value): Return 1 for Alignment 0,
	and do not give an error.
	* doc/gnat_rm/representation_clauses_and_pragmas.rst: Update the
	corresponding documentation.
	* gnat_rm.texi: Regenerate.

gcc/testsuite/

	* gnat.dg/alignment15.adb: New testcase.

From-SVN: r274473
parent f0539a79
2019-08-14 Bob Duff <duff@adacore.com>
* sem_ch13.adb (Get_Alignment_Value): Return 1 for Alignment 0,
and do not give an error.
* doc/gnat_rm/representation_clauses_and_pragmas.rst: Update the
corresponding documentation.
* gnat_rm.texi: Regenerate.
2019-08-14 Eric Botcazou <ebotcazou@adacore.com>
* inline.adb (Add_Pending_Instantiation): Fix off-by-one error
......
......@@ -30,9 +30,11 @@ Alignment Clauses
.. index:: Alignment Clause
GNAT requires that all alignment clauses specify a power of 2, and all
default alignments are always a power of 2. The default alignment
values are as follows:
GNAT requires that all alignment clauses specify 0 or a power of 2, and
all default alignments are always a power of 2. Specifying 0 is the
same as specifying 1.
The default alignment values are as follows:
* *Elementary Types*.
......
......@@ -21,7 +21,7 @@
@copying
@quotation
GNAT Reference Manual , Jul 31, 2019
GNAT Reference Manual , Aug 01, 2019
AdaCore
......@@ -18369,9 +18369,11 @@ and this section describes the additional capabilities provided.
@geindex Alignment Clause
GNAT requires that all alignment clauses specify a power of 2, and all
default alignments are always a power of 2. The default alignment
values are as follows:
GNAT requires that all alignment clauses specify 0 or a power of 2, and
all default alignments are always a power of 2. Specifying 0 is the
same as specifying 1.
The default alignment values are as follows:
@itemize *
......@@ -11509,7 +11509,7 @@ package body Sem_Ch13 is
if Align = No_Uint then
return No_Uint;
elsif Align <= 0 then
elsif Align < 0 then
-- This error is suppressed in ASIS mode to allow for different ASIS
-- back ends or ASIS-based tools to query the illegal clause.
......@@ -11520,6 +11520,11 @@ package body Sem_Ch13 is
return No_Uint;
-- If Alignment is specified to be 0, we treat it the same as 1
elsif Align = 0 then
return Uint_1;
else
for J in Int range 0 .. 64 loop
declare
......
2019-08-14 Bob Duff <duff@adacore.com>
* gnat.dg/alignment15.adb: New testcase.
2019-08-14 Bob Duff <duff@adacore.com>
* gnat.dg/warn27.adb: New testcase.
2019-08-14 Bob Duff <duff@adacore.com>
......
-- { dg-compile }
procedure Alignment15 is
type T0 is record
X : Integer;
end record;
for T0'Alignment use 0;
type T00 is record
X : Integer;
end record with Alignment => 0;
Dummy0 : T0;
Dummy00 : T00;
begin
null;
end;
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment