On Tue, Jan 26, 2016 at 02:56:24PM +0100, Jakub Jelinek wrote:
> Another alternative would be to make sure tree folders don't introduce
> error_mark_node (if it wasn't there already), but instead fold the call say
> to build_int_cst (returntype, 0).  The known cases that would need to change
> are at least darwin_build_constant_cfstring and darwin_fold_builtin, but
> maybe others.

Here is the alternative (but it is unclear if other targets don't have
similar issues in their folders).

I have no access to Darwin, so all I've done was test it on the preprocessed
source from the PR.

2016-01-26  Jakub Jelinek  <ja...@redhat.com>

        PR c++/68357
        * config/darwin.c (darwin_fold_builtin): For errorneous use
        of the __builtin___CFStringMakeConstantString builtin return
        constant 0 in the right type rather than error_mark_node.

--- gcc/config/darwin.c.jj      2016-01-04 14:55:54.000000000 +0100
+++ gcc/config/darwin.c 2016-01-26 17:28:12.489018588 +0100
@@ -3345,19 +3345,17 @@ darwin_fold_builtin (tree fndecl, int n_
   if (fcode == darwin_builtin_cfstring)
     {
       if (!darwin_constant_cfstrings)
+       error ("built-in function %qD requires the" 
+              " %<-mconstant-cfstrings%> flag", fndecl);
+      else if (n_args != 1)
+       error ("built-in function %qD takes one argument only", fndecl);
+      else
        {
-         error ("built-in function %qD requires the" 
-                " %<-mconstant-cfstrings%> flag", fndecl);
-         return error_mark_node;
+         tree ret = darwin_build_constant_cfstring (*argp);
+         if (ret != error_mark_node)
+           return ret;
        }
-
-      if (n_args != 1)
-       {
-         error ("built-in function %qD takes one argument only", fndecl);
-         return error_mark_node;
-       }
-
-      return darwin_build_constant_cfstring (*argp);
+      return build_int_cst (TREE_TYPE (TREE_TYPE (fndecl)), 0);
     }
 
   return NULL_TREE;


        Jakub

Reply via email to