summaryrefslogtreecommitdiff
path: root/gcc/c-common.c
diff options
context:
space:
mode:
authorghazi <ghazi@138bc75d-0d04-0410-961f-82ee72b054a4>2008-05-23 04:47:12 +0000
committerghazi <ghazi@138bc75d-0d04-0410-961f-82ee72b054a4>2008-05-23 04:47:12 +0000
commit19fbe3a4cad0e35dfa638aaa049892c554299ab7 (patch)
treea7912b37870308a35af6d7fef3d8dedaa111ecf9 /gcc/c-common.c
parentd64890c04581af07969401c844d47f37332327d2 (diff)
downloadgcc-19fbe3a4cad0e35dfa638aaa049892c554299ab7.tar.gz
* 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. git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@135789 138bc75d-0d04-0410-961f-82ee72b054a4
Diffstat (limited to 'gcc/c-common.c')
-rw-r--r--gcc/c-common.c36
1 files changed, 34 insertions, 2 deletions
diff --git a/gcc/c-common.c b/gcc/c-common.c
index 67c9c0b538f..70ba5cc4851 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;
}