diff mbox

Fix PR 67665: ICE when passing two empty files directly to cc1 with -g

Message ID CA+=Sn1=ZY=_GLPusvj=BSZMwQ3-367d1s2eKCoy86BPQpkpsWg@mail.gmail.com
State New
Headers show

Commit Message

Andrew Pinski Jan. 13, 2016, 8:27 a.m. UTC
Hi,
  The support -combine was removed a while back but cc1 still accepts
more than one file if directly invoked.  The support for multiple
files has bit-rotten inside the C front-end now too.  This patch now
errors out when invoked with more than one file instead of crashing
later.

OK?  Bootstrapped and tested on aarch64-linux-gnu with no regressions.

Thanks,
Andrew Pinski

c-family/ChangeLog:
* c-opts.c (c_common_post_options): Move the error message about "two
or more source files" such that it is unconditional.

Comments

Richard Biener Jan. 13, 2016, 12:36 p.m. UTC | #1
On Wed, Jan 13, 2016 at 9:27 AM, Andrew Pinski <pinskia@gmail.com> wrote:
> Hi,
>   The support -combine was removed a while back but cc1 still accepts
> more than one file if directly invoked.  The support for multiple
> files has bit-rotten inside the C front-end now too.  This patch now
> errors out when invoked with more than one file instead of crashing
> later.
>
> OK?  Bootstrapped and tested on aarch64-linux-gnu with no regressions.

Ok, but can you please simplify the following code then?  The

  i = 0;
  for (;;)
    {
...
      if (++i >= num_in_fnames)
        break;

and the code following the break should be no longer needed, no?

Thanks,
Richard.

> Thanks,
> Andrew Pinski
>
> c-family/ChangeLog:
> * c-opts.c (c_common_post_options): Move the error message about "two
> or more source files" such that it is unconditional.
Andrew Pinski Jan. 22, 2016, 1:17 a.m. UTC | #2
On Wed, Jan 13, 2016 at 4:36 AM, Richard Biener
<richard.guenther@gmail.com> wrote:
> On Wed, Jan 13, 2016 at 9:27 AM, Andrew Pinski <pinskia@gmail.com> wrote:
>> Hi,
>>   The support -combine was removed a while back but cc1 still accepts
>> more than one file if directly invoked.  The support for multiple
>> files has bit-rotten inside the C front-end now too.  This patch now
>> errors out when invoked with more than one file instead of crashing
>> later.
>>
>> OK?  Bootstrapped and tested on aarch64-linux-gnu with no regressions.
>
> Ok, but can you please simplify the following code then?  The
>
>   i = 0;
>   for (;;)
>     {
> ...
>       if (++i >= num_in_fnames)
>         break;
>
> and the code following the break should be no longer needed, no?

Yes.  Let me resubmit the patch.  Also will this still be accepted
even though we are in stage 4?

Thanks,
Andrew Pinski

>
> Thanks,
> Richard.
>
>> Thanks,
>> Andrew Pinski
>>
>> c-family/ChangeLog:
>> * c-opts.c (c_common_post_options): Move the error message about "two
>> or more source files" such that it is unconditional.
Richard Biener Jan. 22, 2016, 11:04 a.m. UTC | #3
On Fri, Jan 22, 2016 at 2:17 AM, Andrew Pinski <pinskia@gmail.com> wrote:
> On Wed, Jan 13, 2016 at 4:36 AM, Richard Biener
> <richard.guenther@gmail.com> wrote:
>> On Wed, Jan 13, 2016 at 9:27 AM, Andrew Pinski <pinskia@gmail.com> wrote:
>>> Hi,
>>>   The support -combine was removed a while back but cc1 still accepts
>>> more than one file if directly invoked.  The support for multiple
>>> files has bit-rotten inside the C front-end now too.  This patch now
>>> errors out when invoked with more than one file instead of crashing
>>> later.
>>>
>>> OK?  Bootstrapped and tested on aarch64-linux-gnu with no regressions.
>>
>> Ok, but can you please simplify the following code then?  The
>>
>>   i = 0;
>>   for (;;)
>>     {
>> ...
>>       if (++i >= num_in_fnames)
>>         break;
>>
>> and the code following the break should be no longer needed, no?
>
> Yes.  Let me resubmit the patch.  Also will this still be accepted
> even though we are in stage 4?

I suppose it's a regression, so yes.

Richard.

> Thanks,
> Andrew Pinski
>
>>
>> Thanks,
>> Richard.
>>
>>> Thanks,
>>> Andrew Pinski
>>>
>>> c-family/ChangeLog:
>>> * c-opts.c (c_common_post_options): Move the error message about "two
>>> or more source files" such that it is unconditional.
diff mbox

Patch

Index: c-family/c-opts.c
===================================================================
--- c-family/c-opts.c	(revision 232313)
+++ c-family/c-opts.c	(working copy)
@@ -928,6 +928,10 @@  c_common_post_options (const char **pfil
 #endif
     }
 
+  if (num_in_fnames > 1)
+    error ("too many filenames given.  Type %s --help for usage",
+	   progname);
+
   if (flag_preprocess_only)
     {
       /* Open the output now.  We must do so even if flag_no_output is
@@ -944,10 +948,6 @@  c_common_post_options (const char **pfil
 	  return false;
 	}
 
-      if (num_in_fnames > 1)
-	error ("too many filenames given.  Type %s --help for usage",
-	       progname);
-
       init_pp_output (out_stream);
     }
   else