From b0dc07419bf1d93b0e9a3ac7b54db9d3d4cba5a1 Mon Sep 17 00:00:00 2001 From: Aaron Ballman Date: Tue, 26 Nov 2013 16:14:15 +0000 Subject: Replacing a custom diagnostic with a more standard one. No functional change intended. llvm-svn: 195770 --- clang/include/clang/Basic/DiagnosticSemaKinds.td | 2 -- clang/lib/Sema/SemaDeclAttr.cpp | 7 ++++--- clang/test/Sema/overloadable.c | 2 +- 3 files changed, 5 insertions(+), 6 deletions(-) diff --git a/clang/include/clang/Basic/DiagnosticSemaKinds.td b/clang/include/clang/Basic/DiagnosticSemaKinds.td index fcc87011c7b..b8d99ba52cf 100644 --- a/clang/include/clang/Basic/DiagnosticSemaKinds.td +++ b/clang/include/clang/Basic/DiagnosticSemaKinds.td @@ -2405,8 +2405,6 @@ def warn_iboutletcollection_property_assign : Warning< "IBOutletCollection properties should be copy/strong and not assign">, InGroup; -def err_attribute_overloadable_not_function : Error< - "'overloadable' attribute can only be applied to a function">; def err_attribute_overloadable_missing : Error< "%select{overloaded function|redeclaration of}0 %1 must have the " "'overloadable' attribute">; diff --git a/clang/lib/Sema/SemaDeclAttr.cpp b/clang/lib/Sema/SemaDeclAttr.cpp index 75674b08ef5..24009768f46 100644 --- a/clang/lib/Sema/SemaDeclAttr.cpp +++ b/clang/lib/Sema/SemaDeclAttr.cpp @@ -2563,10 +2563,11 @@ static void handleObjCNSObject(Sema &S, Decl *D, const AttributeList &Attr) { Attr.getAttributeSpellingListIndex())); } -static void -handleOverloadableAttr(Sema &S, Decl *D, const AttributeList &Attr) { +static void handleOverloadableAttr(Sema &S, Decl *D, + const AttributeList &Attr) { if (!isa(D)) { - S.Diag(Attr.getLoc(), diag::err_attribute_overloadable_not_function); + S.Diag(Attr.getLoc(), diag::err_attribute_wrong_decl_type) + << Attr.getName() << ExpectedFunction; return; } diff --git a/clang/test/Sema/overloadable.c b/clang/test/Sema/overloadable.c index b93c39fc1a2..bdd471477b4 100644 --- a/clang/test/Sema/overloadable.c +++ b/clang/test/Sema/overloadable.c @@ -1,6 +1,6 @@ // RUN: %clang_cc1 -fsyntax-only -verify %s -int var __attribute__((overloadable)); // expected-error{{'overloadable' attribute can only be applied to a function}} +int var __attribute__((overloadable)); // expected-error{{'overloadable' attribute only applies to functions}} void params(void) __attribute__((overloadable(12))); // expected-error {{'overloadable' attribute takes no arguments}} int *f(int) __attribute__((overloadable)); // expected-note 2{{previous overload of function is here}} -- cgit v1.2.3