From: Chris Lattner Date: Wed, 22 Apr 2009 03:42:19 +0000 (+0000) Subject: Fix rdar://6814950 - stdint.h isn't "-pedantic -std=c89" clean, X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=3936024941229e235aed7f53949a117a54eebf68;p=clang 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; ^ :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. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@69770 91177308-0d34-0410-b5e6-96231b3b80d8 --- diff --git a/lib/Frontend/InitPreprocessor.cpp b/lib/Frontend/InitPreprocessor.cpp index 9cc83ef219..746eba9cf2 100644 --- a/lib/Frontend/InitPreprocessor.cpp +++ b/lib/Frontend/InitPreprocessor.cpp @@ -417,13 +417,17 @@ bool InitializePreprocessor(Preprocessor &PP, const PreprocessorInitOptions& InitOpts) { std::vector PredefineBuffer; + const char *LineDirective = "# 1 \"\" 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 \"\" 1\n"; + LineDirective = "# 1 \"\" 1\n"; PredefineBuffer.insert(PredefineBuffer.end(), LineDirective, LineDirective+strlen(LineDirective)); @@ -451,7 +455,7 @@ bool InitializePreprocessor(Preprocessor &PP, AddImplicitInclude(PredefineBuffer, I->first); } - LineDirective = "# 2 \"\" 2\n"; + LineDirective = "# 2 \"\" 2 3\n"; PredefineBuffer.insert(PredefineBuffer.end(), LineDirective, LineDirective+strlen(LineDirective)); diff --git a/test/Misc/predefines.c b/test/Misc/predefines.c new file mode 100644 index 0000000000..c7fac86331 --- /dev/null +++ b/test/Misc/predefines.c @@ -0,0 +1,5 @@ +/* RUN: clang-cc -fsyntax-only -verify -std=c89 -pedantic-errors %s + * rdar://6814950 + */ +#include + diff --git a/test/Sema/block-literal.c b/test/Sema/block-literal.c index 2c1700a7b7..c6e3931aa8 100644 --- a/test/Sema/block-literal.c +++ b/test/Sema/block-literal.c @@ -40,7 +40,7 @@ void test2() { 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; }); }