[PATCH] cgcc: accept any file type with '-x c'

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Currently cgcc only process file given as stdin or if their
name end with '.c'. Other files are explicitly ignored.

This generally correspond 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 | 8 ++++++++
 1 file changed, 8 insertions(+)

diff --git a/cgcc b/cgcc
index 7611dc9ff..188197369 100755
--- a/cgcc
+++ b/cgcc
@@ -25,6 +25,14 @@ while (@ARGV) {
     # Ditto for stdin.
     $do_check = 1 if $_ eq '-';
 
+    # accept any file type input language is specified with '-x c'
+    if ($_ eq '-x') {
+	my $lang = shift(@ARGV);
+	die ("$0: missing argument for -x") if !$lang;
+	$do_check = 1 if $lang eq 'c';
+	next;
+    }
+
     $m32 = 1 if /^-m32$/;
     $m64 = 1 if /^-m64$/;
     $gendeps = 1 if /^-M$/;
-- 
2.19.0




[Index of Archives]     [Newbies FAQ]     [LKML]     [IETF Annouce]     [DCCP]     [Netdev]     [Networking]     [Security]     [Bugtraq]     [Yosemite]     [MIPS Linux]     [ARM Linux]     [Linux Security]     [Linux RAID]     [Linux SCSI]     [Trinity Fuzzer Tool]

  Powered by Linux