Index: src/AST/AssertAcyclic.cpp
===================================================================
--- src/AST/AssertAcyclic.cpp	(revision 7cc034409f3debc9bfd2e43b089ff1d8d98113ac)
+++ src/AST/AssertAcyclic.cpp	(revision 7cc034409f3debc9bfd2e43b089ff1d8d98113ac)
@@ -0,0 +1,51 @@
+//
+// Cforall Version 1.0.0 Copyright (C) 2019 University of Waterloo
+//
+// The contents of this file are covered under the licence agreement in the
+// file "LICENCE" distributed with Cforall.
+//
+// AssertAcyclic.cpp -- Check that ast::ptr does not form a cycle.
+//
+// Author           : Andrew Beach
+// Created On       : Thu Jun 06 15:00:00 2019
+// Last Modified By : Andrew Beach
+// Last Modified On : Thu Jun 06 15:00:00 2019
+// Update Count     : 0
+//
+
+#include "AssertAcyclic.hpp"
+
+#include "AST/Pass.hpp"
+
+namespace {
+
+class NoStrongCyclesCore : public ast::WithGuards {
+    std::vector<const ast::Node *> parents;
+public:
+	void previsit ( const ast::Node * node ) {
+		for (auto & p : parents) {
+			assert(p != node);
+		}
+		parents.push_back(node);
+		GuardAction( [this]() { parents.pop_back(); } );
+	}
+};
+
+}
+
+namespace ast {
+
+void assertAcyclic( const std::list< ast::ptr< ast::Decl > > translationUnit ) {
+   	Pass<NoStrongCyclesCore> visitor;
+	for ( auto & decl : translationUnit ) {
+		decl->accept( visitor );
+	}
+}
+
+}
+
+// Local Variables: //
+// tab-width: 4 //
+// mode: c++ //
+// compile-command: "make install" //
+// End: //
Index: src/AST/AssertAcyclic.hpp
===================================================================
--- src/AST/AssertAcyclic.hpp	(revision 7cc034409f3debc9bfd2e43b089ff1d8d98113ac)
+++ src/AST/AssertAcyclic.hpp	(revision 7cc034409f3debc9bfd2e43b089ff1d8d98113ac)
@@ -0,0 +1,35 @@
+//
+// Cforall Version 1.0.0 Copyright (C) 2015 University of Waterloo
+//
+// The contents of this file are covered under the licence agreement in the
+// file "LICENCE" distributed with Cforall.
+//
+// AssertAcyclic.hpp -- Check that ast::ptr does not form a cycle.
+//
+// Author           : Andrew Beach
+// Created On       : Thr May 6 15:00:00 2019
+// Last Modified By : Andrew Beach
+// Last Modified On : Thr May 6 15:00:00 2019
+// Update Count     : 0
+//
+
+#pragma once
+
+#include <list>
+
+#include "Node.hpp"
+namespace ast {
+    class Decl;
+};
+
+namespace ast {
+
+void assertAcyclic( const std::list< ast::ptr< ast::Decl > > translationUnit );
+
+}
+
+// Local Variables: //
+// tab-width: 4 //
+// mode: c++ //
+// compile-command: "make install" //
+// End: //
Index: src/AST/module.mk
===================================================================
--- src/AST/module.mk	(revision 546e712c18fe907ee1619132a875d9ba32994efc)
+++ src/AST/module.mk	(revision 7cc034409f3debc9bfd2e43b089ff1d8d98113ac)
@@ -16,4 +16,5 @@
 
 SRC_AST = \
+	AST/AssertAcyclic.cpp \
 	AST/Attribute.cpp \
 	AST/Convert.cpp \
