ResolveSingleFunctionTemplateSpecialization() returns 0 and doesn't emit diags
unless the expression has template-ids, so we must null check the result.
Also add a better diag noting which overloads are causing the problem.
Reviewed by Aaron Ballman.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@193055
91177308-0d34-0410-b5e6-
96231b3b80d8
"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<
} 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;
/// 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,
int v1 __attribute__((cleanup(c2))); // expected-error {{'c2' is a private member of 'C'}}\r
}\r
};\r
+\r
+namespace E {\r
+ void c3(int *a) {} // expected-note {{candidate function}}\r
+ void c3() {} // expected-note {{candidate function}}\r
+ void t3() {\r
+ int v1 __attribute__((cleanup(c3))); // expected-error {{'c3' is not a single function}}\r
+ }\r
+}\r