[cfe-commits] r161767 - in /cfe/trunk: lib/Lex/PPMacroExpansion.cpp test/Sema/inline.c test/Sema/unused-expr.c
Richard Smith
richard at metafoo.co.uk
Mon Aug 13 13:24:01 PDT 2012
On Mon, Aug 13, 2012 at 11:04 AM, Fariborz Jahanian <fjahanian at apple.com>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.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20120813/89219089/attachment.html>
More information about the cfe-commits
mailing list