From a878d730775a884c1d936944f3b19e703643d5e9 Mon Sep 17 00:00:00 2001 From: Shagun Agrawal Date: Mon, 2 Sep 2024 23:31:59 +0530 Subject: Fix extra declaration nesting --- src/cljcc/analyzer.clj | 23 +++++++++++++---------- 1 file changed, 13 insertions(+), 10 deletions(-) (limited to 'src/cljcc/analyzer.clj') diff --git a/src/cljcc/analyzer.clj b/src/cljcc/analyzer.clj index 16124e6..9d761e7 100644 --- a/src/cljcc/analyzer.clj +++ b/src/cljcc/analyzer.clj @@ -86,6 +86,9 @@ (:variable-map for-init) new-var-map) ; updates new-var-map so that include possible ; variable declaration + for-init (if (:declaration for-init) + (:declaration for-init) + for-init) condition (resolve-optional-exp (:condition s) new-var-map) post (resolve-optional-exp (:post s) new-var-map) body (resolve-statement (:body s) new-var-map)] @@ -200,16 +203,16 @@ (pp/pprint (validate-from-src "int main (void) { -int a = 3; -{ - int a = a = 4; -} - -while (a < 10) { -break; -} - -return a; +int i = 0; + int j = 0; + int k = 1; + for (i = 100 ;;) { + int i = 1; + int j = i + k; + k = j; + } + + return k == 101 && i == 0 && j == 0; }")) (pp/pprint -- cgit v1.2.3