forked from alex-eg/sex
refuse a malformed enumerator
Anything in the list but a name or (name value) was taken apart as if it were the pair: (! 1 2) came out ! = 1.
This commit is contained in:
@@ -246,6 +246,14 @@
|
||||
"enum color m = red"))
|
||||
(test-assert "a malformed enum is rejected with its location"
|
||||
(reports? "(enum)" "codegen.sex:1:"))
|
||||
;; anything else in the list was the name its head was and the
|
||||
;; value its second element: (! 1 2) came out `! = 1'
|
||||
(test-assert "an enumerator is a name, or a name and a value"
|
||||
(reports? "(enum color (red (! 1 2)))" "an enumerator is a name, or (name value)"))
|
||||
(test-assert "and an operator is no name"
|
||||
(reports? "(enum color (red (! 1)))" "an enumerator is a name, or (name value)"))
|
||||
(test-assert "nor a value with no name"
|
||||
(reports? "(enum color (red 7))" "an enumerator is a name, or (name value)"))
|
||||
;; c-type handed the declarator's name to c-enum as the enum tag,
|
||||
;; so this emitted `enum m { up, down }' with no variable at all
|
||||
(test-assert "an anonymous enum keeps the variable"
|
||||
|
||||
Reference in New Issue
Block a user