diff options
author | Kaveh R. Ghazi <ghazi@caip.rutgers.edu> | 2008-05-23 04:47:12 +0000 |
---|---|---|
committer | Kaveh Ghazi <ghazi@gcc.gnu.org> | 2008-05-23 04:47:12 +0000 |
commit | 3bf5906b317941790438b4503a2234cdc710dca3 (patch) | |
tree | a7912b37870308a35af6d7fef3d8dedaa111ecf9 /gcc/c-common.c | |
parent | 2aa5c17ce58d1e54763875dfb10580fbdd871731 (diff) | |
download | gcc-3bf5906b317941790438b4503a2234cdc710dca3.zip gcc-3bf5906b317941790438b4503a2234cdc710dca3.tar.gz gcc-3bf5906b317941790438b4503a2234cdc710dca3.tar.bz2 |
builtin-types.def (BT_FN_INT_INT_INT_INT_INT_INT_VAR): New.
* builtin-types.def (BT_FN_INT_INT_INT_INT_INT_INT_VAR): New.
* builtins.c (fold_builtin_fpclassify): New.
(fold_builtin_varargs): Handle BUILT_IN_FPCLASSIFY.
* builtins.def (BUILT_IN_FPCLASSIFY): New.
* c-common.c (handle_type_generic_attribute): Adjust to accept
fixed arguments before an elipsis.
(check_builtin_function_arguments): Handle BUILT_IN_FPCLASSIFY.
* doc/extend.texi: Document __builtin_fpclassify.
testsuite:
* gcc.dg/builtins-error.c: Test __builtin_fpclassify. Also
add tests for all previous type-generic builtins.
* gcc.dg/pr28796-2.c: Add -DUNSAFE flag.
* gcc.dg/tg-tests.h: Test __builtin_fpclassify.
From-SVN: r135789
Diffstat (limited to 'gcc/c-common.c')
-rw-r--r-- | gcc/c-common.c | 36 |
1 files changed, 34 insertions, 2 deletions
diff --git a/gcc/c-common.c b/gcc/c-common.c index 67c9c0b..70ba5cc 100644 --- a/gcc/c-common.c +++ b/gcc/c-common.c @@ -6528,8 +6528,17 @@ handle_type_generic_attribute (tree *node, tree ARG_UNUSED (name), tree ARG_UNUSED (args), int ARG_UNUSED (flags), bool * ARG_UNUSED (no_add_attrs)) { - /* Ensure we have a function type, with no arguments. */ - gcc_assert (TREE_CODE (*node) == FUNCTION_TYPE && ! TYPE_ARG_TYPES (*node)); + tree params; + + /* Ensure we have a function type. */ + gcc_assert (TREE_CODE (*node) == FUNCTION_TYPE); + + params = TYPE_ARG_TYPES (*node); + while (params && ! VOID_TYPE_P (TREE_VALUE (params))) + params = TREE_CHAIN (params); + + /* Ensure we have a variadic function. */ + gcc_assert (!params); return NULL_TREE; } @@ -6712,6 +6721,29 @@ check_builtin_function_arguments (tree fndecl, int nargs, tree *args) } return false; + case BUILT_IN_FPCLASSIFY: + if (validate_nargs (fndecl, nargs, 6)) + { + unsigned i; + + for (i=0; i<5; i++) + if (TREE_CODE (args[i]) != INTEGER_CST) + { + error ("non-const integer argument %u in call to function %qE", + i+1, fndecl); + return false; + } + + if (TREE_CODE (TREE_TYPE (args[5])) != REAL_TYPE) + { + error ("non-floating-point argument in call to function %qE", + fndecl); + return false; + } + return true; + } + return false; + default: return true; } |