Clang error: no matching function found in local scope (err_no_matching_local_friend)
Jump to navigation
Jump to search
Text | error: no matching function found in local scope |
---|---|
Type | Error |
Category | Semantic Issue |
Internal Id | err_no_matching_local_friend |
Internal Message | no matching function found in local scope
|
Regular Expression | (?:error|fatal error)\: no matching function found in local scope
|
First Commit | 2010-10-13 f7cfb2212c65 Support friend function declarations in local classes correctly. |
Description
Example
Flags | -xc++
|
|
---|---|---|
Source |
int main() {
class C {
friend void f() {}
// Friend function defined inside local class
};
return 0;
}
| |
Compiler Output |
<source>:3:21: error: friend function cannot be defined in a local class <source>:3:21: error: no matching function found in local scope |
Clang Internals (17.0.6)
Git Commit Message
Support friend function declarations in local classes correctly. Fixes a crash and diagnoses the error condition of an unqualified friend which doesn't resolve to something. I'm still not certain how this is useful. llvm-svn: 116393
Used in Clang Sources
This section lists all occurrences of the diagnostic within the Clang's codebase. For each occurrence, an auto-extracted snipped from the source code is listed including key elements like control structures, functions, or classes. It should illustrate the conditions under which the diagnostic is activated.
clang/lib/Sema/SemaDecl.cpp (line 8955)
/// Generate diagnostics for an invalid function redeclaration.
///
/// This routine handles generating the diagnostic messages for an invalid
/// function redeclaration, including finding possible similar declarations
/// or performing typo correction if there are no previous declarations with
/// the same name.
///
/// Returns a NamedDecl iff typo correction was performed and substituting in
/// the new declaration name does not cause new errors.
static NamedDecl *DiagnoseInvalidRedeclaration(Sema &SemaRef, LookupResult &Previous, FunctionDecl *NewFD, ActOnFDArgs &ExtraArgs, bool IsLocalFriend, Scope *S) {
// ...
unsigned DiagMsg = IsLocalFriend ? diag::err_no_matching_local_friend : NewFD->getFriendObjectKind() ? diag::err_qualified_friend_no_match : diag::err_member_decl_does_not_match;
Triggered in Clang Tests
This section lists all internal Clang test cases that trigger the diagnostic.
clang/test/CXX/class.access/class.friend/p11.cpp
- clang/test/CXX/class.access/class.friend/p11.cpp:16:19: error: no matching function found in local scope
- clang/test/CXX/class.access/class.friend/p11.cpp:36:21: error: no matching function found in local scope
- clang/test/CXX/class.access/class.friend/p11.cpp:89:23: error: no matching function found in local scope