Bug 98591 - [11 Regression] -x c++-header -fsyntax-only fails: cc1plus: error: output filename specified twice since r11-5615-g10ee6da64c574947
Summary: [11 Regression] -x c++-header -fsyntax-only fails: cc1plus: error: output fil...
Status: RESOLVED FIXED
Alias: None
Product: gcc
Classification: Unclassified
Component: driver (show other bugs)
Version: 11.0
: P1 normal
Target Milestone: 11.0
Assignee: Nathan Sidwell
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2021-01-07 22:35 UTC by Sergei Trofimovich
Modified: 2021-01-15 16:57 UTC (History)
2 users (show)

See Also:
Host:
Target:
Build:
Known to work: 10.2.0
Known to fail: 11.0
Last reconfirmed: 2021-01-08 00:00:00


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Sergei Trofimovich 2021-01-07 22:35:32 UTC
The bug is originally observed by andy on keyutils-1.6.3 at https://bugs.gentoo.org/764371. There build system checks own headers for valid syntax.

The minimal reproducer is (original uses real .h header file, possibly to make sure C header is parsed correctly as valid C++):

```shell
$ g++-10.2.0 -x c++-header -fsyntax-only /dev/null
<ok>
$ g++-11.0.0 -x c++-header -fsyntax-only /dev/null
cc1plus: error: output filename specified twice
```
Comment 1 Martin Liška 2021-01-08 08:24:41 UTC
Thanks for the report.
Started with Nathan's r11-5615-g10ee6da64c574947.
Comment 2 GCC Commits 2021-01-15 16:56:28 UTC
The master branch has been updated by Nathan Sidwell <nathan@gcc.gnu.org>:

https://gcc.gnu.org/g:492b90f33dfb37576dc7ae424d67b2be8b959bf2

commit r11-6724-g492b90f33dfb37576dc7ae424d67b2be8b959bf2
Author: Nathan Sidwell <nathan@acm.org>
Date:   Fri Jan 15 08:48:54 2021 -0800

    c++: Fix langspecs with -fsyntax-only [PR98591]
    
    -fsyntax-only is handled specially in the driver and causes it to add
     '-o /dev/null' (or a suitable OS-specific variant thereof).  PCH is
     handled in the language driver.  I'd not sufficiently protected the
     -fmodule-only action of adding a dummy assembler from the actions of
     -fsyntax-only, so we ended up with two -o options.
    
            PR c++/98591
            gcc/cp/
            * lang-specs.h: Fix handling of -fmodule-only with -fsyntax-only.
Comment 3 Nathan Sidwell 2021-01-15 16:57:35 UTC
492b90f33df 2021-01-15 | c++: Fix langspecs with -fsyntax-only [PR98591]