Currently cgcc only processes file given as stdin or if their name end with '.c'. Other files are explicitly ignored. This generally corresponds to what is wanted but GCC also accept files with any extension if their type is given via the option '-x <language>'. Some projects use this mechanism, for example to use the C pre-processor on some files containing no code. This fails when cgcc is used as wrapper around sparse + GCC. Fix this by teaching sparse about the '-x c' option. Reported-by: Antonio Ospite <ao2@xxxxxx> Signed-off-by: Luc Van Oostenryck <luc.vanoostenryck@xxxxxxxxx> --- cgcc | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/cgcc b/cgcc index 7611dc9ff..c62645e5e 100755 --- a/cgcc +++ b/cgcc @@ -25,6 +25,15 @@ while (@ARGV) { # Ditto for stdin. $do_check = 1 if $_ eq '-'; + # accept any file type when '-x c' is given as option. + if ($_ eq '-x') { + my $lang = shift(@ARGV); + die ("$0: missing argument for -x") if !$lang; + die ("$0: invalid argument for -x") if $lang ne 'c'; + $do_check = 1; + next; + } + $m32 = 1 if /^-m32$/; $m64 = 1 if /^-m64$/; $gendeps = 1 if /^-M$/; @@ -52,6 +61,12 @@ while (@ARGV) { next; } + if (/^-o$/) { + $_ = shift @ARGV; + die ("$0: missing argument for -o") if !$_; + next; + } + # If someone adds "-E", don't pre-process twice. $do_compile = 0 if $_ eq '-E'; -- 2.19.0