From 61f1dc05a88de38afcb337ef194cfdb7dc798197 Mon Sep 17 00:00:00 2001 From: tlemy <138604946+tlemy@users.noreply.github.com> Date: Fri, 22 Nov 2024 12:24:17 -0500 Subject: [PATCH] Added more descriptive message (issue 116808) (#117201) The dialogue messages were changed to be more descriptive. Fixes #116808 --- .../include/clang/Basic/DiagnosticSemaKinds.td | 4 ++-- .../test/CXX/class.access/class.friend/p11.cpp | 18 +++++++++--------- clang/test/SemaCXX/function-redecl.cpp | 2 +- 3 files changed, 12 insertions(+), 12 deletions(-) diff --git a/clang/include/clang/Basic/DiagnosticSemaKinds.td b/clang/include/clang/Basic/DiagnosticSemaKinds.td index 157d77b38b35..eb05a6a77978 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< diff --git a/clang/test/CXX/class.access/class.friend/p11.cpp b/clang/test/CXX/class.access/class.friend/p11.cpp index 71f11bdf9e07..bc2bc073f51a 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 8c0e9a880d07..90490a4c1b70 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'}} }; } }