On Tue, Feb 26, 2013 at 11:17:22PM +0000, Joseph S. Myers wrote:
> On Tue, 26 Feb 2013, Marek Polacek wrote:
> 
> > +         /* We don't allow passing huge (> 2^30 B) arguments
> > +            by value.  It would cause an overflow later on.  */
> > +         if (adjusted_args_size.constant >= (1 << 30))
> > +           {
> > +             error ("passing too large argument on stack");
> > +             continue;
> 
> This should be sorry () not error (), as a compiler limitation rather than 
> a defect in the user's program.  (And is input_location set to something 
> useful here so the diagnostic points to the argument in question rather 
> than e.g. to the end of the function containing the problem call?)

Okay, changed back to sorry ().  I'd think that input_location is fine
here, for e.g.

struct S { unsigned char s[1 << 30]; } s;
extern void foo (struct S);

void
bar (void)
{
  foo (s);
}

we get:
pr56344.c: In function ‘bar’:
pr56344.c:7:7: sorry, unimplemented: passing too large argument on stack
   foo (s);
       ^

Ok now?

2013-02-27  Marek Polacek  <pola...@redhat.com>

        PR middle-end/56344
        * calls.c (expand_call): Disallow passing huge arguments
        by value.

--- gcc/calls.c.mp      2013-02-26 17:04:33.159555349 +0100
+++ gcc/calls.c 2013-02-27 10:44:02.254461200 +0100
@@ -3037,6 +3037,14 @@ expand_call (tree exp, rtx target, int i
            {
              rtx before_arg = get_last_insn ();
 
+             /* We don't allow passing huge (> 2^30 B) arguments
+                by value.  It would cause an overflow later on.  */
+             if (adjusted_args_size.constant >= (1 << 30))
+               {
+                 sorry ("passing too large argument on stack");
+                 continue;
+               }
+
              if (store_one_arg (&args[i], argblock, flags,
                                 adjusted_args_size.var != 0,
                                 reg_parm_stack_space)

        Marek

Reply via email to