From: Ted Kremenek Date: Fri, 9 May 2008 17:36:24 +0000 (+0000) Subject: Add attribute "format" support for typedefs of function pointers. X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=72786e009bd0519882ceac874e618134d2200d95;p=clang Add attribute "format" support for typedefs of function pointers. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@50906 91177308-0d34-0410-b5e6-96231b3b80d8 --- diff --git a/lib/Sema/SemaDecl.cpp b/lib/Sema/SemaDecl.cpp index 748b66fb3e..afe877fb97 100644 --- a/lib/Sema/SemaDecl.cpp +++ b/lib/Sema/SemaDecl.cpp @@ -2338,6 +2338,8 @@ static const FunctionTypeProto *getFunctionProto(Decl *d) { Ty = decl->getType(); else if (FieldDecl *decl = dyn_cast(d)) Ty = decl->getType(); + else if (TypedefDecl* decl = dyn_cast(d)) + Ty = decl->getUnderlyingType(); else return 0; diff --git a/test/Sema/format-attribute.c b/test/Sema/format-attribute.c index 8eefe3f065..ecdef9dde1 100644 --- a/test/Sema/format-attribute.c +++ b/test/Sema/format-attribute.c @@ -22,3 +22,5 @@ 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}} }; + +typedef int (*f3_ptr)(char*,...) __attribute__((format(printf,1,0))); // no-error