summaryrefslogtreecommitdiffstats
path: root/clang/test
diff options
context:
space:
mode:
authorDavid Blaikie <dblaikie@gmail.com>2014-02-09 06:54:23 +0000
committerDavid Blaikie <dblaikie@gmail.com>2014-02-09 06:54:23 +0000
commit6cab596218f9b16f32153ccba57ac6fec9984bed (patch)
tree7bf905e246ea08a2a20db67bf6239f4f99d9561a /clang/test
parent158ba130eec9997716b22bdf2bfe476d9f73104a (diff)
downloadbcm5719-llvm-6cab596218f9b16f32153ccba57ac6fec9984bed.tar.gz
bcm5719-llvm-6cab596218f9b16f32153ccba57ac6fec9984bed.zip
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
Diffstat (limited to 'clang/test')
-rw-r--r--clang/test/CXX/basic/basic.lookup/basic.lookup.qual/class.qual/p2.cpp3
-rw-r--r--clang/test/CXX/temp/temp.res/temp.local/p3.cpp2
-rw-r--r--clang/test/SemaCXX/constructor-initializer.cpp2
-rw-r--r--clang/test/SemaCXX/member-pointer.cpp2
-rw-r--r--clang/test/SemaCXX/nested-name-spec.cpp13
-rw-r--r--clang/test/SemaObjCXX/propert-dot-error.mm6
6 files changed, 16 insertions, 12 deletions
diff --git a/clang/test/CXX/basic/basic.lookup/basic.lookup.qual/class.qual/p2.cpp b/clang/test/CXX/basic/basic.lookup/basic.lookup.qual/class.qual/p2.cpp
index 1f78a738f38..b9e83988cfb 100644
--- a/clang/test/CXX/basic/basic.lookup/basic.lookup.qual/class.qual/p2.cpp
+++ b/clang/test/CXX/basic/basic.lookup/basic.lookup.qual/class.qual/p2.cpp
@@ -105,9 +105,10 @@ namespace InhCtor {
};
+ // FIXME: Consider reusing the same diagnostic between dependent and non-dependent contexts
typedef int I;
struct UsingInt {
- using I::I; // expected-error {{expected a class or namespace}}
+ using I::I; // expected-error {{'I' (aka 'int') is not a class, namespace, or scoped enumeration}}
};
template<typename T> struct UsingIntTemplate {
using T::T; // expected-error {{type 'int' cannot be used prior to '::' because it has no members}}
diff --git a/clang/test/CXX/temp/temp.res/temp.local/p3.cpp b/clang/test/CXX/temp/temp.res/temp.local/p3.cpp
index 54da8856fe4..e29ced19bc4 100644
--- a/clang/test/CXX/temp/temp.res/temp.local/p3.cpp
+++ b/clang/test/CXX/temp/temp.res/temp.local/p3.cpp
@@ -15,7 +15,7 @@ template <class T> struct Derived: Base<int>, Base<char> {
t->Base<T>::f();
t->Base::f(); // expected-error{{member 'Base' found in multiple base classes of different types}} \
// expected-error{{no member named 'f' in 'X0'}} \
- // expected-error{{expected a class or namespace}}
+ // expected-error{{'Base' is not a class, namespace, or scoped enumeration}}
}
};
diff --git a/clang/test/SemaCXX/constructor-initializer.cpp b/clang/test/SemaCXX/constructor-initializer.cpp
index 697f718eabb..81dc19ea6df 100644
--- a/clang/test/SemaCXX/constructor-initializer.cpp
+++ b/clang/test/SemaCXX/constructor-initializer.cpp
@@ -94,7 +94,7 @@ struct Current : Derived {
Derived::Base1(), // expected-error {{type 'Derived::Base1' is not a direct or virtual base of 'Current'}}
Derived::V(),
::NonExisting(), // expected-error {{member initializer 'NonExisting' does not name a non-static data member or}}
- INT::NonExisting() {} // expected-error {{expected a class or namespace}} \
+ INT::NonExisting() {} // expected-error {{'INT' (aka 'int') is not a class, namespace, or scoped enumeration}} \
// expected-error {{member initializer 'NonExisting' does not name a non-static data member or}}
};
diff --git a/clang/test/SemaCXX/member-pointer.cpp b/clang/test/SemaCXX/member-pointer.cpp
index 82873d9c7da..b8631bcf3ef 100644
--- a/clang/test/SemaCXX/member-pointer.cpp
+++ b/clang/test/SemaCXX/member-pointer.cpp
@@ -13,7 +13,7 @@ int A::*pdi1;
int (::A::*pdi2);
int (A::*pfi)(int);
-int B::*pbi; // expected-error {{expected a class or namespace}}
+int B::*pbi; // expected-error {{'B' is not a class, namespace, or scoped enumeration}}
int C::*pci; // expected-error {{'pci' does not point into a class}}
void A::*pdv; // expected-error {{'pdv' declared as a member pointer to void}}
int& A::*pdr; // expected-error {{'pdr' declared as a member pointer to a reference}}
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}}
diff --git a/clang/test/SemaObjCXX/propert-dot-error.mm b/clang/test/SemaObjCXX/propert-dot-error.mm
index 2a462e4ffa3..e28204c665f 100644
--- a/clang/test/SemaObjCXX/propert-dot-error.mm
+++ b/clang/test/SemaObjCXX/propert-dot-error.mm
@@ -53,7 +53,7 @@ void g(B *b) {
// PR9759
class Forward;
-@interface D {
+@interface D { // expected-note 2 {{'D' declared here}}
@public
int ivar;
}
@@ -64,6 +64,6 @@ class Forward;
void testD(D *d) {
d.Forward::property = 17; // expected-error{{property access cannot be qualified with 'Forward::'}}
d->Forward::ivar = 12; // expected-error{{instance variable access cannot be qualified with 'Forward::'}}
- d.D::property = 17; // expected-error{{expected a class or namespace}}
- d->D::ivar = 12; // expected-error{{expected a class or namespace}}
+ d.D::property = 17; // expected-error{{'D' is not a class, namespace, or scoped enumeration}}
+ d->D::ivar = 12; // expected-error{{'D' is not a class, namespace, or scoped enumeration}}
}
OpenPOWER on IntegriCloud