diff options
| author | Shagun Agrawal <agrawalshagun07@gmail.com> | 2024-09-02 23:31:59 +0530 |
|---|---|---|
| committer | Shagun Agrawal <agrawalshagun07@gmail.com> | 2024-09-02 23:31:59 +0530 |
| commit | a878d730775a884c1d936944f3b19e703643d5e9 (patch) | |
| tree | d0ef08aca422e515309fd864a3b373254428720c | |
| parent | a37366e6cec7b9fad387b738d60a4643a26570b1 (diff) | |
Fix extra declaration nesting
| -rw-r--r-- | src/cljcc/analyzer.clj | 23 |
1 files changed, 13 insertions, 10 deletions
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 |
