c2hal: Comment out lone declarations.
Test: `make c2hal` and examine the result for c2hal/test/test.h
Change-Id: I1a72ecaddf6215b94bd76f3e8b09ed6def9aadcc
diff --git a/c2hal/AST.cpp b/c2hal/AST.cpp
index f803cc1..e2ae13c 100644
--- a/c2hal/AST.cpp
+++ b/c2hal/AST.cpp
@@ -21,8 +21,10 @@
#include "Scope.h"
#include "Declaration.h"
#include "CompositeDeclaration.h"
+#include "VarDeclaration.h"
#include "Define.h"
#include "Include.h"
+#include "Note.h"
#include <string>
#include <algorithm>
@@ -85,6 +87,13 @@
}
void AST::setDeclarations(std::vector<Declaration *> *declarations) {
+ // on the top level, no var declarations are allowed.
+ for(size_t i = 0; i < declarations->size(); i++) {
+ if(declarations->at(i)->decType() == VarDeclaration::type()) {
+ declarations->at(i) = new Note(declarations->at(i));
+ }
+ }
+
mDeclarations = declarations;
}
@@ -336,4 +345,4 @@
return mOutputDir;
}
-} // namespace android
\ No newline at end of file
+} // namespace android