aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDouglas Gregor <dgregor@apple.com>2010-03-05 00:26:45 +0000
committerDouglas Gregor <dgregor@apple.com>2010-03-05 00:26:45 +0000
commit42738573253da1bd61f9c44f8d77f600d3b0cd1c (patch)
treeb33f44225b8f68307cfd3af46b99a71b1a639eaf
parenta74326651c4040d2150192c43f29732ac5485e09 (diff)
When we invalidate a declaration, make it public, so that it doesn't
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
-rw-r--r--include/clang/AST/DeclBase.h2
-rw-r--r--lib/AST/DeclBase.cpp10
2 files changed, 11 insertions, 1 deletions
diff --git a/include/clang/AST/DeclBase.h b/include/clang/AST/DeclBase.h
index 7fb5f9daae..0bdc6f54b7 100644
--- a/include/clang/AST/DeclBase.h
+++ b/include/clang/AST/DeclBase.h
@@ -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
diff --git a/lib/AST/DeclBase.cpp b/lib/AST/DeclBase.cpp
index 47b7e7efb6..9db6ae1329 100644
--- a/lib/AST/DeclBase.cpp
+++ b/lib/AST/DeclBase.cpp
@@ -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!");