r260721 - in /trunk/gcc/ada: ChangeLog freeze.a...

pmderodat@gcc.gnu.org pmderodat@gcc.gnu.org
Fri May 25 09:03:00 GMT 2018


Author: pmderodat
Date: Fri May 25 09:03:29 2018
New Revision: 260721

URL: https://gcc.gnu.org/viewcvs?rev=260721&root=gcc&view=rev
Log:
[Ada] Support for C99 and C++ standard boolean types

This change the type Interfaces.C.Extensions.bool to be fully compatible
with the C99 and C++ standard boolean types by making it a fully-fledged
boolean type with convention C.

The following C+Ada program must compile quietly in LTO mode:

bool b;

struct S {};

bool foo (struct S *s) { return true; }

pragma Ada_2005;
pragma Style_Checks (Off);

with Interfaces.C; use Interfaces.C;
with Interfaces.C.Extensions;

package t_c is

   b : aliased Extensions.bool;  -- t.c:3
   pragma Import (C, b, "b");

   type S is record
      null;
   end record;
   pragma Convention (C_Pass_By_Copy, S);  -- t.c:5

   function foo (the_s : access S) return Extensions.bool;  -- t.c:7
   pragma Import (C, foo, "foo");

end t_c;

with t_c; use t_c;

procedure P_C is

  Dummy : aliased S;

begin
  b := foo (Dummy'Access);
end;

2018-05-25  Eric Botcazou  <ebotcazou@adacore.com>

gcc/ada/

	* freeze.adb (Freeze_Enumeration_Type): Do not give integer size to a
	boolean type with convention C.
	* libgnat/i-cexten.ads (bool): Change to boolean with convention C.
	* gcc-interface/decl.c (gnat_to_gnu_entity): Add new local variable
	FOREIGN and use it throughout the function.
	<E_Enumeration_Type>: Set precision 1 on boolean types with foreign
	convention.
	<E_Enumeration_Subtype>: Likewise for subtypes.
	<E_Record_Type>: Force the size of a storage unit on empty classes.
	* gcc-interface/utils.c (make_type_from_size) <BOOLEAN_TYPE>: Skip
	boolean types with precision 1 if the size is the expected one.

Modified:
    trunk/gcc/ada/ChangeLog
    trunk/gcc/ada/freeze.adb
    trunk/gcc/ada/gcc-interface/decl.c
    trunk/gcc/ada/gcc-interface/utils.c
    trunk/gcc/ada/libgnat/i-cexten.ads



More information about the Gcc-cvs mailing list