+2019-07-22 Javier Miranda <miranda@adacore.com>
+
+ * freeze.adb (Freeze_Subprogram): Check that C++ constructors
+ must have external or link name.
+
2019-07-22 Ed Schonberg <schonberg@adacore.com>
* sem_res.adb (Resolve_Selected_Component): If the prefix has a
with Sinfo; use Sinfo;
with Snames; use Snames;
with Stand; use Stand;
+with Stringt; use Stringt;
with Targparm; use Targparm;
with Tbuild; use Tbuild;
with Ttypes; use Ttypes;
Set_Is_Pure (E, False);
end if;
+ -- For C++ constructors check that their external name has been given
+ -- (either in pragma CPP_Constructor or in a pragma import).
+
+ if Is_Constructor (E)
+ and then
+ (No (Interface_Name (E))
+ or else String_Equal
+ (L => Strval (Interface_Name (E)),
+ R => Strval (Get_Default_External_Name (E))))
+ then
+ Error_Msg_N
+ ("'C++ constructor must have external name or link name", E);
+ end if;
+
-- We also reset the Pure indication on a subprogram with an Address
-- parameter, because the parameter may be used as a pointer and the
-- referenced data may change even if the address value does not.
+2019-07-22 Javier Miranda <miranda@adacore.com>
+
+ * gnat.dg/cpp_constructor2.adb: New testcase.
+
2019-07-22 Ed Schonberg <schonberg@adacore.com>
* gnat.dg/warn22.adb: New testcase.
--- /dev/null
+-- { dg-do compile }
+
+procedure CPP_Constructor2 is
+
+ package P is
+ type X is tagged limited record
+ A, B, C, D : Integer;
+ end record;
+ pragma Import (Cpp, X);
+
+ procedure F1 (V : X);
+ pragma Import (Cpp, F1);
+
+ function F2 return X; -- { dg-error "C\\+\\+ constructor must have external name or link name" }
+ pragma Cpp_Constructor (F2);
+ end P;
+begin
+ null;
+end CPP_Constructor2;