Issue Details (XML | Word | Printable)

Key: PCC-371
Type: New Feature New Feature
Status: Resolved Resolved
Resolution: Fixed
Priority: Trivial Trivial
Assignee: Iain Hibbert
Reporter: TAKAHASHI Tamotsu
Votes: 0
Watchers: 0

If you were logged in you would be able to see more operations.

add -Wno-error=... option

Created: 11/Jul/11 02:09 PM   Updated: 10/Aug/12 09:03 AM
Component/s: C frontend, Common code, pcc backend
Affects Version/s: None
Fix Version/s: None

File Attachments: 1. File werror.diff (4 kB)

 Description  « Hide
gcc has the "-Werror=..." and "-Wno-error=..." specifier.
I think this is really useful because pcc builds itself with -Werror unless -Wtruncate is used.
So it may be reasonable to implement and use "-Werror -Wno-error=truncate".
(The attached diff is just a PoC. The current pcc can't build it because of -Werror
without -Wno-error=truncate. Also, I'm not a so experienced programmer.)

 All   Comments   Change History      Sort Order: Ascending order - Click to sort in descending order
Iain Hibbert added a comment - 14/Nov/11 01:07 PM
I added "error=" handling to cc and ccom, not quite as you had it as cleaned up some associated Wflag
code at the same time

cannot add "-Werror -Wno-error=truncate" to the configure script at this time though, because we still have some
-Wtruncate warnings and as you note previous pcc cannot handle -Wno-error=truncate. These warnings could be fixed,
though the problem is that they can appear bogus and I experienced some such warnings in system header files

for instance,

   int i;
   char c = i & 0x0f;

will trigger such a warning, though clearly this construct is valid and no unintended truncation is going to happen

Gregory McGarry added a comment - 14/Nov/11 11:01 PM
Feel free to remove -Wtruncate from the build. I added it since I really like this feature of the Microsoft compiler. It doesn't have an equivalent in gcc.

Iain Hibbert added a comment - 15/Nov/11 11:29 AM
I am in two minds about it, since -Wtruncate is potentially useful (does the above example
trigger the Microsoft compiler btw?)

I had a thought about this, to change the DESIRED_FLAGS to an ordered list, ending with

   ... -Werror -Wno-error=truncate -Wtruncate"

and when the first non-supported flag is found, to break from the loop.. this means that
-Wtruncate is only added when -Wno-error=truncate is permitted.

patch below, does that look good?

RCS file: /cvsroot/pcc/,v
retrieving revision 1.107
diff -u -p -r1.107
--- 1 Nov 2011 18:33:44 -0000 1.107
+++ 15 Nov 2011 10:19:44 -0000
@@ -387,20 +387,21 @@ AC_DEFINE_UNQUOTED(WCHAR_SIZE, $wchar_si
 # check for additional compiler flags
-DESIRED_FLAGS="-Wall -Wmissing-prototypes -Wstrict-prototypes -Wshadow -Wsign-compare -Wtruncate"
+AC_LANG_CONFTEST([int main() { return 0; }])
+DESIRED_FLAGS="-Werror -Wall -Wmissing-prototypes -Wstrict-prototypes -Wshadow -Wsign-compare -Wno-error=truncate -Wtruncate"
 for flag in $DESIRED_FLAGS
  AC_MSG_CHECKING([whether $CC accepts $flag])
- AC_LANG_CONFTEST([int main() { return 0; }])
  $CC $CFLAGS $flag -c conftest.c > /dev/null 2> /dev/null
  if test $? = 0 ; then
+ break # bail out at first failure
- rm -f conftest.o
+rm -f conftest.o
 # setup for cross-compiling mkext
 AC_MSG_CHECKING([for a C compiler for mkext])

Anders Magnusson added a comment - 31/Jul/12 08:44 AM
Please go ahead with this. I think -Wtruncate is a very useful flag and should be used whenever possible.

Iain Hibbert added a comment - 10/Aug/12 09:03 AM
have added -Werror to the default flags now