aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--lib/Lex/PPMacroExpansion.cpp9
-rw-r--r--test/Preprocessor/has_attribute.c10
-rw-r--r--test/Sema/inline.c2
-rw-r--r--test/Sema/unused-expr.c2
4 files changed, 11 insertions, 12 deletions
diff --git a/lib/Lex/PPMacroExpansion.cpp b/lib/Lex/PPMacroExpansion.cpp
index 7aef2f1a0e..ebdb6446d1 100644
--- a/lib/Lex/PPMacroExpansion.cpp
+++ b/lib/Lex/PPMacroExpansion.cpp
@@ -1054,7 +1054,7 @@ void Preprocessor::ExpandBuiltinMacro(Token &Tok) {
if (Tok.is(tok::l_paren)) {
// Read the identifier
Lex(Tok);
- if (Tok.is(tok::identifier)) {
+ if (Tok.is(tok::identifier) || Tok.is(tok::kw_const)) {
FeatureII = Tok.getIdentifierInfo();
// Read the ')'.
@@ -1062,13 +1062,6 @@ void Preprocessor::ExpandBuiltinMacro(Token &Tok) {
if (Tok.is(tok::r_paren))
IsValid = true;
}
- else if (Tok.is(tok::kw_const)) {
- FeatureII = getIdentifierInfo("const");
- // Read the ')'.
- Lex(Tok);
- if (Tok.is(tok::r_paren))
- IsValid = true;
- }
}
bool Value = false;
diff --git a/test/Preprocessor/has_attribute.c b/test/Preprocessor/has_attribute.c
index 80f53a52fe..711cf671cf 100644
--- a/test/Preprocessor/has_attribute.c
+++ b/test/Preprocessor/has_attribute.c
@@ -24,3 +24,13 @@ int has_has_attribute();
#if !__has_attribute(something_we_dont_have)
int has_something_we_dont_have();
#endif
+
+// rdar://10253857
+#if __has_attribute(__const)
+ int fn3() __attribute__ ((__const));
+#endif
+
+#if __has_attribute(const)
+ static int constFunction() __attribute__((const));
+#endif
+
diff --git a/test/Sema/inline.c b/test/Sema/inline.c
index 6377d40b8f..c27c00efaa 100644
--- a/test/Sema/inline.c
+++ b/test/Sema/inline.c
@@ -34,9 +34,7 @@ extern inline int useStaticInlineFromExtern () {
return useStaticFromStatic(); // no-warning
}
-#if __has_attribute(const)
static int constFunction() __attribute__((const));
-#endif
inline int useConst () {
return constFunction(); // no-warning
diff --git a/test/Sema/unused-expr.c b/test/Sema/unused-expr.c
index 6081ce651f..056d09a871 100644
--- a/test/Sema/unused-expr.c
+++ b/test/Sema/unused-expr.c
@@ -82,9 +82,7 @@ void t5() {
int fn1() __attribute__ ((warn_unused_result));
int fn2() __attribute__ ((pure));
-#if __has_attribute(__const)
int fn3() __attribute__ ((__const));
-#endif
// rdar://6587766
int t6() {
if (fn1() < 0 || fn2(2,1) < 0 || fn3(2) < 0) // no warnings