[cfe-commits] r49938 - in /cfe/trunk: lib/Sema/SemaDecl.cpp test/Sema/format-attribute.c
Nuno Lopes
nunoplopes at sapo.pt
Fri Apr 18 15:43:40 PDT 2008
Author: nlopes
Date: Fri Apr 18 17:43:39 2008
New Revision: 49938
URL: http://llvm.org/viewvc/llvm-project?rev=49938&view=rev
Log:
fix __attribute__(format) for struct function pointer fields
Modified:
cfe/trunk/lib/Sema/SemaDecl.cpp
cfe/trunk/test/Sema/format-attribute.c
Modified: cfe/trunk/lib/Sema/SemaDecl.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaDecl.cpp?rev=49938&r1=49937&r2=49938&view=diff
==============================================================================
--- cfe/trunk/lib/Sema/SemaDecl.cpp (original)
+++ cfe/trunk/lib/Sema/SemaDecl.cpp Fri Apr 18 17:43:39 2008
@@ -2268,10 +2268,14 @@
}
static const FunctionTypeProto *getFunctionProto(Decl *d) {
- ValueDecl *decl = dyn_cast<ValueDecl>(d);
- if (!decl) return 0;
+ QualType Ty;
- QualType Ty = decl->getType();
+ if (ValueDecl *decl = dyn_cast<ValueDecl>(d))
+ Ty = decl->getType();
+ else if (FieldDecl *decl = dyn_cast<FieldDecl>(d))
+ Ty = decl->getType();
+ else
+ return 0;
if (Ty->isFunctionPointerType()) {
const PointerType *PtrTy = Ty->getAsPointerType();
Modified: cfe/trunk/test/Sema/format-attribute.c
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Sema/format-attribute.c?rev=49938&r1=49937&r2=49938&view=diff
==============================================================================
--- cfe/trunk/test/Sema/format-attribute.c (original)
+++ cfe/trunk/test/Sema/format-attribute.c Fri Apr 18 17:43:39 2008
@@ -17,3 +17,8 @@
int (*f_ptr)(char*,...) __attribute__((format(printf, 1,2))); // no-error
int (*f2_ptr)(double,...) __attribute__((format(printf, 1, 2))); // expected-error {{format argument not a string type}}
+
+struct _mystruct {
+ int (*printf)(const char *format, ...) __attribute__((__format__(printf, 1, 2))); // no-error
+ int (*printf2)(double format, ...) __attribute__((__format__(printf, 1, 2))); // expected-error {{format argument not a string type}}
+};
More information about the cfe-commits
mailing list