[cfe-commits] r152284 - in /cfe/trunk: include/clang/AST/Decl.h lib/AST/Decl.cpp test/SemaCXX/enum-scoped.cpp

Douglas Gregor dgregor at apple.com
Wed Mar 7 18:08:06 PST 2012


Author: dgregor
Date: Wed Mar  7 20:08:05 2012
New Revision: 152284

URL: http://llvm.org/viewvc/llvm-project?rev=152284&view=rev
Log:
Loosen the precondition of isCXXInstanceMember() to simply return
"false" for declarations that aren't members of classes. Fixes PR12106.

Modified:
    cfe/trunk/include/clang/AST/Decl.h
    cfe/trunk/lib/AST/Decl.cpp
    cfe/trunk/test/SemaCXX/enum-scoped.cpp

Modified: cfe/trunk/include/clang/AST/Decl.h
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/AST/Decl.h?rev=152284&r1=152283&r2=152284&view=diff
==============================================================================
--- cfe/trunk/include/clang/AST/Decl.h (original)
+++ cfe/trunk/include/clang/AST/Decl.h Wed Mar  7 20:08:05 2012
@@ -205,8 +205,8 @@
     return DC->isRecord();
   }
 
-  /// \brief Given that this declaration is a C++ class member,
-  /// determine whether it's an instance member of its class.
+  /// \brief Determine whether the given declaration is an instance member of
+  /// a C++ class.
   bool isCXXInstanceMember() const;
 
   class LinkageInfo {

Modified: cfe/trunk/lib/AST/Decl.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/AST/Decl.cpp?rev=152284&r1=152283&r2=152284&view=diff
==============================================================================
--- cfe/trunk/lib/AST/Decl.cpp (original)
+++ cfe/trunk/lib/AST/Decl.cpp Wed Mar  7 20:08:05 2012
@@ -997,9 +997,9 @@
 }
 
 bool NamedDecl::isCXXInstanceMember() const {
-  assert(isCXXClassMember() &&
-         "checking whether non-member is instance member");
-
+  if (!isCXXClassMember())
+    return false;
+  
   const NamedDecl *D = this;
   if (isa<UsingShadowDecl>(D))
     D = cast<UsingShadowDecl>(D)->getTargetDecl();

Modified: cfe/trunk/test/SemaCXX/enum-scoped.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/SemaCXX/enum-scoped.cpp?rev=152284&r1=152283&r2=152284&view=diff
==============================================================================
--- cfe/trunk/test/SemaCXX/enum-scoped.cpp (original)
+++ cfe/trunk/test/SemaCXX/enum-scoped.cpp Wed Mar  7 20:08:05 2012
@@ -174,3 +174,13 @@
 }
 
 enum class N2764::B {};
+
+namespace PR12106 {
+  template<typename E> struct Enum {
+    Enum() : m_e(E::Last) {}
+    E m_e;
+  };
+
+  enum eCOLORS { Last };
+  Enum<eCOLORS> e;
+}





More information about the cfe-commits mailing list