ref: e915714cbfee3ac1d5bcfcbb3cda56939f64821e
parent: e3598b4df463df725281f103d0fe37108517dbd3
author: Roberto E. Vargas Caballero <[email protected]>
date: Tue Jun 7 04:41:37 EDT 2016
[cc2] Fix parsing of ternary operators The parser was correct, but the generated tree was not correct, because the names of ask and colon were interchanged and we were not joint the ? with the :
--- a/cc2/parser.c
+++ b/cc2/parser.c
@@ -272,7 +272,7 @@
static void
ternary(char *token, union tokenop u)
{
- Node *ask = newnode(OCOLON), *colon = newnode(OASK);
+ Node *ask = newnode(OASK), *colon = newnode(OCOLON);
Type *tp = gettype(token+1);
colon->right = pop();
@@ -280,6 +280,7 @@
ask->type = *tp;
ask->left = pop();
+ ask->right = colon;
push(ask);
}