Issue Details (XML | Word | Printable)

Key: PCC-212
Type: Bug Bug
Status: Closed Closed
Resolution: Fixed
Priority: Major Major
Assignee: Anders Magnusson
Reporter: Piotr Sikora
Votes: 0
Watchers: 1
Operations

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

mishandled -W flags

Created: 13/Jan/11 06:52 AM   Updated: 27/Jul/11 07:28 PM
Component/s: C frontend
Affects Version/s: None
Fix Version/s: None

Environment: pcc 0.9.9 20110112 for x86_64-unknown-linux-gnu, p@ubuntu


 Description  « Hide
Hello,
it seems that pcc is mishandling -W flags.


According to the front-end code (cc/cc/cc.c):
- -WW enables everything defined in Wflags, that is: -Wtruncate, -Werror, -Wshadow, -Wpointer-sign, -Wsign-compare, -Wunknown-pragmas, -Wunreachable-code.
- -Wall enables: -Wpointer-sign, -Wunknown-pragmas,
- everything defined in Wflags can be passed and it will be enabled, everything else is silently discarded.


According to the compiler code (cc/ccom/main.c):
- -WW enables everything defined in flagstr, that is: -Wtruncate, -Wstrict-prototypes, -Wmissing-prototypes, -Wimplicit-int, -Wimplicit-function-declaration, -Wshadow, -Wpointer-sign, -Wsign-compare, -Wunknown-pragmas, -Wunreachable-code.
- -Wimplicit enables: -Wimplicit_int, -Wimplicit_function_declaration,
- -Werror treats warnings as errors,
- everything defined in flagstr can be passed and it will be enabled.


It seems reasonable, but -WW is expanded by pcc to all flags defined in Wflags, including -Werror(!!!), but it (-WW) isn't passed down to ccom, which results in undesired behavior:

p@ubuntu:~$ pcc -v -WW hello.c
(...)
/usr/local/libexec/ccom -Wtruncate -Werror -Wshadow -Wpointer-sign -Wsign-compare -Wunknown-pragmas -Wunreachable-code -v /tmp/ctm.Lvilh2 /tmp/ctm.br501B
ccom: pcc 0.9.9 20110112 for x86_64-unknown-linux-gnu, p@ubuntu
DEBUG: warniserr: 1 <-- pcc expands -WW to -Werror (BAD)
DEBUG: truncate: 1
DEBUG: strict-prototypes: 0
DEBUG: missing-prototypes: 0
DEBUG: implicit-int: 0
DEBUG: implicit-function-declaration: 0
DEBUG: shadow: 1
DEBUG: pointer-sign: 1
DEBUG: sign-compare: 1
DEBUG: unknown-pragmas: 1
DEBUG: unreachable-code: 1


pcc -v -Wc,-WW hello.c
(...)
/usr/local/libexec/ccom -WW -v /tmp/ctm.6Cor1G /tmp/ctm.6FAUmn
ccom: pcc 0.9.9 20110112 for x86_64-unknown-linux-gnu, p@ubuntu
DEBUG: warniserr: 0 <--- ccom doesn't expand -WW to -Werror (GOOD)
DEBUG: truncate: 1
DEBUG: strict-prototypes: 1
DEBUG: missing-prototypes: 1
DEBUG: implicit-int: 1
DEBUG: implicit-function-declaration: 1
DEBUG: shadow: 1
DEBUG: pointer-sign: 1
DEBUG: sign-compare: 1
DEBUG: unknown-pragmas: 1
DEBUG: unreachable-code: 1


pcc -v -Werror -Wc,-WW hello.c
(...)
/usr/local/libexec/ccom -Werror -WW -v /tmp/ctm.INtTht /tmp/ctm.TywgvS
ccom: pcc 0.9.9 20110112 for x86_64-unknown-linux-gnu, p@ubuntu
DEBUG: warniserr: 1
DEBUG: truncate: 1
DEBUG: strict-prototypes: 1
DEBUG: missing-prototypes: 1
DEBUG: implicit-int: 1
DEBUG: implicit-function-declaration: 1
DEBUG: shadow: 1
DEBUG: pointer-sign: 1
DEBUG: sign-compare: 1
DEBUG: unknown-pragmas: 1
DEBUG: unreachable-code: 1



Also, because unknown -W flags are ignored by pcc, -Wxxx is handled differently by pcc and ccom:

p@ubuntu:~$ /usr/local/bin/pcc -Wxxx
no input files
p@ubuntu:~$ /usr/local/libexec/ccom -Wxxx
unrecognised option 'xxx'
usage: /usr/local/libexec/ccom [option] [infile] [outfile]...



To be honest I have no idea if pre-processor, assembler or linker are using -W flags, if not then -WW probably doesn't need to be expanded by pcc and ccom could take care of it (pcc just needs to pass it).

 All   Comments   Change History      Sort Order: Ascending order - Click to sort in descending order
Anders Magnusson made changes - 16/Jan/11 08:16 PM
Field Original Value New Value
Assignee Anders Magnusson [ ragge ]
Iain Hibbert made changes - 27/Jul/11 07:28 PM
Status Open [ 1 ] Resolved [ 5 ]
Resolution Fixed [ 1 ]
Iain Hibbert made changes - 27/Jul/11 07:28 PM
Status Resolved [ 5 ] Closed [ 6 ]