diff options
author | Daniel Dunbar <daniel@zuster.org> | 2009-02-05 23:44:44 +0000 |
---|---|---|
committer | Daniel Dunbar <daniel@zuster.org> | 2009-02-05 23:44:44 +0000 |
commit | bbd34e665815ce71aad2bc6b884c47695f44c860 (patch) | |
tree | 2c9320f657447d1fc03dc19b1bc326d59b1ad89a /tools/ccc | |
parent | fab9d67cebb87be968e7ae31a3b549a5279b5d51 (diff) |
ccc: Implement special language recognition handling for -.
- <rdar://problem/6551577> [ccc] require -x with -
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@63901 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'tools/ccc')
-rw-r--r-- | tools/ccc/ccclib/Driver.py | 36 | ||||
-rw-r--r-- | tools/ccc/test/ccc/stdin.c | 10 |
2 files changed, 32 insertions, 14 deletions
diff --git a/tools/ccc/ccclib/Driver.py b/tools/ccc/ccclib/Driver.py index 30e2ae702d..9387c37e18 100644 --- a/tools/ccc/ccclib/Driver.py +++ b/tools/ccc/ccclib/Driver.py @@ -374,27 +374,35 @@ class Driver(object): inputValue = args.getValue(a) if inputType is None: base,ext = os.path.splitext(inputValue) - if ext and ext in Types.kTypeSuffixMap: + # stdin is handled specially. + if inputValue == '-': + if args.getLastArg(self.parser.EOption): + # Treat as a C input needing preprocessing + # (or Obj-C if over-ridden below). + klass = Types.CType + else: + raise Arguments.InvalidArgumentsError("-E or -x required when input is from standard input") + elif ext and ext in Types.kTypeSuffixMap: klass = Types.kTypeSuffixMap[ext] - - # -ObjC and -ObjC++ over-ride the default - # language, but only for "source files". We - # just treat everything that isn't a linker - # input as a source file. - # - # FIXME: Clean this up if we move the phase - # sequence into the type. - if klass is not Types.ObjectType: - if args.getLastArg(self.parser.ObjCOption): - klass = Types.ObjCType - elif args.getLastArg(self.parser.ObjCXXOption): - klass = Types.ObjCType else: # FIXME: Its not clear why we shouldn't just # revert to unknown. I think this is more likely a # bug / unintended behavior in gcc. Not very # important though. klass = Types.ObjectType + + # -ObjC and -ObjC++ over-ride the default + # language, but only for "source files". We + # just treat everything that isn't a linker + # input as a source file. + # + # FIXME: Clean this up if we move the phase + # sequence into the type. + if klass is not Types.ObjectType: + if args.getLastArg(self.parser.ObjCOption): + klass = Types.ObjCType + elif args.getLastArg(self.parser.ObjCXXOption): + klass = Types.ObjCType else: assert inputTypeOpt is not None self.claim(inputTypeOpt) diff --git a/tools/ccc/test/ccc/stdin.c b/tools/ccc/test/ccc/stdin.c new file mode 100644 index 0000000000..a8df15cab4 --- /dev/null +++ b/tools/ccc/test/ccc/stdin.c @@ -0,0 +1,10 @@ +// RUN: not xcc -### - &> %t && +// RUN: grep 'E or -x required when input is from standard input' %t && +// RUN: xcc -ccc-print-phases -### -E - &> %t && +// RUN: grep '1: preprocessor.*, {0}, cpp-output' %t && +// RUN: xcc -ccc-print-phases -### -ObjC -E - &> %t && +// RUN: grep '1: preprocessor.*, {0}, objective-c-cpp-output' %t && +// RUN: xcc -ccc-print-phases -### -ObjC -x c -E - &> %t && +// RUN: grep '1: preprocessor.*, {0}, cpp-output' %t && + +// RUN: true |