c: small refactoring of checking for __attribute__(const))
per Richard's comment.


git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@161786 91177308-0d34-0410-b5e6-96231b3b80d8
diff --git a/lib/Lex/PPMacroExpansion.cpp b/lib/Lex/PPMacroExpansion.cpp
index 7aef2f1..ebdb644 100644
--- a/lib/Lex/PPMacroExpansion.cpp
+++ b/lib/Lex/PPMacroExpansion.cpp
@@ -1054,7 +1054,7 @@
     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 @@
         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 80f53a5..711cf67 100644
--- a/test/Preprocessor/has_attribute.c
+++ b/test/Preprocessor/has_attribute.c
@@ -24,3 +24,13 @@
 #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 6377d40..c27c00e 100644
--- a/test/Sema/inline.c
+++ b/test/Sema/inline.c
@@ -34,9 +34,7 @@
   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 6081ce6..056d09a 100644
--- a/test/Sema/unused-expr.c
+++ b/test/Sema/unused-expr.c
@@ -82,9 +82,7 @@
 
 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