aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--tools/ccc/ccclib/Driver.py13
-rw-r--r--tools/ccc/test/ccc/ObjC.c7
2 files changed, 20 insertions, 0 deletions
diff --git a/tools/ccc/ccclib/Driver.py b/tools/ccc/ccclib/Driver.py
index 2f4cc14066..30e2ae702d 100644
--- a/tools/ccc/ccclib/Driver.py
+++ b/tools/ccc/ccclib/Driver.py
@@ -376,6 +376,19 @@ class Driver(object):
base,ext = os.path.splitext(inputValue)
if 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
diff --git a/tools/ccc/test/ccc/ObjC.c b/tools/ccc/test/ccc/ObjC.c
new file mode 100644
index 0000000000..e638cbbc4e
--- /dev/null
+++ b/tools/ccc/test/ccc/ObjC.c
@@ -0,0 +1,7 @@
+// RUN: xcc -fsyntax-only %s -ObjC &&
+// RUN: ! xcc -fsyntax-only -x c %s -ObjC &&
+// RUN: xcc -fsyntax-only %s -ObjC++ &&
+// RUN: ! xcc -fsyntax-only -x c %s -ObjC++
+
+@interface A
+@end