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

Anna Zaks ganna at apple.com
Thu May 10 11:13:17 PDT 2012


CCing Rafael.

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 by	rafael
> Changed at	Wed 09 May 2012 19:50:16
> Repository	smooshlab-project
> Revision	156531
> 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

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20120510/d5fdd04c/attachment.html>


More information about the cfe-commits mailing list