[cfe-commits] r161767 - in /cfe/trunk: lib/Lex/PPMacroExpansion.cpp test/Sema/inline.c test/Sema/unused-expr.c
Fariborz Jahanian
fjahanian at apple.com
Mon Aug 13 11:04:58 PDT 2012
Author: fjahanian
Date: Mon Aug 13 13:04:58 2012
New Revision: 161767
URL: http://llvm.org/viewvc/llvm-project?rev=161767&view=rev
Log:
c: make __has_attribute(const) work for const
function attribute. // rdar://10253857
Modified:
cfe/trunk/lib/Lex/PPMacroExpansion.cpp
cfe/trunk/test/Sema/inline.c
cfe/trunk/test/Sema/unused-expr.c
Modified: cfe/trunk/lib/Lex/PPMacroExpansion.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Lex/PPMacroExpansion.cpp?rev=161767&r1=161766&r2=161767&view=diff
==============================================================================
--- cfe/trunk/lib/Lex/PPMacroExpansion.cpp (original)
+++ cfe/trunk/lib/Lex/PPMacroExpansion.cpp Mon Aug 13 13:04:58 2012
@@ -1062,6 +1062,13 @@
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;
Modified: cfe/trunk/test/Sema/inline.c
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Sema/inline.c?rev=161767&r1=161766&r2=161767&view=diff
==============================================================================
--- cfe/trunk/test/Sema/inline.c (original)
+++ cfe/trunk/test/Sema/inline.c Mon Aug 13 13:04:58 2012
@@ -34,7 +34,9 @@
return useStaticFromStatic(); // no-warning
}
+#if __has_attribute(const)
static int constFunction() __attribute__((const));
+#endif
inline int useConst () {
return constFunction(); // no-warning
Modified: cfe/trunk/test/Sema/unused-expr.c
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Sema/unused-expr.c?rev=161767&r1=161766&r2=161767&view=diff
==============================================================================
--- cfe/trunk/test/Sema/unused-expr.c (original)
+++ cfe/trunk/test/Sema/unused-expr.c Mon Aug 13 13:04:58 2012
@@ -82,7 +82,9 @@
int fn1() __attribute__ ((warn_unused_result));
int fn2() __attribute__ ((pure));
-int fn3() __attribute__ ((const));
+#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
More information about the cfe-commits
mailing list