From 6cab596218f9b16f32153ccba57ac6fec9984bed Mon Sep 17 00:00:00 2001 From: David Blaikie Date: Sun, 9 Feb 2014 06:54:23 +0000 Subject: Improve diagnostic for using non-class/namespace/scoped enum in a nested name specifier. Rather than simply saying "X is not a class or namespace", clarify what X is by providing the aka type in the case where X is a type, or pointing to the named declaration if there's an unambiguous one to refer to. In the ambiguous case, the ambiguities are already enumerated (though could be clarified by describing what kind of entities they are) Included a few FIXMEs in tests where some further improvements could be made. llvm-svn: 201038 --- clang/test/SemaCXX/nested-name-spec.cpp | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-) (limited to 'clang/test/SemaCXX/nested-name-spec.cpp') diff --git a/clang/test/SemaCXX/nested-name-spec.cpp b/clang/test/SemaCXX/nested-name-spec.cpp index a0bac059a20..8587e70158b 100644 --- a/clang/test/SemaCXX/nested-name-spec.cpp +++ b/clang/test/SemaCXX/nested-name-spec.cpp @@ -85,10 +85,13 @@ struct A2::CC::NC { void f3() { N::x = 0; // expected-error {{use of undeclared identifier 'N'}} - int N; - N::x = 0; // expected-error {{expected a class or namespace}} + // FIXME: Consider including the kind of entity that 'N' is ("variable 'N' + // declared here", "template 'X' declared here", etc) to help explain what it + // is if it's 'not a class, namespace, or scoped enumeration'. + int N; // expected-note {{'N' declared here}} + N::x = 0; // expected-error {{'N' is not a class, namespace, or scoped enumeration}} { int A; A::ax = 0; } - { typedef int A; A::ax = 0; } // expected-error{{expected a class or namespace}} + { typedef int A; A::ax = 0; } // expected-error{{'A' (aka 'int') is not a class, namespace, or scoped enumeration}} { typedef A::C A; A::ax = 0; } // expected-error {{no member named 'ax'}} { typedef A::C A; A::cx = 0; } } @@ -114,7 +117,7 @@ namespace E { }; void f() { - return E::X; // expected-error{{expected a class or namespace}} + return E::X; // expected-error{{'E::Nested::E' is not a class, namespace, or scoped enumeration}} } } } @@ -308,4 +311,4 @@ namespace N { } namespace TypedefNamespace { typedef int F; }; -TypedefNamespace::F::NonexistentName BadNNSWithCXXScopeSpec; // expected-error {{expected a class or namespace}} +TypedefNamespace::F::NonexistentName BadNNSWithCXXScopeSpec; // expected-error {{'F' (aka 'int') is not a class, namespace, or scoped enumeration}} -- cgit v1.2.3