anchor an if's arms only where the if is a statement
Every if had its arms anchored, including one inside an argument that the writer renders as ?:, so a #line landed between its parts and the C did not compile. -C output, with no directives, hid it. Fixes #54.
This commit is contained in:
@@ -86,7 +86,10 @@
|
||||
" (: done)" ; 52
|
||||
" (var svar u64 (sizeof (struct pt)))" ; 53
|
||||
" (var cvar int (cast mvar int))" ; 54
|
||||
" (return 122))" ; 55
|
||||
" (putchar (if (< mvar 123)" ; 55 a conditional as an
|
||||
" (putchar 124)" ; 56 argument: an expression,
|
||||
" 125))" ; 57 so no anchor inside it
|
||||
" (return 122))" ; 58
|
||||
))
|
||||
|
||||
(define fixture (string-intersperse fixture-lines "\n"))
|
||||
@@ -231,7 +234,14 @@ after that is one more. Lines before the first directive get #f."
|
||||
;; Expressions that are their own statement
|
||||
(test-group "expressions"
|
||||
(maps/tokens "sizeof" "(var svar" "sizeof")
|
||||
(maps/tokens "cast" "(var cvar" "(int)mvar"))
|
||||
(maps/tokens "cast" "(var cvar" "(int)mvar")
|
||||
;; an `if' arm is a statement only where the `if' is one: a
|
||||
;; directive between `?' and `:' does not compile
|
||||
(maps "conditional argument" "123")
|
||||
(test-assert "holds no directive"
|
||||
(let ((start (string-contains c-out "123")))
|
||||
(not (string-contains (substring c-out start (string-contains c-out "125" start))
|
||||
"#line")))))
|
||||
|
||||
;; A location is (file . line); every directive must name the file the
|
||||
;; form was read from.
|
||||
|
||||
Reference in New Issue
Block a user