Skip to content

Commit bada0d4

Browse files
author
Oren Ben Simhon
committedMay 3, 2017
Reusing an existing attribute diagnostic
In a previous patch, a new generic error diagnostic for inconsistent attributes was added. In this commit I reuse this diagnostic for ns_returns_retained attribute check. Differential Revision: https://reviews.llvm.org/D32697 llvm-svn: 302024
1 parent d0baa52 commit bada0d4

File tree

3 files changed

+3
-5
lines changed

3 files changed

+3
-5
lines changed
 

‎clang/include/clang/Basic/DiagnosticSemaKinds.td

-3
Original file line numberDiff line numberDiff line change
@@ -2820,9 +2820,6 @@ def warn_cconv_structors : Warning<
28202820
def err_regparm_mismatch : Error<"function declared with regparm(%0) "
28212821
"attribute was previously declared "
28222822
"%plural{0:without the regparm|:with the regparm(%1)}1 attribute">;
2823-
def err_returns_retained_mismatch : Error<
2824-
"function declared with the ns_returns_retained attribute "
2825-
"was previously declared without the ns_returns_retained attribute">;
28262823
def err_function_attribute_mismatch : Error<
28272824
"function declared with %0 attribute "
28282825
"was previously declared without the %0 attribute">;

‎clang/lib/Sema/SemaDecl.cpp

+2-1
Original file line numberDiff line numberDiff line change
@@ -2951,7 +2951,8 @@ bool Sema::MergeFunctionDecl(FunctionDecl *New, NamedDecl *&OldD,
29512951
// Merge ns_returns_retained attribute.
29522952
if (OldTypeInfo.getProducesResult() != NewTypeInfo.getProducesResult()) {
29532953
if (NewTypeInfo.getProducesResult()) {
2954-
Diag(New->getLocation(), diag::err_returns_retained_mismatch);
2954+
Diag(New->getLocation(), diag::err_function_attribute_mismatch)
2955+
<< "'ns_returns_retained'";
29552956
Diag(OldLocation, diag::note_previous_declaration);
29562957
return true;
29572958
}

‎clang/test/SemaObjCXX/arc-overloading.mm

+1-1
Original file line numberDiff line numberDiff line change
@@ -199,4 +199,4 @@ - (void)applicationDidFinishLaunching {
199199
};
200200

201201
id rdar10142572::f() { return 0; } // okay: merged down
202-
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}}
202+
id __attribute__((ns_returns_retained)) rdar10142572::g() { return 0; } // expected-error{{function declared with 'ns_returns_retained' attribute was previously declared without the 'ns_returns_retained' attribute}}

0 commit comments

Comments
 (0)