forked from OSchip/llvm-project
Under ARC, merge the bit corresponding to the ns_returns_retained
attribute from the first declaration to later declarations. Fixes <rdar://problem/10142572>. llvm-svn: 141957
This commit is contained in:
parent
400907cc41
commit
f1404d7d49
|
@ -1439,6 +1439,9 @@ def err_cconv_varargs : Error<
|
|||
def err_regparm_mismatch : Error<"function declared with with regparm(%0) "
|
||||
"attribute was previously declared "
|
||||
"%plural{0:without the regparm|:with the regparm(%1)}1 attribute">;
|
||||
def err_returns_retained_mismatch : Error<
|
||||
"function declared with the ns_returns_retained attribute "
|
||||
"was previously declared without the ns_returns_retained attribute">;
|
||||
def err_objc_precise_lifetime_bad_type : Error<
|
||||
"objc_precise_lifetime only applies to retainable types; type here is %0">;
|
||||
def warn_objc_precise_lifetime_meaningless : Error<
|
||||
|
|
|
@ -1752,6 +1752,18 @@ bool Sema::MergeFunctionDecl(FunctionDecl *New, Decl *OldD) {
|
|||
RequiresAdjustment = true;
|
||||
}
|
||||
|
||||
// Merge ns_returns_retained attribute.
|
||||
if (OldTypeInfo.getProducesResult() != NewTypeInfo.getProducesResult()) {
|
||||
if (NewTypeInfo.getProducesResult()) {
|
||||
Diag(New->getLocation(), diag::err_returns_retained_mismatch);
|
||||
Diag(Old->getLocation(), diag::note_previous_declaration);
|
||||
return true;
|
||||
}
|
||||
|
||||
NewTypeInfo = NewTypeInfo.withProducesResult(true);
|
||||
RequiresAdjustment = true;
|
||||
}
|
||||
|
||||
if (RequiresAdjustment) {
|
||||
NewType = Context.adjustFunctionType(NewType, NewTypeInfo);
|
||||
New->setType(QualType(NewType, 0));
|
||||
|
|
|
@ -192,3 +192,11 @@ void f9790531_2(char * inClientData); // expected-note {{candidate function not
|
|||
f9790531_2(self); // expected-error {{no matching function for call to 'f9790531_2'}}
|
||||
}
|
||||
@end
|
||||
|
||||
class rdar10142572 {
|
||||
id f() __attribute__((ns_returns_retained));
|
||||
id g(); // expected-note{{previous declaration}}
|
||||
};
|
||||
|
||||
id rdar10142572::f() { return 0; } // okay: merged down
|
||||
id __attribute__((ns_returns_retained)) rdar10142572::g() { return 0; } // expected-error{{function declared with the ns_returns_retained attribute was previously declared without the ns_returns_retained attribute}}
|
||||
|
|
Loading…
Reference in New Issue