Bug 51115 - "-Wstrict-prototypes" is rejected for C++ (ok) but accepted for Ada (meaningless)
Summary: "-Wstrict-prototypes" is rejected for C++ (ok) but accepted for Ada (meaningl...
Status: RESOLVED FIXED
Alias: None
Product: gcc
Classification: Unclassified
Component: ada (show other bugs)
Version: 4.5.2
: P3 trivial
Target Milestone: 4.8.0
Assignee: Not yet assigned to anyone
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2011-11-13 01:20 UTC by Keith Thompson
Modified: 2015-12-06 14:38 UTC (History)
2 users (show)

See Also:
Host:
Target:
Build:
Known to work:
Known to fail:
Last reconfirmed:


Attachments
Demo script (277 bytes, application/octet-stream)
2011-11-13 01:20 UTC, Keith Thompson
Details

Note You need to log in before you can comment on or make changes to this bug.
Description Keith Thompson 2011-11-13 01:20:04 UTC
Created attachment 25811 [details]
Demo script

When the "-Wstrict-prototypes" option is used when compiling C++, the following warning appears:

cc1plus: warning: command line option "-Wstrict-prototypes" is valid for Ada/C/ObjC but not for C++

The warning option doesn't make sense for C++, since the language doesn't permit old-style non-prototype function declarations, but it makes even less sense for Ada.  Further experiment shows that the option is quietly accepted when compiling Ada.

Suggested solution:

1. Make the Ada front end complain about "-Wstrict-prototypes" (unless there's a general policy of having it quietly accept options that don't make sense).

2. Drop "Ada/" from the cc1plus warning message.

The attached sh script demonstrates the problem.  The output on my system is:


% gcc --version
gcc (Ubuntu/Linaro 4.5.2-8ubuntu4) 4.5.2
Copyright (C) 2010 Free Software Foundation, Inc.
This is free software; see the source for copying conditions.  There is NO
warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.

% gnatmake --version
GNATMAKE 4.4.5
Copyright (C) 1995-2008, Free Software Foundation, Inc.
This is free software; see the source for copying conditions.
There is NO warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.

% uname -a
Linux kvetch 2.6.38-12-generic #51-Ubuntu SMP Wed Sep 28 14:25:20 UTC 2011 i686 i686 i386 GNU/Linux

=== C ===
% gcc -c -Wstrict-prototypes foo.c

=== C++ ===
% g++ -c -Wstrict-prototypes foo.cpp
cc1plus: warning: command line option "-Wstrict-prototypes" is valid for Ada/C/ObjC but not for C++
% gcc -c -Wstrict-prototypes foo.cpp
cc1plus: warning: command line option "-Wstrict-prototypes" is valid for Ada/C/ObjC but not for C++

=== Objective-C
% gcc -c -Wstrict-prototypes foo.m

=== Ada ===
% gnatmake foo.adb -cargs -Wstrict-prototypes
gcc-4.4 -c -Wstrict-prototypes foo.adb
gnatbind -x foo.ali
gnatlink foo.ali
Comment 1 Eric Botcazou 2015-12-06 14:38:07 UTC
gnat1: warning: command line option ‘-Wstrict-prototypes’ is valid for C/ObjC but not for Ada [enabled by default]