aboutsummaryrefslogtreecommitdiff
path: root/gcc/builtins.c
diff options
context:
space:
mode:
authorRichard Guenther <rguenther@suse.de>2007-11-27 12:30:15 +0000
committerRichard Biener <rguenth@gcc.gnu.org>2007-11-27 12:30:15 +0000
commitf4577fcd487059390e485acfd3517648652e6557 (patch)
tree66d142fbae84eb74916a3fd22856d22cba0b8ab1 /gcc/builtins.c
parent28bbc9678774d275d38ef23ee82bd96aab2f2864 (diff)
downloadgcc-f4577fcd487059390e485acfd3517648652e6557.zip
gcc-f4577fcd487059390e485acfd3517648652e6557.tar.gz
gcc-f4577fcd487059390e485acfd3517648652e6557.tar.bz2
builtins.c (fold_builtin_1): Verify the argument types of BUILT_IN_ISNORMAL.
2007-11-27 Richard Guenther <rguenther@suse.de> * builtins.c (fold_builtin_1): Verify the argument types of BUILT_IN_ISNORMAL. (fold_builtin_n): Verify the number of arguments to variadic built-in functions. * gcc.dg/builtins-error.c: New testcase. From-SVN: r130465
Diffstat (limited to 'gcc/builtins.c')
-rw-r--r--gcc/builtins.c57
1 files changed, 57 insertions, 0 deletions
diff --git a/gcc/builtins.c b/gcc/builtins.c
index 1eb6cfc..5befd42 100644
--- a/gcc/builtins.c
+++ b/gcc/builtins.c
@@ -10063,6 +10063,15 @@ fold_builtin_1 (tree fndecl, tree arg0, bool ignore)
case BUILT_IN_ISNAND128:
return fold_builtin_classify (fndecl, arg0, BUILT_IN_ISNAN);
+ case BUILT_IN_ISNORMAL:
+ if (!validate_arg (arg0, REAL_TYPE))
+ {
+ error ("non-floating-point argument to function %qs",
+ IDENTIFIER_POINTER (DECL_NAME (fndecl)));
+ return error_mark_node;
+ }
+ break;
+
case BUILT_IN_PRINTF:
case BUILT_IN_PRINTF_UNLOCKED:
case BUILT_IN_VPRINTF:
@@ -10408,7 +10417,55 @@ fold_builtin_4 (tree fndecl, tree arg0, tree arg1, tree arg2, tree arg3,
static tree
fold_builtin_n (tree fndecl, tree *args, int nargs, bool ignore)
{
+ enum built_in_function fcode = DECL_FUNCTION_CODE (fndecl);
tree ret = NULL_TREE;
+
+ /* Verify the number of arguments for type-generic and thus variadic
+ builtins. */
+ switch (fcode)
+ {
+ case BUILT_IN_ISFINITE:
+ case BUILT_IN_ISINF:
+ case BUILT_IN_ISNAN:
+ case BUILT_IN_ISNORMAL:
+ if (nargs < 1)
+ {
+ error ("too few arguments to function %qs",
+ IDENTIFIER_POINTER (DECL_NAME (fndecl)));
+ return error_mark_node;
+ }
+ else if (nargs > 1)
+ {
+ error ("too many arguments to function %qs",
+ IDENTIFIER_POINTER (DECL_NAME (fndecl)));
+ return error_mark_node;
+ }
+ break;
+
+ case BUILT_IN_ISGREATER:
+ case BUILT_IN_ISGREATEREQUAL:
+ case BUILT_IN_ISLESS:
+ case BUILT_IN_ISLESSEQUAL:
+ case BUILT_IN_ISLESSGREATER:
+ case BUILT_IN_ISUNORDERED:
+ if (nargs < 2)
+ {
+ error ("too few arguments to function %qs",
+ IDENTIFIER_POINTER (DECL_NAME (fndecl)));
+ return error_mark_node;
+ }
+ else if (nargs > 2)
+ {
+ error ("too many arguments to function %qs",
+ IDENTIFIER_POINTER (DECL_NAME (fndecl)));
+ return error_mark_node;
+ }
+ break;
+
+ default:
+ break;
+ }
+
switch (nargs)
{
case 0: