diff mbox series

[Arm] Allow the use of arm_cde.h for C++

Message ID AM6PR08MB31577815626CB8BE3BB66F9DE0C10@AM6PR08MB3157.eurprd08.prod.outlook.com
State New
Headers show
Series [Arm] Allow the use of arm_cde.h for C++ | expand

Commit Message

Matthew Malcomson April 9, 2020, 2:31 p.m. UTC
arm_cde.h includes the arm_mve_types.h header, which declares some C++
overloaded functions.

There is a superfluous `extern "C"` statement in arm_cde.h, which
encompasses these functions.  This means that if compiling for C++, the
overloaded functions are declared, but are declared without name
mangling.  Hence all the function names are the same and we have many
conflicting declarations.

Testing Done:
  Regression tested for arm-none-eabi.

gcc/ChangeLog:

2020-04-09  Matthew Malcomson  <matthew.malcomson@arm.com>

	* config/arm/arm_cde.h: Remove `extern "C"` when compiling for
	C++.

gcc/testsuite/ChangeLog:

2020-04-09  Matthew Malcomson  <matthew.malcomson@arm.com>

	* g++.target/arm/cde_mve.C: New test.



###############     Attachment also inlined for ease of reply    ###############
diff --git a/gcc/config/arm/arm_cde.h b/gcc/config/arm/arm_cde.h
index d8ddda6bd648d8b94e97f7b6403b7708cebc9eb3..0ba3ee02d057dd280c9b3400ef70b46ed472aec3 100644
--- a/gcc/config/arm/arm_cde.h
+++ b/gcc/config/arm/arm_cde.h
@@ -27,10 +27,6 @@
 #ifndef _GCC_ARM_CDE_H
 #define _GCC_ARM_CDE_H 1
 
-#ifdef __cplusplus
-extern "C" {
-#endif
-
 #include <stdint.h>
 
 #if defined (__ARM_FEATURE_CDE)
@@ -177,8 +173,4 @@ extern "C" {
 
 #endif
 
-#ifdef __cplusplus
-}
-#endif
-
 #endif
diff --git a/gcc/testsuite/g++.target/arm/cde_mve.C b/gcc/testsuite/g++.target/arm/cde_mve.C
new file mode 100644
index 0000000000000000000000000000000000000000..897cbd2b8119471385c1c51158b1aa4851acbaf1
--- /dev/null
+++ b/gcc/testsuite/g++.target/arm/cde_mve.C
@@ -0,0 +1,10 @@
+/* { dg-do compile } */
+/* { dg-require-effective-target arm_v8_1m_main_cde_mve_fp_ok } */
+/* { dg-add-options arm_v8_1m_main_cde_mve_fp } */
+
+/* Ensure this compiles.  */
+#include "arm_cde.h"
+int foo ()
+{
+  return 1;
+}

Comments

Kyrylo Tkachov April 9, 2020, 2:59 p.m. UTC | #1
> -----Original Message-----
> From: Matthew Malcomson <Matthew.Malcomson@arm.com>
> Sent: 09 April 2020 15:31
> To: gcc-patches@gcc.gnu.org
> Cc: nd <nd@arm.com>; Ramana Radhakrishnan
> <Ramana.Radhakrishnan@arm.com>; Kyrylo Tkachov
> <Kyrylo.Tkachov@arm.com>; Richard Earnshaw
> <Richard.Earnshaw@arm.com>; nickc@redhat.com
> Subject: [Arm] Allow the use of arm_cde.h for C++
> 
> arm_cde.h includes the arm_mve_types.h header, which declares some C++
> overloaded functions.
> 
> There is a superfluous `extern "C"` statement in arm_cde.h, which
> encompasses these functions.  This means that if compiling for C++, the
> overloaded functions are declared, but are declared without name
> mangling.  Hence all the function names are the same and we have many
> conflicting declarations.
> 
> Testing Done:
>   Regression tested for arm-none-eabi.

Ok.
Thanks,
Kyrill

> 
> gcc/ChangeLog:
> 
> 2020-04-09  Matthew Malcomson  <matthew.malcomson@arm.com>
> 
> 	* config/arm/arm_cde.h: Remove `extern "C"` when compiling for
> 	C++.
> 
> gcc/testsuite/ChangeLog:
> 
> 2020-04-09  Matthew Malcomson  <matthew.malcomson@arm.com>
> 
> 	* g++.target/arm/cde_mve.C: New test.
> 
> 
> 
> ###############     Attachment also inlined for ease of reply
> ###############
> 
> 
> diff --git a/gcc/config/arm/arm_cde.h b/gcc/config/arm/arm_cde.h
> index
> d8ddda6bd648d8b94e97f7b6403b7708cebc9eb3..0ba3ee02d057dd280c9b34
> 00ef70b46ed472aec3 100644
> --- a/gcc/config/arm/arm_cde.h
> +++ b/gcc/config/arm/arm_cde.h
> @@ -27,10 +27,6 @@
>  #ifndef _GCC_ARM_CDE_H
>  #define _GCC_ARM_CDE_H 1
> 
> -#ifdef __cplusplus
> -extern "C" {
> -#endif
> -
>  #include <stdint.h>
> 
>  #if defined (__ARM_FEATURE_CDE)
> @@ -177,8 +173,4 @@ extern "C" {
> 
>  #endif
> 
> -#ifdef __cplusplus
> -}
> -#endif
> -
>  #endif
> diff --git a/gcc/testsuite/g++.target/arm/cde_mve.C
> b/gcc/testsuite/g++.target/arm/cde_mve.C
> new file mode 100644
> index
> 0000000000000000000000000000000000000000..897cbd2b8119471385c1c51
> 158b1aa4851acbaf1
> --- /dev/null
> +++ b/gcc/testsuite/g++.target/arm/cde_mve.C
> @@ -0,0 +1,10 @@
> +/* { dg-do compile } */
> +/* { dg-require-effective-target arm_v8_1m_main_cde_mve_fp_ok } */
> +/* { dg-add-options arm_v8_1m_main_cde_mve_fp } */
> +
> +/* Ensure this compiles.  */
> +#include "arm_cde.h"
> +int foo ()
> +{
> +  return 1;
> +}
diff mbox series

Patch

diff --git a/gcc/config/arm/arm_cde.h b/gcc/config/arm/arm_cde.h
index d8ddda6bd648d8b94e97f7b6403b7708cebc9eb3..0ba3ee02d057dd280c9b3400ef70b46ed472aec3 100644
--- a/gcc/config/arm/arm_cde.h
+++ b/gcc/config/arm/arm_cde.h
@@ -27,10 +27,6 @@ 
 #ifndef _GCC_ARM_CDE_H
 #define _GCC_ARM_CDE_H 1
 
-#ifdef __cplusplus
-extern "C" {
-#endif
-
 #include <stdint.h>
 
 #if defined (__ARM_FEATURE_CDE)
@@ -177,8 +173,4 @@  extern "C" {
 
 #endif
 
-#ifdef __cplusplus
-}
-#endif
-
 #endif
diff --git a/gcc/testsuite/g++.target/arm/cde_mve.C b/gcc/testsuite/g++.target/arm/cde_mve.C
new file mode 100644
index 0000000000000000000000000000000000000000..897cbd2b8119471385c1c51158b1aa4851acbaf1
--- /dev/null
+++ b/gcc/testsuite/g++.target/arm/cde_mve.C
@@ -0,0 +1,10 @@ 
+/* { dg-do compile } */
+/* { dg-require-effective-target arm_v8_1m_main_cde_mve_fp_ok } */
+/* { dg-add-options arm_v8_1m_main_cde_mve_fp } */
+
+/* Ensure this compiles.  */
+#include "arm_cde.h"
+int foo ()
+{
+  return 1;
+}