This is the mail archive of the gcc-patches@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

[PATCH][C++] Fix PR36128, ICE with invalid builtin arguments


This moves the builtin argument checking to the correct place.

Bootstrapped and tested on x86_64-unknown-linux-gnu, ok for trunk?

Thanks,
Richard.

2008-05-08  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.

Index: cp/typeck.c
===================================================================
*** cp/typeck.c	(revision 135078)
--- cp/typeck.c	(working copy)
*************** cp_build_function_call (tree function, t
*** 2889,2901 ****
    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,
--- 2889,2894 ----
Index: cp/call.c
===================================================================
*** cp/call.c	(revision 135078)
--- cp/call.c	(working copy)
*************** build_cxx_call (tree fn, int nargs, tree
*** 5252,5257 ****
--- 5252,5264 ----
        && 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: testsuite/g++.dg/other/builtin1.C
===================================================================
*** testsuite/g++.dg/other/builtin1.C	(revision 0)
--- testsuite/g++.dg/other/builtin1.C	(revision 0)
***************
*** 0 ****
--- 1,6 ----
+ /* { dg-do compile } */
+ 
+ void foo()
+ {
+   __builtin_isless (foo, 0); /* { dg-error "non-floating-point arguments" } */
+ }


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]