]> granicus.if.org Git - clang/commitdiff
__CONSTANT_CFSTRINGS__ should be defined even in C mode, otherwise the CFSTR
authorChris Lattner <sabre@nondot.org>
Mon, 6 Oct 2008 07:43:09 +0000 (07:43 +0000)
committerChris Lattner <sabre@nondot.org>
Mon, 6 Oct 2008 07:43:09 +0000 (07:43 +0000)
won't expand to the builtin.  This fixes rdar://6248329

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

lib/Lex/Preprocessor.cpp
test/CodeGen/cfstring2.c [new file with mode: 0644]

index 6c5daae13bff29bc7d5271001f6788ebeb5010e0..ed69e6f93360d886e3c13c969c0d5421b6ce5379 100644 (file)
@@ -488,12 +488,12 @@ static void InitializePredefinedMacros(Preprocessor &PP,
 
     if (PP.getLangOptions().NeXTRuntime)
       DefineBuiltinMacro(Buf, "__NEXT_RUNTIME__=1");
-
-    // darwin_constant_cfstrings controls this. This is also dependent
-    // on other things like the runtime I believe.
-    DefineBuiltinMacro(Buf, "__CONSTANT_CFSTRINGS__=1");
   }
   
+  // darwin_constant_cfstrings controls this. This is also dependent
+  // on other things like the runtime I believe.  This is set even for C code.
+  DefineBuiltinMacro(Buf, "__CONSTANT_CFSTRINGS__=1");
+  
   if (PP.getLangOptions().ObjC2)
     DefineBuiltinMacro(Buf, "OBJC_NEW_PROPERTIES");
 
diff --git a/test/CodeGen/cfstring2.c b/test/CodeGen/cfstring2.c
new file mode 100644 (file)
index 0000000..605b9d5
--- /dev/null
@@ -0,0 +1,13 @@
+// RUN: clang -emit-llvm %s -o %t
+
+#ifdef __APPLE__
+#include <Carbon/Carbon.h>
+
+void f() {
+  CFSTR("Hello, World!");
+}
+
+// rdar://6248329
+void *G = CFSTR("yo joe");
+
+#endif