[cfe-commits] gcc's __format attribute is broken.

Rafael Espíndola rafael.espindola at gmail.com
Thu May 10 11:57:27 PDT 2012


On 10 May 2012 14:13, Anna Zaks <ganna at apple.com> wrote:
>
> CCing Rafael.

I will fix it tonight. Sorry about it.

> Anna.
> On May 10, 2012, at 11:03 AM, jahanian wrote:
>
>
> Following patch has broken a dejagnu test in couple of places.Failing part
> is attached.
> Couple of warnings are missing.
>
> - Fariborz
>
> Change #77256
>
> Changed byrafael
> Changed atWed 09 May 2012 19:50:16
> Repositorysmooshlab-project
> Revision156531
>
> Comments
>
> Fix an old (2009) FIXME:
>
> // FIXME: This needs to happen before we merge declarations. Then,
> // let attribute merging cope with attribute conflicts.
>
> This was already being done for variables, but for functions we were
> merging
> then first and then applying the attributes. To avoid duplicating merging
> logic, some of the helpers in SemaDeclAttr.cpp become methods that can
> handle merging two attributes in one decl or inheriting attributes from
> one
> decl to another.
>
> With this change we are now able to produce errors for variables with
> incompatible visibility attributes or warn about unused dllimports in
> variables.
>
> This changes the attribute list iteration back to being in reverse source
> code order, as that matches what decl merging does and avoids
> differentiating
> the two cases is the merge*Attr methods.
>
> Changed files
>
> include/clang/Sema/Sema.h
> lib/Sema/SemaDecl.cpp
> lib/Sema/SemaDeclAttr.cpp
> lib/Sema/TargetAttributesSema.cpp
> test/Index/complete-with-annotations.cpp
> test/Sema/attr-visibility.c
> test/Sema/dllimport-dllexport.c
>
>
>
>
> /* { dg-options "-std=gnu99 -Wformat" } */
> #include <stdarg.h>
> extern void my_vprintf_scanf3 (const char *, va_list, const char *, ...)
>      __attribute__((__format__(__printf__, 1, 0)));
> extern void my_vprintf_scanf3 (const char *, va_list, const char *, ...)
>      __attribute__((__format__(__scanf__, 3, 4)));
>
> extern void my_vprintf_scanf4 (const char *, va_list, const char *, ...)
>      __attribute__((__format__(__scanf__, 3, 4)));
> extern void my_vprintf_scanf4 (const char *, va_list, const char *, ...)
>      __attribute__((__format__(__printf__, 1, 0)));
>
> void
> foo (va_list ap, int *ip, long *lp)
> {
>   my_vprintf_scanf3 ("%", ap, "%d", ip); /* { dg-warning "format" "printf"
> } */
>   my_vprintf_scanf4 ("%d", ap, "%ld", ip); /* { dg-warning "format"
> "scanf" } */
> }
>
>
> _______________________________________________
> cfe-commits mailing list
> cfe-commits at cs.uiuc.edu
> http://lists.cs.uiuc.edu/mailman/listinfo/cfe-commits
>
>




More information about the cfe-commits mailing list