On Mon, Aug 13, 2012 at 11:04 AM, Fariborz Jahanian <[email protected]>wrote:
> 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; > + } > Rather than duplicating this, how about... - if (Tok.is(tok::identifier)) { + if (Tok.is(tok::identifier) || Tok.is(tok::kw_const)) { > } > > 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 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.
_______________________________________________ cfe-commits mailing list [email protected] http://lists.cs.uiuc.edu/mailman/listinfo/cfe-commits
