[cfe-commits] r69770 - in /cfe/trunk: lib/Frontend/InitPreprocessor.cpp test/Misc/predefines.c test/Sema/block-literal.c

Chris Lattner sabre at nondot.org
Tue Apr 21 20:42:35 PDT 2009


Author: lattner
Date: Tue Apr 21 22:42:19 2009
New Revision: 69770

URL: http://llvm.org/viewvc/llvm-project?rev=69770&view=rev
Log:
Fix rdar://6814950 - stdint.h isn't "-pedantic -std=c89" clean,
by marking the predefines buffer as a system header.  The problem 
with stdint is that it was getting problems like this:

/Volumes/Projects/cvs/llvm/Debug/lib/clang/1.0/include/stdint.h:43:9: warning: 'long long' is an extension when C99 mode is not enabled
typedef __INT64_TYPE__ int64_t;
        ^
<built-in>:73:29: note: instantiated from:
#define __INT64_TYPE__ long long
                            ^

We correctly silence warnings in system headers, but only if the 
spelling location of the token came from the system header.  This is
designed so that if you use a system macro in your code that you don't
get punished for its definition.  This is all cool except that the 
predefines buffer wasn't considered a system header.


Added:
    cfe/trunk/test/Misc/predefines.c
Modified:
    cfe/trunk/lib/Frontend/InitPreprocessor.cpp
    cfe/trunk/test/Sema/block-literal.c

Modified: cfe/trunk/lib/Frontend/InitPreprocessor.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Frontend/InitPreprocessor.cpp?rev=69770&r1=69769&r2=69770&view=diff

==============================================================================
--- cfe/trunk/lib/Frontend/InitPreprocessor.cpp (original)
+++ cfe/trunk/lib/Frontend/InitPreprocessor.cpp Tue Apr 21 22:42:19 2009
@@ -417,13 +417,17 @@
                             const PreprocessorInitOptions& InitOpts) {
   std::vector<char> PredefineBuffer;
   
+  const char *LineDirective = "# 1 \"<built-in>\" 3\n";
+  PredefineBuffer.insert(PredefineBuffer.end(),
+                         LineDirective, LineDirective+strlen(LineDirective));
+  
   // Install things like __POWERPC__, __GNUC__, etc into the macro table.
   InitializePredefinedMacros(PP.getTargetInfo(), PP.getLangOptions(),
                              PredefineBuffer);
   
   // Add on the predefines from the driver.  Wrap in a #line directive to report
   // that they come from the command line.
-  const char *LineDirective = "# 1 \"<command line>\" 1\n";
+  LineDirective = "# 1 \"<command line>\" 1\n";
   PredefineBuffer.insert(PredefineBuffer.end(),
                          LineDirective, LineDirective+strlen(LineDirective));
 
@@ -451,7 +455,7 @@
       AddImplicitInclude(PredefineBuffer, I->first);
  }
 
-  LineDirective = "# 2 \"<built-in>\" 2\n";
+  LineDirective = "# 2 \"<built-in>\" 2 3\n";
   PredefineBuffer.insert(PredefineBuffer.end(),
                          LineDirective, LineDirective+strlen(LineDirective));
 

Added: cfe/trunk/test/Misc/predefines.c
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Misc/predefines.c?rev=69770&view=auto

==============================================================================
--- cfe/trunk/test/Misc/predefines.c (added)
+++ cfe/trunk/test/Misc/predefines.c Tue Apr 21 22:42:19 2009
@@ -0,0 +1,5 @@
+/* RUN: clang-cc -fsyntax-only -verify -std=c89 -pedantic-errors %s
+ * rdar://6814950
+ */
+#include <stdint.h>
+

Modified: cfe/trunk/test/Sema/block-literal.c
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Sema/block-literal.c?rev=69770&r1=69769&r2=69770&view=diff

==============================================================================
--- cfe/trunk/test/Sema/block-literal.c (original)
+++ cfe/trunk/test/Sema/block-literal.c Tue Apr 21 22:42:19 2009
@@ -40,7 +40,7 @@
 
 foo:
 	takeclosure(^{ x = 4; });  // expected-error {{variable is not assignable (missing __block type specifier)}}
-  __block y = 7; // expected-warning {{type specifier missing, defaults to 'int'}}
+  __block y = 7; 
   takeclosure(^{ y = 8; });
 }
 





More information about the cfe-commits mailing list