aboutsummaryrefslogtreecommitdiff
path: root/gcc
diff options
context:
space:
mode:
authorKito Cheng <kito.cheng@sifive.com>2020-06-19 14:07:39 +0800
committerKito Cheng <kito.cheng@sifive.com>2020-06-22 10:44:44 +0800
commit33d9794b7277a64543914bfbbfd567505e72da6c (patch)
treee226a515d5d0b4b4daa03006a7891d3f44f0628f /gcc
parentf86e11a267aa70c56b300cfe60cfe3a27111b204 (diff)
downloadgcc-33d9794b7277a64543914bfbbfd567505e72da6c.zip
gcc-33d9794b7277a64543914bfbbfd567505e72da6c.tar.gz
gcc-33d9794b7277a64543914bfbbfd567505e72da6c.tar.bz2
RISC-V: Fix compilation failed for frflags builtin in C++ mode
- g++ will complain too few arguments for frflags builtin like bellow message: error: too few arguments to function 'unsigned int __builtin_riscv_frflags(void)' - However it's no arguments needed, it because we declare the function type with VOID arguments, that seems like require a VOID argument in the c++ front-end when GCC tried to resolve the function. gcc/ChangeLog * config/riscv/riscv-builtins.c (RISCV_FTYPE_NAME0): New. (RISCV_FTYPE_ATYPES0): New. (riscv_builtins): Using RISCV_USI_FTYPE for frflags. * config/riscv/riscv-ftypes.def: Remove VOID argument. gcc/testsuite/ChangeLog * g++.target/riscv/frflags.C: New.
Diffstat (limited to 'gcc')
-rw-r--r--gcc/config/riscv/riscv-builtins.c5
-rw-r--r--gcc/config/riscv/riscv-ftypes.def2
-rw-r--r--gcc/testsuite/g++.target/riscv/frflags.C7
3 files changed, 12 insertions, 2 deletions
diff --git a/gcc/config/riscv/riscv-builtins.c b/gcc/config/riscv/riscv-builtins.c
index a45108e..bc95938 100644
--- a/gcc/config/riscv/riscv-builtins.c
+++ b/gcc/config/riscv/riscv-builtins.c
@@ -38,6 +38,7 @@ along with GCC; see the file COPYING3. If not see
#include "langhooks.h"
/* Macros to create an enumeration identifier for a function prototype. */
+#define RISCV_FTYPE_NAME0(A) RISCV_##A##_FTYPE
#define RISCV_FTYPE_NAME1(A, B) RISCV_##A##_FTYPE_##B
/* Classifies the prototype of a built-in function. */
@@ -121,11 +122,13 @@ AVAIL (hard_float, TARGET_HARD_FLOAT)
/* RISCV_FTYPE_ATYPESN takes N RISCV_FTYPES-like type codes and lists
their associated RISCV_ATYPEs. */
+#define RISCV_FTYPE_ATYPES0(A) \
+ RISCV_ATYPE_##A
#define RISCV_FTYPE_ATYPES1(A, B) \
RISCV_ATYPE_##A, RISCV_ATYPE_##B
static const struct riscv_builtin_description riscv_builtins[] = {
- DIRECT_BUILTIN (frflags, RISCV_USI_FTYPE_VOID, hard_float),
+ DIRECT_BUILTIN (frflags, RISCV_USI_FTYPE, hard_float),
DIRECT_NO_TARGET_BUILTIN (fsflags, RISCV_VOID_FTYPE_USI, hard_float)
};
diff --git a/gcc/config/riscv/riscv-ftypes.def b/gcc/config/riscv/riscv-ftypes.def
index 5edeb48..1c6bc4e 100644
--- a/gcc/config/riscv/riscv-ftypes.def
+++ b/gcc/config/riscv/riscv-ftypes.def
@@ -26,5 +26,5 @@ along with GCC; see the file COPYING3. If not see
LIST contains the return-type code followed by the codes for each
argument type. */
-DEF_RISCV_FTYPE (1, (USI, VOID))
+DEF_RISCV_FTYPE (0, (USI))
DEF_RISCV_FTYPE (1, (VOID, USI))
diff --git a/gcc/testsuite/g++.target/riscv/frflags.C b/gcc/testsuite/g++.target/riscv/frflags.C
new file mode 100644
index 0000000..6353044
--- /dev/null
+++ b/gcc/testsuite/g++.target/riscv/frflags.C
@@ -0,0 +1,7 @@
+/* { dg-options "-O2 -march=rv32if -mabi=ilp32f" } */
+/* { dg-do compile } */
+
+int f()
+{
+ return __builtin_riscv_frflags();
+}