re PR c++/36128 (ICE with invalid argument for builtin)
authorRichard Guenther <rguenther@suse.de>
Thu, 3 Jul 2008 08:18:09 +0000 (08:18 +0000)
committerRichard Biener <rguenth@gcc.gnu.org>
Thu, 3 Jul 2008 08:18:09 +0000 (08:18 +0000)
2008-07-02  Richard Guenther  <rguenther@suse.de>

PR c++/36128
* typeck.c (cp_build_function_call): Move code to verify
builtin function arguments ...
* call.c (build_cxx_call): ... here.

* g++.dg/other/builtin1.C: New testcase.

From-SVN: r137408

gcc/cp/ChangeLog
gcc/cp/call.c
gcc/cp/typeck.c
gcc/testsuite/ChangeLog
gcc/testsuite/g++.dg/other/builtin1.C [new file with mode: 0644]

index 6475b43fc1b7d24c731e73b7e165200a40e81af1..5ef7e2e10054ce151b5aebbf070244d28b56cbf3 100644 (file)
@@ -1,3 +1,10 @@
+2008-07-03  Richard Guenther  <rguenther@suse.de>
+
+       PR c++/36128
+       * typeck.c (cp_build_function_call): Move code to verify
+       builtin function arguments ...
+       * call.c (build_cxx_call): ... here.
+
 2008-07-02  Jason Merrill  <jason@redhat.com>
 
        * Make-lang.in (cp/typeck2.o): Add $(REAL_H) dependency.
index d41465db638451ff19deee95e619622d4b5c22fc..368d95a677f23729d46697dded6bf7dc3765327d 100644 (file)
@@ -5418,6 +5418,13 @@ build_cxx_call (tree fn, int nargs, tree *argarray)
       && cfun)
     cp_function_chain->can_throw = 1;
 
+  /* Check that arguments to builtin functions match the expectations.  */
+  if (fndecl
+      && DECL_BUILT_IN (fndecl)
+      && DECL_BUILT_IN_CLASS (fndecl) == BUILT_IN_NORMAL
+      && !check_builtin_function_arguments (fndecl, nargs, argarray))
+    return error_mark_node;
+
   /* Some built-in function calls will be evaluated at compile-time in
      fold ().  */
   fn = fold_if_not_in_template (fn);
index 14cbd9d8dd2731484c9241aaec8ff7abc0d0840d..409f34068d4397f2541de3a8f5013e426472f743 100644 (file)
@@ -2887,13 +2887,6 @@ cp_build_function_call (tree function, tree params, tsubst_flags_t complain)
   if (nargs < 0)
     return error_mark_node;
 
-  /* Check that arguments to builtin functions match the expectations.  */
-  if (fndecl
-      && DECL_BUILT_IN (fndecl)
-      && DECL_BUILT_IN_CLASS (fndecl) == BUILT_IN_NORMAL
-      && !check_builtin_function_arguments (fndecl, nargs, argarray))
-    return error_mark_node;
-
   /* Check for errors in format strings and inappropriately
      null parameters.  */
   check_function_arguments (TYPE_ATTRIBUTES (fntype), nargs, argarray,
index 1cfcad45c050a1f94bc3eb6d3e5303a89619c91f..3feefc8985adf0bddf7bed90e683617536f83740 100644 (file)
@@ -1,3 +1,8 @@
+2008-07-03  Richard Guenther  <rguenther@suse.de>
+
+       PR c++/36128
+       * g++.dg/other/builtin1.C: New testcase.
+
 2008-07-02  Joseph Myers  <joseph@codesourcery.com>
 
        * g++.dg/compat/struct-layout-1.exp: Compile generator on build
diff --git a/gcc/testsuite/g++.dg/other/builtin1.C b/gcc/testsuite/g++.dg/other/builtin1.C
new file mode 100644 (file)
index 0000000..8866581
--- /dev/null
@@ -0,0 +1,6 @@
+/* { dg-do compile } */
+
+void foo()
+{
+  __builtin_isless (foo, 0); /* { dg-error "non-floating-point arguments" } */
+}