diff mbox series

[1/X,mid-end] Fix declared type of personality functions

Message ID HE1PR0802MB22518CDF09D50FA3396A1770E07E0@HE1PR0802MB2251.eurprd08.prod.outlook.com
State New
Headers show
Series [1/X,mid-end] Fix declared type of personality functions | expand

Commit Message

Matthew Malcomson Nov. 5, 2019, 11:33 a.m. UTC
`build_personality_function` generates a declaration for a personality
function.  The type it declares for these functions doesn't match the
type of the actual personality functions that are defined by the C++
unwinding ABI.

This doesn't cause any crashes since the compiler never generates a call
to these decl's, and hence the type of the function is never used.
Nonetheless, for the sake of consistency and readability we update the
type of this declaration.

(See libstdc++-v3/libsupc++/unwind-cxx.h for declaration of _gxx_personality_v0
to compare types).

gcc/ChangeLog:

2019-11-05  Matthew Malcomson  <matthew.malcomson@arm.com>

	* expr.c (build_personality_function): Fix generated type to
	match actual personality functions.



###############     Attachment also inlined for ease of reply    ###############
diff --git a/gcc/expr.c b/gcc/expr.c
index 2f2b53f8b6905013b4214eea137d67c666b0c795..7dc37a288ebffb99c990442cf339b848c5fa9d2e 100644
--- a/gcc/expr.c
+++ b/gcc/expr.c
@@ -12525,7 +12525,8 @@ build_personality_function (const char *lang)
 
   name = ACONCAT (("__", lang, "_personality", unwind_and_version, NULL));
 
-  type = build_function_type_list (integer_type_node, integer_type_node,
+  type = build_function_type_list (unsigned_type_node,
+				   integer_type_node, integer_type_node,
 				   long_long_unsigned_type_node,
 				   ptr_type_node, ptr_type_node, NULL_TREE);
   decl = build_decl (UNKNOWN_LOCATION, FUNCTION_DECL,

Comments

Richard Biener Nov. 5, 2019, 11:41 a.m. UTC | #1
On Tue, 5 Nov 2019, Matthew Malcomson wrote:

> `build_personality_function` generates a declaration for a personality
> function.  The type it declares for these functions doesn't match the
> type of the actual personality functions that are defined by the C++
> unwinding ABI.
> 
> This doesn't cause any crashes since the compiler never generates a call
> to these decl's, and hence the type of the function is never used.
> Nonetheless, for the sake of consistency and readability we update the
> type of this declaration.
> 
> (See libstdc++-v3/libsupc++/unwind-cxx.h for declaration of _gxx_personality_v0
> to compare types).

OK.  I believe _Unwind_Personality_Fn in libgcc/unwind-generic.h is the
correct reference.

Thanks,
Richard.

> gcc/ChangeLog:
> 
> 2019-11-05  Matthew Malcomson  <matthew.malcomson@arm.com>
> 
> 	* expr.c (build_personality_function): Fix generated type to
> 	match actual personality functions.
> 
> 
> 
> ###############     Attachment also inlined for ease of reply    ###############
> 
> 
> diff --git a/gcc/expr.c b/gcc/expr.c
> index 2f2b53f8b6905013b4214eea137d67c666b0c795..7dc37a288ebffb99c990442cf339b848c5fa9d2e 100644
> --- a/gcc/expr.c
> +++ b/gcc/expr.c
> @@ -12525,7 +12525,8 @@ build_personality_function (const char *lang)
>  
>    name = ACONCAT (("__", lang, "_personality", unwind_and_version, NULL));
>  
> -  type = build_function_type_list (integer_type_node, integer_type_node,
> +  type = build_function_type_list (unsigned_type_node,
> +				   integer_type_node, integer_type_node,
>  				   long_long_unsigned_type_node,
>  				   ptr_type_node, ptr_type_node, NULL_TREE);
>    decl = build_decl (UNKNOWN_LOCATION, FUNCTION_DECL,
> 
>
diff mbox series

Patch

diff --git a/gcc/expr.c b/gcc/expr.c
index 2f2b53f8b6905013b4214eea137d67c666b0c795..7dc37a288ebffb99c990442cf339b848c5fa9d2e 100644
--- a/gcc/expr.c
+++ b/gcc/expr.c
@@ -12525,7 +12525,8 @@  build_personality_function (const char *lang)
 
   name = ACONCAT (("__", lang, "_personality", unwind_and_version, NULL));
 
-  type = build_function_type_list (integer_type_node, integer_type_node,
+  type = build_function_type_list (unsigned_type_node,
+				   integer_type_node, integer_type_node,
 				   long_long_unsigned_type_node,
 				   ptr_type_node, ptr_type_node, NULL_TREE);
   decl = build_decl (UNKNOWN_LOCATION, FUNCTION_DECL,