c2newspeak: the condition of for loop can be a sequence : for(x=0;x=1,x;x++)
authorEtienne Millon <etienne . millon AT eads . net>
Thu Feb 16 16:07:04 2012 +0100 (3 months ago)
changeset 3018e71cd880cb25
parent 3017bed46bd36b82
child 301949a8e6fd7f19
c2newspeak: the condition of for loop can be a sequence : for(x=0;x=1,x;x++)
src/c2newspeak/parser.mly
tests/c2newspeak/857.c
tests/c2newspeak/857.spec
tests/c2newspeak/Makefile
       1 --- a/src/c2newspeak/parser.mly	Thu Feb 16 15:32:21 2012 +0100
       2 +++ b/src/c2newspeak/parser.mly	Thu Feb 16 16:07:04 2012 +0100
       3 @@ -1066,7 +1066,7 @@
       4  ;;
       5  
       6  expression_option:
       7 -  expression                               { Some $1 }
       8 +  expression_sequence                      { Some $1 }
       9  |                                          { None }
      10  ;;
      11  
     1.1 --- a/tests/c2newspeak/Makefile	Thu Feb 16 15:32:21 2012 +0100
     1.2 +++ b/tests/c2newspeak/Makefile	Thu Feb 16 16:07:04 2012 +0100
     1.3 @@ -110,7 +110,7 @@
     1.4          820 821 822 823 824 825 826 827 828 829 \
     1.5  	830 831 832 833 834 835 836 837 838 839 \
     1.6  	840 841 842 843 844 845 846 847 848 849 \
     1.7 -	850 851 852 853 854 855 856
     1.8 +	850 851 852 853 854 855 856 857
     1.9  
    1.10  PREREQ=%.c
    1.11  CLEANFILES=$(addsuffix .cil.bak, $(TESTS))
     2.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     2.2 +++ b/tests/c2newspeak/857.c	Thu Feb 16 16:07:04 2012 +0100
     2.3 @@ -0,0 +1,5 @@
     2.4 +void f(void)
     2.5 +{
     2.6 +    int x;
     2.7 +    for(x=0;x=1,x;x++);
     2.8 +}
     3.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     3.2 +++ b/tests/c2newspeak/857.spec	Thu Feb 16 16:07:04 2012 +0100
     3.3 @@ -0,0 +1,22 @@
     3.4 +Warning: 857.c:4#0: comma in expression accepted
     3.5 +Newspeak output
     3.6 +---------------
     3.7 +void (857.c:1#5)^f(void) {
     3.8 +  (857.c:3#8)^int32 x;
     3.9 +  (857.c:4#8)^x =(int32) 0;
    3.10 +  (857.c:4#4)^do {
    3.11 +    (857.c:4#4)^while (1) {
    3.12 +      (857.c:4#12)^x =(int32) 1;
    3.13 +      (857.c:4#4)^choose {
    3.14 +       -->
    3.15 +        (857.c:4#4)^guard(x_int32);
    3.16 +       -->
    3.17 +        (857.c:4#4)^guard(! x_int32);
    3.18 +        (857.c:4#4)^goto lbl1;
    3.19 +      }
    3.20 +      (857.c:4#18)^x =(int32) coerce[-2147483648,2147483647] (x_int32 + 1);
    3.21 +    }
    3.22 +  } with lbl1:
    3.23 +}
    3.24 +
    3.25 +