]> granicus.if.org Git - clang/commitdiff
When we invalidate a declaration, make it public, so that it doesn't
authorDouglas Gregor <dgregor@apple.com>
Fri, 5 Mar 2010 00:26:45 +0000 (00:26 +0000)
committerDouglas Gregor <dgregor@apple.com>
Fri, 5 Mar 2010 00:26:45 +0000 (00:26 +0000)
trigger access control or one of the many assertions we have for valid
access specifiers.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@97767 91177308-0d34-0410-b5e6-96231b3b80d8

include/clang/AST/DeclBase.h
lib/AST/DeclBase.cpp

index 7fb5f9daae17c93e48829026d043f86fc1ee4bc5..0bdc6f54b7ca1562b76e0362b86c269e7fe89935 100644 (file)
@@ -268,7 +268,7 @@ public:
 
   /// setInvalidDecl - Indicates the Decl had a semantic error. This
   /// allows for graceful error recovery.
-  void setInvalidDecl(bool Invalid = true) { InvalidDecl = Invalid; }
+  void setInvalidDecl(bool Invalid = true);
   bool isInvalidDecl() const { return (bool) InvalidDecl; }
 
   /// isImplicit - Indicates whether the declaration was implicitly
index 47b7e7efb60e06dc12fc46705bff9d4e6aca0cbb..9db6ae1329e4ed28ecd7eb1aeaab7d3c6be13688 100644 (file)
@@ -46,6 +46,16 @@ const char *Decl::getDeclKindName() const {
   }
 }
 
+void Decl::setInvalidDecl(bool Invalid) {
+  InvalidDecl = Invalid;
+  if (Invalid) {
+    // Defensive maneuver for ill-formed code: we're likely not to make it to
+    // a point where we set the access specifier, so default it to "public"
+    // to avoid triggering asserts elsewhere in the front end. 
+    setAccess(AS_public);
+  }
+}
+
 const char *DeclContext::getDeclKindName() const {
   switch (DeclKind) {
   default: assert(0 && "Declaration context not in DeclNodes.def!");