summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorArgyrios Kyrtzidis <akyrtzi@gmail.com>2011-01-31 07:04:33 +0000
committerArgyrios Kyrtzidis <akyrtzi@gmail.com>2011-01-31 07:04:33 +0000
commitb85cd7c312aecd9f6837e69a47e12d98f3307530 (patch)
tree7abcddcdd6bdee39bc2c77498946580215d7ea1a
parent8322b426a56db0ecaf99c565746ed04448cd29b1 (diff)
downloadbcm5719-llvm-b85cd7c312aecd9f6837e69a47e12d98f3307530.tar.gz
bcm5719-llvm-b85cd7c312aecd9f6837e69a47e12d98f3307530.zip
Error for use of field from anonymous struct or union should say "invalid use of nonstatic data member"
not "call to non-static member function without an object argument". llvm-svn: 124576
-rw-r--r--clang/lib/Sema/SemaExpr.cpp2
-rw-r--r--clang/test/SemaCXX/class.cpp12
2 files changed, 13 insertions, 1 deletions
diff --git a/clang/lib/Sema/SemaExpr.cpp b/clang/lib/Sema/SemaExpr.cpp
index 2429c75880e..4a0f2299dbd 100644
--- a/clang/lib/Sema/SemaExpr.cpp
+++ b/clang/lib/Sema/SemaExpr.cpp
@@ -1154,7 +1154,7 @@ static void DiagnoseInstanceReference(Sema &SemaRef,
SourceRange Range(Loc);
if (SS.isSet()) Range.setBegin(SS.getRange().getBegin());
- if (R.getAsSingle<FieldDecl>()) {
+ if (R.getAsSingle<FieldDecl>() || R.getAsSingle<IndirectFieldDecl>()) {
if (CXXMethodDecl *MD = dyn_cast<CXXMethodDecl>(SemaRef.CurContext)) {
if (MD->isStatic()) {
// "invalid use of member 'x' in static member function"
diff --git a/clang/test/SemaCXX/class.cpp b/clang/test/SemaCXX/class.cpp
index 7c6a62f41e1..52140cb0743 100644
--- a/clang/test/SemaCXX/class.cpp
+++ b/clang/test/SemaCXX/class.cpp
@@ -176,3 +176,15 @@ namespace rdar8367341 {
static const float y = foo(); // expected-warning {{in-class initializer for static data member of type 'const float' is a C++0x extension}} expected-error {{in-class initializer is not a constant expression}}
};
}
+
+namespace with_anon {
+struct S {
+ union {
+ char c;
+ };
+};
+
+void f() {
+ S::c; // expected-error {{invalid use of nonstatic data member}}
+}
+}
OpenPOWER on IntegriCloud