aboutsummaryrefslogtreecommitdiff
path: root/lib/Lex/Preprocessor.cpp
diff options
context:
space:
mode:
authorSteve Naroff <snaroff@apple.com>2008-09-02 18:50:17 +0000
committerSteve Naroff <snaroff@apple.com>2008-09-02 18:50:17 +0000
commitb4eaf9cf5f79c86a3f7564f4dfdea57f165ca45c (patch)
treedb97abd97f3fb8540bdf90f6f0bface7ce4c1302 /lib/Lex/Preprocessor.cpp
parentc9a4eea59228bd06072927059979a1c9ccab45b5 (diff)
- Implement __block.
- Replace FIXME in Preprocessor::HandleIdentifier() with a check that avoids diagnosing extension tokens that originate from macro definitions. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@55639 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/Lex/Preprocessor.cpp')
-rw-r--r--lib/Lex/Preprocessor.cpp13
1 files changed, 10 insertions, 3 deletions
diff --git a/lib/Lex/Preprocessor.cpp b/lib/Lex/Preprocessor.cpp
index 18b106ad84..50fafdc73b 100644
--- a/lib/Lex/Preprocessor.cpp
+++ b/lib/Lex/Preprocessor.cpp
@@ -476,6 +476,14 @@ static void InitializePredefinedMacros(Preprocessor &PP,
DefineBuiltinMacro(Buf, "__int64=long long");
DefineBuiltinMacro(Buf, "__declspec(X)=");
}
+ // Directly modeled after the attribute-based implementation in GCC.
+ if (PP.getLangOptions().Blocks)
+ DefineBuiltinMacro(Buf, "__block=__attribute__((__blocks__(byref)))");
+ else
+ // This allows "__block int unusedVar;" even when blocks are disabled.
+ // This is modeled after GCC's handling of __strong/__weak.
+ DefineBuiltinMacro(Buf, "__block=");
+
// FIXME: Should emit a #line directive here.
}
@@ -594,8 +602,7 @@ void Preprocessor::HandleIdentifier(Token &Identifier) {
Identifier.setKind(II.getTokenID());
// If this is an extension token, diagnose its use.
- // FIXME: tried (unsuccesfully) to shut this up when compiling with gnu99
- // For now, I'm just commenting it out (while I work on attributes).
- if (II.isExtensionToken() && Features.C99)
+ // We avoid diagnosing tokens that originate from macro definitions.
+ if (II.isExtensionToken() && Features.C99 && !DisableMacroExpansion)
Diag(Identifier, diag::ext_token_used);
}