<div class="gmail_quote">On Mon, Aug 13, 2012 at 11:04 AM, Fariborz Jahanian <span dir="ltr"><<a href="mailto:fjahanian@apple.com" target="_blank">fjahanian@apple.com</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
Author: fjahanian<br>
Date: Mon Aug 13 13:04:58 2012<br>
New Revision: 161767<br>
<br>
URL: <a href="http://llvm.org/viewvc/llvm-project?rev=161767&view=rev" target="_blank">http://llvm.org/viewvc/llvm-project?rev=161767&view=rev</a><br>
Log:<br>
c: make __has_attribute(const) work for const<br>
function attribute. // rdar://10253857<br>
<br>
Modified:<br>
    cfe/trunk/lib/Lex/PPMacroExpansion.cpp<br>
    cfe/trunk/test/Sema/inline.c<br>
    cfe/trunk/test/Sema/unused-expr.c<br>
<br>
Modified: cfe/trunk/lib/Lex/PPMacroExpansion.cpp<br>
URL: <a href="http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Lex/PPMacroExpansion.cpp?rev=161767&r1=161766&r2=161767&view=diff" target="_blank">http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Lex/PPMacroExpansion.cpp?rev=161767&r1=161766&r2=161767&view=diff</a><br>

==============================================================================<br>
--- cfe/trunk/lib/Lex/PPMacroExpansion.cpp (original)<br>
+++ cfe/trunk/lib/Lex/PPMacroExpansion.cpp Mon Aug 13 13:04:58 2012<br>
@@ -1062,6 +1062,13 @@<br>
         if (Tok.is(tok::r_paren))<br>
           IsValid = true;<br>
       }<br>
+      else if (Tok.is(tok::kw_const)) {<br>
+        FeatureII = getIdentifierInfo("const");<br>
+        // Read the ')'.<br>
+        Lex(Tok);<br>
+        if (Tok.is(tok::r_paren))<br>
+          IsValid = true;<br>
+      }<br></blockquote><div><br></div><div><div>Rather than duplicating this, how about...</div><div><br></div><div>-      if (Tok.is(tok::identifier)) {</div><div>+      if (Tok.is(tok::identifier) || Tok.is(tok::kw_const)) {</div>
</div><div> </div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
     }<br>
<br>
     bool Value = false;<br>
<br>
Modified: cfe/trunk/test/Sema/inline.c<br>
URL: <a href="http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Sema/inline.c?rev=161767&r1=161766&r2=161767&view=diff" target="_blank">http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Sema/inline.c?rev=161767&r1=161766&r2=161767&view=diff</a><br>

==============================================================================<br>
--- cfe/trunk/test/Sema/inline.c (original)<br>
+++ cfe/trunk/test/Sema/inline.c Mon Aug 13 13:04:58 2012<br>
@@ -34,7 +34,9 @@<br>
   return useStaticFromStatic(); // no-warning<br>
 }<br>
<br>
+#if __has_attribute(const)<br>
 static int constFunction() __attribute__((const));<br>
+#endif<br>
<br>
 inline int useConst () {<br>
   return constFunction(); // no-warning<br>
<br>
Modified: cfe/trunk/test/Sema/unused-expr.c<br>
URL: <a href="http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Sema/unused-expr.c?rev=161767&r1=161766&r2=161767&view=diff" target="_blank">http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Sema/unused-expr.c?rev=161767&r1=161766&r2=161767&view=diff</a><br>

==============================================================================<br>
--- cfe/trunk/test/Sema/unused-expr.c (original)<br>
+++ cfe/trunk/test/Sema/unused-expr.c Mon Aug 13 13:04:58 2012<br>
@@ -82,7 +82,9 @@<br>
<br>
 int fn1() __attribute__ ((warn_unused_result));<br>
 int fn2() __attribute__ ((pure));<br>
-int fn3() __attribute__ ((const));<br>
+#if __has_attribute(__const)<br>
+int fn3() __attribute__ ((__const));<br>
+#endif<br>
 // rdar://6587766<br>
 int t6() {<br>
   if (fn1() < 0 || fn2(2,1) < 0 || fn3(2) < 0)  // no warnings</blockquote><div><br></div><div>Are these test changes attempting to verify that __has_attribute(const) works and is expanded to 1? If so, these tests should be in test/Preprocessor/has_attribute.c.</div>
</div>