[clang] Added more descriptive message (issue 116808) (PR #117201)
via cfe-commits
cfe-commits at lists.llvm.org
Fri Nov 22 08:29:02 PST 2024
https://github.com/tlemy updated https://github.com/llvm/llvm-project/pull/117201
>From 99f9b957a5b82c532e97b08b9a45ddf2a2918b68 Mon Sep 17 00:00:00 2001
From: ted <lemyted21 at gmail.com>
Date: Thu, 21 Nov 2024 13:04:05 -0500
Subject: [PATCH 1/2] Added more descriptive message (issue 116808)
---
clang/include/clang/Basic/DiagnosticSemaKinds.td | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/clang/include/clang/Basic/DiagnosticSemaKinds.td b/clang/include/clang/Basic/DiagnosticSemaKinds.td
index dfb90501ce72d7..3aa4cfa573dd56 100644
--- a/clang/include/clang/Basic/DiagnosticSemaKinds.td
+++ b/clang/include/clang/Basic/DiagnosticSemaKinds.td
@@ -1728,9 +1728,9 @@ def err_introducing_special_friend : Error<
def err_tagless_friend_type_template : Error<
"friend type templates must use an elaborated type">;
def err_no_matching_local_friend : Error<
- "no matching function found in local scope">;
+ "cannot define friend function in a local class definition">;
def err_no_matching_local_friend_suggest : Error<
- "no matching function %0 found in local scope; did you mean %3?">;
+ "cannot define friend function %0 in a local class definition; did you mean %3?">;
def err_partial_specialization_friend : Error<
"partial specialization cannot be declared as a friend">;
def err_qualified_friend_def : Error<
>From 441b4f3001bf74acd081eaa92d661c7f7daac310 Mon Sep 17 00:00:00 2001
From: ted <lemyted21 at gmail.com>
Date: Fri, 22 Nov 2024 11:28:22 -0500
Subject: [PATCH 2/2] Corrected tests
---
.../test/CXX/class.access/class.friend/p11.cpp | 18 +++++++++---------
clang/test/SemaCXX/function-redecl.cpp | 2 +-
2 files changed, 10 insertions(+), 10 deletions(-)
diff --git a/clang/test/CXX/class.access/class.friend/p11.cpp b/clang/test/CXX/class.access/class.friend/p11.cpp
index 71f11bdf9e0736..bc2bc073f51a73 100644
--- a/clang/test/CXX/class.access/class.friend/p11.cpp
+++ b/clang/test/CXX/class.access/class.friend/p11.cpp
@@ -12,7 +12,7 @@ namespace test0 {
namespace test1 {
void foo() {
class A {
- friend void bar(); // expected-error {{no matching function found in local scope}}
+ friend void bar(); // expected-error {{cannot define friend function in a local class definition}}
};
}
}
@@ -22,7 +22,7 @@ namespace test2 {
void foo() { // expected-note 2{{'::test2::foo' declared here}}
struct S1 {
- friend void foo(); // expected-error {{no matching function 'foo' found in local scope; did you mean '::test2::foo'?}}
+ friend void foo(); // expected-error {{cannot define friend function 'foo' in a local class definition; did you mean '::test2::foo'?}}
};
void foo(); // expected-note {{local declaration nearly matches}}
@@ -32,24 +32,24 @@ namespace test2 {
{
struct S2 {
- friend void foo(); // expected-error {{no matching function found in local scope}}
+ friend void foo(); // expected-error {{cannot define friend function in a local class definition}}
};
}
{
int foo;
struct S3 {
- friend void foo(); // expected-error {{no matching function 'foo' found in local scope; did you mean '::test2::foo'?}}
+ friend void foo(); // expected-error {{cannot define friend function 'foo' in a local class definition; did you mean '::test2::foo'?}}
};
}
struct S4 {
- friend void bar(); // expected-error {{no matching function 'bar' found in local scope; did you mean '::test2::bar'?}}
+ friend void bar(); // expected-error {{cannot define friend function 'bar' in a local class definition; did you mean '::test2::bar'?}}
};
{ void bar(); }
struct S5 {
- friend void bar(); // expected-error {{no matching function 'bar' found in local scope; did you mean '::test2::bar'?}}
+ friend void bar(); // expected-error {{cannot define friend function 'bar' in a local class definition; did you mean '::test2::bar'?}}
};
{
@@ -76,7 +76,7 @@ namespace test2 {
struct S9 {
struct Inner {
- friend void baz(); // expected-error {{no matching function 'baz' found in local scope; did you mean 'bar'?}}
+ friend void baz(); // expected-error {{cannot define friend function 'baz' in a local class definition; did you mean 'bar'?}}
};
};
@@ -84,8 +84,8 @@ namespace test2 {
void quux() {}
void foo() {
struct Inner1 {
- friend void bar(); // expected-error {{no matching function 'bar' found in local scope; did you mean '::test2::bar'?}}
- friend void quux(); // expected-error {{no matching function found in local scope}}
+ friend void bar(); // expected-error {{cannot define friend function 'bar' in a local class definition; did you mean '::test2::bar'?}}
+ friend void quux(); // expected-error {{cannot define friend function in a local class definition}}
};
void bar();
diff --git a/clang/test/SemaCXX/function-redecl.cpp b/clang/test/SemaCXX/function-redecl.cpp
index 8c0e9a880d070e..90490a4c1b7005 100644
--- a/clang/test/SemaCXX/function-redecl.cpp
+++ b/clang/test/SemaCXX/function-redecl.cpp
@@ -46,7 +46,7 @@ namespace test0 {
void dummy() {
void Bar(); // expected-note {{'Bar' declared here}}
class A {
- friend void bar(); // expected-error {{no matching function 'bar' found in local scope; did you mean 'Bar'}}
+ friend void bar(); // expected-error {{cannot define friend function 'bar' in a local class definition; did you mean 'Bar'}}
};
}
}
More information about the cfe-commits
mailing list