]> granicus.if.org Git - clang/commitdiff
ccc: -ObjC and -ObjC++ change default language, but only for "source
authorDaniel Dunbar <daniel@zuster.org>
Wed, 4 Feb 2009 08:01:01 +0000 (08:01 +0000)
committerDaniel Dunbar <daniel@zuster.org>
Wed, 4 Feb 2009 08:01:01 +0000 (08:01 +0000)
files".

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@63727 91177308-0d34-0410-b5e6-96231b3b80d8

tools/ccc/ccclib/Driver.py
tools/ccc/test/ccc/ObjC.c [new file with mode: 0644]

index 2f4cc14066adc9cb5ba299fdd84f2a87f3224a16..30e2ae702d9d88250a396e92ffefc5986fb6e279 100644 (file)
@@ -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 (file)
index 0000000..e638cbb
--- /dev/null
@@ -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