Add C++ forward declaration check
C++ prohibits forward declaration of an inner type.
At this point we take it over and prohibit such forward references.
The formal rule is that if type A references in its declaration type B
then B is parent of A or B’s parent is parent of A
(stack from global scope to A contains the exact parent of A).
Bug: 31827278
Test: mma
Test: test in follow-up CL moving lookups
Change-Id: Ia163fb76bce243c826b992202849108acd53f2c1
diff --git a/Type.h b/Type.h
index 8fb48b9..4055790 100644
--- a/Type.h
+++ b/Type.h
@@ -111,6 +111,10 @@
CheckAcyclicStatus checkAcyclic(std::unordered_set<const Type*>* visited,
std::unordered_set<const Type*>* stack) const;
+ // Checks following C++ restriction on forward declaration:
+ // inner struct could be forward declared only inside its parent.
+ status_t checkForwardReferenceRestrictions(const Reference<Type>& ref) const;
+
virtual const ScalarType *resolveToScalarType() const;
virtual std::string typeName() const = 0;
@@ -124,6 +128,7 @@
void setPostParseCompleted();
Scope* parent();
+ const Scope* parent() const;
enum StorageMode {
StorageMode_Stack,