summaryrefslogtreecommitdiffstats
path: root/clang
diff options
context:
space:
mode:
Diffstat (limited to 'clang')
-rw-r--r--clang/include/clang/Basic/DiagnosticSemaKinds.td2
-rw-r--r--clang/lib/Sema/SemaDeclAttr.cpp9
-rw-r--r--clang/lib/Sema/SemaOverload.cpp3
-rw-r--r--clang/test/SemaCXX/attr-cleanup.cpp8
4 files changed, 19 insertions, 3 deletions
diff --git a/clang/include/clang/Basic/DiagnosticSemaKinds.td b/clang/include/clang/Basic/DiagnosticSemaKinds.td
index 55c4e9d57b5..d582ad5ad7d 100644
--- a/clang/include/clang/Basic/DiagnosticSemaKinds.td
+++ b/clang/include/clang/Basic/DiagnosticSemaKinds.td
@@ -2365,7 +2365,7 @@ def warn_cleanup_ext : Warning<
"than a simple identifier">,
InGroup<GccCompat>;
def err_attribute_cleanup_arg_not_function : Error<
- "'cleanup' argument %select{|%1 }0is not a function">;
+ "'cleanup' argument %select{|%1 |%1 }0is not a %select{||single }0function">;
def err_attribute_cleanup_func_must_take_one_arg : Error<
"'cleanup' function %0 must take 1 parameter">;
def err_attribute_cleanup_func_arg_incompatible_type : Error<
diff --git a/clang/lib/Sema/SemaDeclAttr.cpp b/clang/lib/Sema/SemaDeclAttr.cpp
index 3eabf87624c..a71d3c0d7b5 100644
--- a/clang/lib/Sema/SemaDeclAttr.cpp
+++ b/clang/lib/Sema/SemaDeclAttr.cpp
@@ -2899,10 +2899,15 @@ static void handleCleanupAttr(Sema &S, Decl *D, const AttributeList &Attr) {
} else if (UnresolvedLookupExpr *ULE = dyn_cast<UnresolvedLookupExpr>(E)) {
if (ULE->hasExplicitTemplateArgs())
S.Diag(Loc, diag::warn_cleanup_ext);
-
- // This will diagnose the case where the function cannot be found.
FD = S.ResolveSingleFunctionTemplateSpecialization(ULE, true);
NI = ULE->getNameInfo();
+ if (!FD) {
+ S.Diag(Loc, diag::err_attribute_cleanup_arg_not_function) << 2
+ << NI.getName();
+ if (ULE->getType() == S.Context.OverloadTy)
+ S.NoteAllOverloadCandidates(ULE);
+ return;
+ }
} else {
S.Diag(Loc, diag::err_attribute_cleanup_arg_not_function) << 0;
return;
diff --git a/clang/lib/Sema/SemaOverload.cpp b/clang/lib/Sema/SemaOverload.cpp
index 6dbb7b6cc57..20cfb00584d 100644
--- a/clang/lib/Sema/SemaOverload.cpp
+++ b/clang/lib/Sema/SemaOverload.cpp
@@ -9672,6 +9672,9 @@ Sema::ResolveAddressOfOverloadedFunction(Expr *AddressOfExpr,
/// template, where that template-id refers to a single template whose template
/// arguments are either provided by the template-id or have defaults,
/// as described in C++0x [temp.arg.explicit]p3.
+///
+/// If no template-ids are found, no diagnostics are emitted and NULL is
+/// returned.
FunctionDecl *
Sema::ResolveSingleFunctionTemplateSpecialization(OverloadExpr *ovl,
bool Complain,
diff --git a/clang/test/SemaCXX/attr-cleanup.cpp b/clang/test/SemaCXX/attr-cleanup.cpp
index b6c58533acf..764df997dec 100644
--- a/clang/test/SemaCXX/attr-cleanup.cpp
+++ b/clang/test/SemaCXX/attr-cleanup.cpp
@@ -19,3 +19,11 @@ class D : public C {
int v1 __attribute__((cleanup(c2))); // expected-error {{'c2' is a private member of 'C'}}
}
};
+
+namespace E {
+ void c3(int *a) {} // expected-note {{candidate function}}
+ void c3() {} // expected-note {{candidate function}}
+ void t3() {
+ int v1 __attribute__((cleanup(c3))); // expected-error {{'c3' is not a single function}}
+ }
+}
OpenPOWER on IntegriCloud