[cfe-commits] r151413 - in /cfe/trunk: lib/Sema/SemaExprMember.cpp test/SemaCXX/cxx0x-class.cpp test/SemaCXX/warn-thread-safety-analysis.cpp
DeLesley Hutchins
delesley at google.com
Fri Feb 24 16:11:55 PST 2012
Author: delesley
Date: Fri Feb 24 18:11:55 2012
New Revision: 151413
URL: http://llvm.org/viewvc/llvm-project?rev=151413&view=rev
Log:
Bugfix: bogus warning -- "invalid use of non-static data member",
when a class is forward declared, and the reference to the data
member in question does not occur within a method body.
Modified:
cfe/trunk/lib/Sema/SemaExprMember.cpp
cfe/trunk/test/SemaCXX/cxx0x-class.cpp
cfe/trunk/test/SemaCXX/warn-thread-safety-analysis.cpp
Modified: cfe/trunk/lib/Sema/SemaExprMember.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaExprMember.cpp?rev=151413&r1=151412&r2=151413&view=diff
==============================================================================
--- cfe/trunk/lib/Sema/SemaExprMember.cpp (original)
+++ cfe/trunk/lib/Sema/SemaExprMember.cpp Fri Feb 24 18:11:55 2012
@@ -173,7 +173,8 @@
// ...if C is not X or a base class of X, the class member access expression
// is ill-formed.
if (R.getNamingClass() &&
- contextClass != R.getNamingClass()->getCanonicalDecl() &&
+ contextClass->getCanonicalDecl() !=
+ R.getNamingClass()->getCanonicalDecl() &&
contextClass->isProvablyNotDerivedFrom(R.getNamingClass()))
return (hasNonInstance ? IMA_Mixed_Unrelated : IMA_Error_Unrelated);
Modified: cfe/trunk/test/SemaCXX/cxx0x-class.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/SemaCXX/cxx0x-class.cpp?rev=151413&r1=151412&r2=151413&view=diff
==============================================================================
--- cfe/trunk/test/SemaCXX/cxx0x-class.cpp (original)
+++ cfe/trunk/test/SemaCXX/cxx0x-class.cpp Fri Feb 24 18:11:55 2012
@@ -26,3 +26,14 @@
static constexpr float y2 = foo(); // expected-error {{must be initialized by a constant expression}} expected-note {{non-constexpr function 'foo'}}
};
}
+
+
+namespace Foo {
+ // Regression test -- forward declaration of Foo should not cause error about
+ // nonstatic data member.
+ class Foo;
+ class Foo {
+ int x;
+ int y = x;
+ };
+}
Modified: cfe/trunk/test/SemaCXX/warn-thread-safety-analysis.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/SemaCXX/warn-thread-safety-analysis.cpp?rev=151413&r1=151412&r2=151413&view=diff
==============================================================================
--- cfe/trunk/test/SemaCXX/warn-thread-safety-analysis.cpp (original)
+++ cfe/trunk/test/SemaCXX/warn-thread-safety-analysis.cpp Fri Feb 24 18:11:55 2012
@@ -2100,3 +2100,17 @@
} // end namespace SelfLockingTest
+namespace InvalidNonstatic {
+
+// Forward decl here causes bogus "invalid use of non-static data member"
+// on reference to mutex_ in guarded_by attribute.
+class Foo;
+
+class Foo {
+ Mutex* mutex_;
+
+ int foo __attribute__((guarded_by(mutex_)));
+};
+
+} // end namespace InvalidNonStatic
+
More information about the cfe-commits
mailing list