aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--lib/Sema/SemaExpr.cpp2
-rw-r--r--test/SemaCXX/class.cpp12
2 files changed, 13 insertions, 1 deletions
diff --git a/lib/Sema/SemaExpr.cpp b/lib/Sema/SemaExpr.cpp
index 2429c75880..4a0f2299db 100644
--- a/lib/Sema/SemaExpr.cpp
+++ b/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/test/SemaCXX/class.cpp b/test/SemaCXX/class.cpp
index 7c6a62f41e..52140cb074 100644
--- a/test/SemaCXX/class.cpp
+++ b/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}}
+}
+}