Commit 5644b7e8 by Arnaud Charlet

[multiple changes]

2013-10-14  Vincent Celier  <celier@adacore.com>

	* snames.ads-tmpl: Add new standard name Library_Rpath_Options.

2013-10-14  Tristan Gingold  <gingold@adacore.com>

	* sem_prag.adb (Process_Import_Or_Interface): Allow importing
	of exception using convention Cpp.
	* exp_prag.adb (Expand_Pragma_Import_Or_Interface): Expand cpp
	imported exceptions.
	* raise-gcc.c (is_handled_by): Filter C++ exception occurrences.
	* gnat_rm.texi: Document how to import C++ exceptions.

2013-10-14  Jose Ruiz  <ruiz@adacore.com>

	* sem_ch13.adb (Sem_Ch13.Analyze_Aspect_Specification): For
	Priority and CPU aspects, when checking, issue a warning only
	if it is obviously not a main program.

2013-10-14  Tristan Gingold  <gingold@adacore.com>

	* adaint.c: Fix condition for AIX. Minor reformatting.

From-SVN: r203549
parent 0895ac08
2013-10-14 Vincent Celier <celier@adacore.com>
* snames.ads-tmpl: Add new standard name Library_Rpath_Options.
2013-10-14 Tristan Gingold <gingold@adacore.com>
* sem_prag.adb (Process_Import_Or_Interface): Allow importing
of exception using convention Cpp.
* exp_prag.adb (Expand_Pragma_Import_Or_Interface): Expand cpp
imported exceptions.
* raise-gcc.c (is_handled_by): Filter C++ exception occurrences.
* gnat_rm.texi: Document how to import C++ exceptions.
2013-10-14 Jose Ruiz <ruiz@adacore.com>
* sem_ch13.adb (Sem_Ch13.Analyze_Aspect_Specification): For
Priority and CPU aspects, when checking, issue a warning only
if it is obviously not a main program.
2013-10-14 Tristan Gingold <gingold@adacore.com>
* adaint.c: Fix condition for AIX. Minor reformatting.
2013-10-14 Robert Dewar <dewar@adacore.com> 2013-10-14 Robert Dewar <dewar@adacore.com>
* sem_ch3.adb, sem_prag.adb, prj.ads: Minor reformatting. * sem_ch3.adb, sem_prag.adb, prj.ads: Minor reformatting.
......
...@@ -575,6 +575,64 @@ package body Exp_Prag is ...@@ -575,6 +575,64 @@ package body Exp_Prag is
if No (Init_Call) and then Present (Expression (Parent (Def_Id))) then if No (Init_Call) and then Present (Expression (Parent (Def_Id))) then
Set_Expression (Parent (Def_Id), Empty); Set_Expression (Parent (Def_Id), Empty);
end if; end if;
elsif Ekind (Def_Id) = E_Exception
and then Convention (Def_Id) = Convention_CPP
then
-- Import a C++ convention
declare
Loc : constant Source_Ptr := Sloc (N);
Exdata : List_Id;
Lang_Char : Node_Id;
Foreign_Data : Node_Id;
Rtti_Name : constant Node_Id := Arg3 (N);
Dum : constant Entity_Id := Make_Temporary (Loc, 'D');
begin
Exdata := Component_Associations (Expression (Parent (Def_Id)));
Lang_Char := Next (First (Exdata));
-- Change the one-character language designator to 'C'
Rewrite (Expression (Lang_Char),
Make_Character_Literal (Loc,
Chars => Name_uC,
Char_Literal_Value =>
UI_From_Int (Character'Pos ('C'))));
Analyze (Expression (Lang_Char));
-- Change the value of Foreign_Data
Foreign_Data := Next (Next (Next (Next (Lang_Char))));
Insert_Actions (Def_Id, New_List (
Make_Object_Declaration (Loc,
Defining_Identifier => Dum,
Object_Definition =>
New_Occurrence_Of (Standard_Character, Loc)),
Make_Pragma (Loc,
Chars => Name_Import,
Pragma_Argument_Associations => New_List (
Make_Pragma_Argument_Association (Loc,
Expression => Make_Identifier (Loc, Name_Ada)),
Make_Pragma_Argument_Association (Loc,
Expression => Make_Identifier (Loc, Chars (Dum))),
Make_Pragma_Argument_Association (Loc,
Chars => Name_Link_Name,
Expression => Relocate_Node (Rtti_Name))))));
Rewrite (Expression (Foreign_Data),
Unchecked_Convert_To (Standard_A_Char,
Make_Attribute_Reference (Loc,
Prefix => Make_Identifier (Loc, Chars (Dum)),
Attribute_Name => Name_Address)));
Analyze (Expression (Foreign_Data));
end;
end if; end if;
end Expand_Pragma_Import_Or_Interface; end Expand_Pragma_Import_Or_Interface;
......
...@@ -11963,6 +11963,7 @@ where @var{nnn} is an integer. ...@@ -11963,6 +11963,7 @@ where @var{nnn} is an integer.
@emph{Exception_Name:} nnnnn @emph{Exception_Name:} nnnnn
@emph{Message:} mmmmm @emph{Message:} mmmmm
@emph{PID:} ppp @emph{PID:} ppp
@emph{Load address:} 0xhhhh
@emph{Call stack traceback locations:} @emph{Call stack traceback locations:}
0xhhhh 0xhhhh 0xhhhh ... 0xhhh 0xhhhh 0xhhhh 0xhhhh ... 0xhhh
@end smallexample @end smallexample
...@@ -11984,10 +11985,12 @@ present only if the Process Id is nonzero). Currently we are ...@@ -11984,10 +11985,12 @@ present only if the Process Id is nonzero). Currently we are
not making use of this field. not making use of this field.
@item @item
The Call stack traceback locations line and the following values The Load address line, the Call stack traceback locations line and the
are present only if at least one traceback location was recorded. following values are present only if at least one traceback location was
The values are given in C style format, with lower case letters recorded. The Load address indicates the address at which the main executable
for a-f, and only as many digits present as are necessary. was loaded; this line may not be present if operating system hasn't relocated
the main executable. The values are given in C style format, with lower case
letters for a-f, and only as many digits present as are necessary.
@end itemize @end itemize
@noindent @noindent
...@@ -18874,6 +18877,19 @@ occurrence has no message, and the simple name of the exception identity ...@@ -18874,6 +18877,19 @@ occurrence has no message, and the simple name of the exception identity
contains @samp{Foreign_Exception}. Finalization and awaiting dependent contains @samp{Foreign_Exception}. Finalization and awaiting dependent
tasks works properly when such foreign exceptions are propagated. tasks works properly when such foreign exceptions are propagated.
It is also possible to import a C++ exception using the following syntax:
@smallexample @c ada
LOCAL_NAME : exception;
pragma Import (Cpp,
[Entity =>] LOCAL_NAME,
[External_Name =>] static_string_EXPRESSION);
@end smallexample
@noident
The @code{External_Name} is the name of the C++ RTTI symbol. You can then
cover a specific C++ exception in an exception handler.
@node Interfacing to COBOL @node Interfacing to COBOL
@section Interfacing to COBOL @section Interfacing to COBOL
......
...@@ -87,6 +87,36 @@ extern void __gnat_unhandled_except_handler (_Unwind_Exception *); ...@@ -87,6 +87,36 @@ extern void __gnat_unhandled_except_handler (_Unwind_Exception *);
#define CXX_EXCEPTION_CLASS 0x474e5543432b2b00ULL #define CXX_EXCEPTION_CLASS 0x474e5543432b2b00ULL
#define GNAT_EXCEPTION_CLASS 0x474e552d41646100ULL #define GNAT_EXCEPTION_CLASS 0x474e552d41646100ULL
/* Structure of a C++ exception, represented as a C structure... See
unwind-cxx.h for the full definition. */
struct __cxa_exception
{
void *exceptionType;
void (*exceptionDestructor)(void *);
void (*unexpectedHandler)();
void (*terminateHandler)();
struct __cxa_exception *nextException;
int handlerCount;
#ifdef __ARM_EABI_UNWINDER__
struct __cxa_exception* nextPropagatingException;
int propagationCount;
#else
int handlerSwitchValue;
const unsigned char *actionRecord;
const unsigned char *languageSpecificData;
_Unwind_Ptr catchTemp;
void *adjustedPtr;
#endif
_Unwind_Exception unwindHeader;
};
/* -------------------------------------------------------------- /* --------------------------------------------------------------
-- The DB stuff below is there for debugging purposes only. -- -- The DB stuff below is there for debugging purposes only. --
-------------------------------------------------------------- */ -------------------------------------------------------------- */
...@@ -882,6 +912,22 @@ is_handled_by (_Unwind_Ptr choice, _GNAT_Exception * propagated_exception) ...@@ -882,6 +912,22 @@ is_handled_by (_Unwind_Ptr choice, _GNAT_Exception * propagated_exception)
|| choice == (_Unwind_Ptr) &Foreign_Exception) || choice == (_Unwind_Ptr) &Foreign_Exception)
return handler; return handler;
/* C++ exception occurrences. */
if (propagated_exception->common.exception_class == CXX_EXCEPTION_CLASS
&& Language_For (choice) == 'C')
{
void *choice_typeinfo = Foreign_Data_For (choice);
void *except_typeinfo =
(((struct __cxa_exception *)
((_Unwind_Exception *)propagated_exception + 1)) - 1)->exceptionType;
/* Typeinfo are directly compared, which might not be correct if they
aren't merged. ??? We should call the == operator if this module is
compiled in C++. */
if (choice_typeinfo == except_typeinfo)
return handler;
}
return nothing; return nothing;
} }
......
...@@ -1834,11 +1834,14 @@ package body Sem_Ch13 is ...@@ -1834,11 +1834,14 @@ package body Sem_Ch13 is
Flag_Non_Static_Expr Flag_Non_Static_Expr
("aspect requires static expression!", Expr); ("aspect requires static expression!", Expr);
-- Check whether this is the main subprogram -- Check whether this is the main subprogram. Issue a
-- warning only if it is obviously not a main program
elsif Current_Sem_Unit /= Main_Unit -- (when it has parameters or when the subprogram is
and then -- within a package).
Cunit_Entity (Current_Sem_Unit) /= Main_Unit_Entity
elsif Present (Parameter_Specifications
(Specification (N)))
or else not Is_Compilation_Unit (Defining_Entity (N))
then then
-- See ARM D.1 (14/3) and D.16 (12/3) -- See ARM D.1 (14/3) and D.16 (12/3)
......
...@@ -7126,6 +7126,34 @@ package body Sem_Prag is ...@@ -7126,6 +7126,34 @@ package body Sem_Prag is
Check_CPP_Type_Has_No_Defaults (Def_Id); Check_CPP_Type_Has_No_Defaults (Def_Id);
end if; end if;
-- Import a CPP exception
elsif C = Convention_CPP
and then Ekind (Def_Id) = E_Exception
then
if No (Arg3) then
Error_Pragma_Arg
("'External_'Name arguments is required for 'Cpp exception",
Arg3);
else
-- As only a string is allowed, Check_Arg_Is_External_Name
-- isn't called.
Check_Arg_Is_Static_Expression (Arg3, Standard_String);
end if;
if Present (Arg4) then
Error_Pragma_Arg
("Link_Name argument not allowed for imported Cpp exception",
Arg4);
end if;
-- Do not call Set_Interface_Name as the name of the exception
-- shouldn't be modified (and in particular it shouldn't be
-- the External_Name). For exceptions, the External_Name is the
-- name of the RTTI structure.
-- ??? Emit an error if pragma Import/Export_Exception is present
elsif Nkind (Parent (Def_Id)) = N_Incomplete_Type_Declaration then elsif Nkind (Parent (Def_Id)) = N_Incomplete_Type_Declaration then
Check_No_Link_Name; Check_No_Link_Name;
Check_Arg_Count (3); Check_Arg_Count (3);
......
...@@ -1302,6 +1302,7 @@ package Snames is ...@@ -1302,6 +1302,7 @@ package Snames is
Name_Library_Options : constant Name_Id := N + $; Name_Library_Options : constant Name_Id := N + $;
Name_Library_Partial_Linker : constant Name_Id := N + $; Name_Library_Partial_Linker : constant Name_Id := N + $;
Name_Library_Reference_Symbol_File : constant Name_Id := N + $; Name_Library_Reference_Symbol_File : constant Name_Id := N + $;
Name_Library_Rpath_Options : constant Name_Id := N + $; -- GB
Name_Library_Standalone : constant Name_Id := N + $; Name_Library_Standalone : constant Name_Id := N + $;
Name_Library_Encapsulated_Options : constant Name_Id := N + $; -- GB Name_Library_Encapsulated_Options : constant Name_Id := N + $; -- GB
Name_Library_Encapsulated_Supported : constant Name_Id := N + $; -- GB Name_Library_Encapsulated_Supported : constant Name_Id := N + $; -- GB
......
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