forked from OSchip/llvm-project
fix __attribute__(format) for struct function pointer fields
llvm-svn: 49938
This commit is contained in:
parent
472cf88ef2
commit
42dd577238
|
@ -2268,10 +2268,14 @@ void Sema::HandleNothrowAttribute(Decl *d, AttributeList *rawAttr) {
|
|||
}
|
||||
|
||||
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();
|
||||
|
|
|
@ -17,3 +17,8 @@ void z(char *str, int c, ...) __attribute__((format(strftime, 1,2))); // expecte
|
|||
|
||||
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}}
|
||||
};
|
||||
|
|
Loading…
Reference in New Issue