Index: lib/Sema/SemaDeclAttr.cpp =================================================================== --- lib/Sema/SemaDeclAttr.cpp +++ lib/Sema/SemaDeclAttr.cpp @@ -2595,7 +2595,7 @@ static void handleCleanupAttr(Sema &S, Decl *D, const AttributeList &Attr) { VarDecl *VD = cast(D); - if (!VD->hasLocalStorage()) { + if (!VD->hasLocalStorage() || isa(VD)) { S.Diag(Attr.getLoc(), diag::warn_attribute_ignored) << Attr.getName(); return; } Index: test/Sema/attr-cleanup.c =================================================================== --- test/Sema/attr-cleanup.c +++ test/Sema/attr-cleanup.c @@ -46,3 +46,5 @@ void t6(void) { int i __attribute__((cleanup((void *)0))); // expected-error {{'cleanup' argument is not a function}} } + +void t7(__attribute__((cleanup(c4))) int a) {} // expected-warning {{'cleanup' attribute ignored}}