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

jahanian fjahanian at apple.com
Thu May 10 11:03:41 PDT 2012


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" } */
}


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


More information about the cfe-commits mailing list