From 639bfc7b1e55e01dd38d2ef399366b5efa55a9a7 Mon Sep 17 00:00:00 2001 From: Anders Carlsson Date: Sun, 30 Aug 2009 06:49:43 +0000 Subject: [PATCH] Improve missing error messages as suggested by Doug. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@80489 91177308-0d34-0410-b5e6-96231b3b80d8 --- include/clang/Basic/DiagnosticSemaKinds.td | 8 ++++---- lib/Sema/Sema.cpp | 6 +++--- test/SemaCXX/missing-members.cpp | 18 +++++++++--------- 3 files changed, 16 insertions(+), 16 deletions(-) diff --git a/include/clang/Basic/DiagnosticSemaKinds.td b/include/clang/Basic/DiagnosticSemaKinds.td index 98e91b6ac5..564eacb4b4 100644 --- a/include/clang/Basic/DiagnosticSemaKinds.td +++ b/include/clang/Basic/DiagnosticSemaKinds.td @@ -1298,11 +1298,11 @@ def note_member_reference_needs_call : Note< def err_typecheck_incomplete_tag : Error<"incomplete definition of type %0">; def err_typecheck_no_member_deprecated : Error<"no member named %0">; def err_typecheck_record_no_member : Error< - "%select{struct|union|class}0 %q1 has no member named %2">; + "no member named %0 in %select{struct|union|class|enum}1 %q2">; def err_typecheck_namespace_no_member : Error< - "namespace %q0 has no member named %1">; -def err_typecheck_global_scope_no_member : Error< - "the global scope has no member named %0">; + "no member named %0 in namespace %q1">; +def err_typecheck_global_namespace_no_member : Error< + "no member named %0 in the global namespace">; def err_member_redeclared : Error<"class member cannot be redeclared">; def err_member_def_does_not_match : Error< diff --git a/lib/Sema/Sema.cpp b/lib/Sema/Sema.cpp index f291be1abb..755cc22d52 100644 --- a/lib/Sema/Sema.cpp +++ b/lib/Sema/Sema.cpp @@ -354,16 +354,16 @@ void Sema::DiagnoseMissingMember(SourceLocation MemberLoc, const Type *Ty = Context.getCanonicalType(NNS->getAsType()); RecordDecl *RD = cast(Ty)->getDecl(); Diag(MemberLoc, diag::err_typecheck_record_no_member) - << RD->getTagKind() << RD << Member << Range; + << Member << RD->getTagKind() << RD << Range; break; } case NestedNameSpecifier::Namespace: { Diag(MemberLoc, diag::err_typecheck_namespace_no_member) - << NNS->getAsNamespace() << Member << Range; + << Member << NNS->getAsNamespace() << Range; break; } case NestedNameSpecifier::Global: { - Diag(MemberLoc, diag::err_typecheck_global_scope_no_member) + Diag(MemberLoc, diag::err_typecheck_global_namespace_no_member) << Member << Range; break; } diff --git a/test/SemaCXX/missing-members.cpp b/test/SemaCXX/missing-members.cpp index 9df5b049f7..91cde600f9 100644 --- a/test/SemaCXX/missing-members.cpp +++ b/test/SemaCXX/missing-members.cpp @@ -8,19 +8,19 @@ namespace A { } void f() { - A::B::i; // expected-error {{namespace 'A::B' has no member named 'i'}} - A::B::C::i; // expected-error {{class 'A::B::C' has no member named 'i'}} - ::i; // expected-error {{the global scope has no member named 'i'}} + A::B::i; // expected-error {{no member named 'i' in namespace 'A::B'}} + A::B::C::i; // expected-error {{no member named 'i' in class 'A::B::C'}} + ::i; // expected-error {{no member named 'i' in the global namespace}} } -int A::B::i = 10; // expected-error {{namespace 'A::B' has no member named 'i'}} -int A::B::C::i = 10; // expected-error {{class 'A::B::C' has no member named 'i'}} -int A::B::S::i = 10; // expected-error {{struct 'A::B::S' has no member named 'i'}} -int A::B::U::i = 10; // expected-error {{union 'A::B::U' has no member named 'i'}} +int A::B::i = 10; // expected-error {{no member named 'i' in namespace 'A::B'}} +int A::B::C::i = 10; // expected-error {{no member named 'i' in class 'A::B::C'}} +int A::B::S::i = 10; // expected-error {{no member named 'i' in struct 'A::B::S'}} +int A::B::U::i = 10; // expected-error {{no member named 'i' in union 'A::B::U'}} -using A::B::D; // expected-error {{namespace 'A::B' has no member named 'D'}} +using A::B::D; // expected-error {{no member named 'D' in namespace 'A::B'}} struct S : A::B::C { - using A::B::C::f; // expected-error {{class 'A::B::C' has no member named 'f'}} + using A::B::C::f; // expected-error {{no member named 'f' in class 'A::B::C'}} }; -- 2.40.0