When we see a reference to a struct, class, or union like "struct X"
that is neither a definition nor a forward declaration and where X has
not yet been declared as a tag, introduce a declaration
into the appropriate scope (which is likely *not* to be the current
scope). The rules for the placement of the declaration differ slightly
in C and C++, so we implement both and test the various corner
cases. This implementation isn't 100% correct due to some lingering
issues with the function prototype scope (for a function parameter
list) not being the same scope as the scope of the function
definition. Testcase is FIXME'd; this probably isn't an important issue.
Addresses <rdar://problem/6484805>.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@62014 91177308-0d34-0410-b5e6-96231b3b80d8
diff --git a/lib/Parse/ParseDeclCXX.cpp b/lib/Parse/ParseDeclCXX.cpp
index c6c2ae4..26787ae 100644
--- a/lib/Parse/ParseDeclCXX.cpp
+++ b/lib/Parse/ParseDeclCXX.cpp
@@ -720,7 +720,7 @@
SourceLocation LBraceLoc = ConsumeBrace();
- if (!CurScope->isCXXClassScope() && // Not about to define a nested class.
+ if (!CurScope->isClassScope() && // Not about to define a nested class.
CurScope->isInCXXInlineMethodScope()) {
// We will define a local class of an inline method.
// Push a new LexedMethodsForTopClass for its inline methods.
@@ -728,7 +728,7 @@
}
// Enter a scope for the class.
- ParseScope ClassScope(this, Scope::CXXClassScope|Scope::DeclScope);
+ ParseScope ClassScope(this, Scope::ClassScope|Scope::DeclScope);
Actions.ActOnTagStartDefinition(CurScope, TagDecl);
@@ -782,7 +782,7 @@
//
// FIXME: Only function bodies and constructor ctor-initializers are
// parsed correctly, fix the rest.
- if (!CurScope->getParent()->isCXXClassScope()) {
+ if (!CurScope->getParent()->isClassScope()) {
// We are not inside a nested class. This class and its nested classes
// are complete and we can parse the delayed portions of method
// declarations and the lexed inline method definitions.