From b2fd97ec23e73c4f091039159b3353224727ddd7 Mon Sep 17 00:00:00 2001 From: remix7531 <131352678+remix7531@users.noreply.github.com> Date: Wed, 4 Nov 2026 21:01:44 +0000 Subject: [PATCH] Print for loops with the CompCert guard orientation The specialized for-loop notation printed a guard that breaks when true as a continuing condition. Match Sifthenelse guard Sskip Sbreak instead, as CompCert's Swhile and Sfor expand. The opposite orientation still prints as the generic loop containing its conditional break. --- floyd/Clightnotations.v | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/floyd/Clightnotations.v b/floyd/Clightnotations.v index d8be02ab7..71e5092f7 100644 --- a/floyd/Clightnotations.v +++ b/floyd/Clightnotations.v @@ -82,7 +82,7 @@ Notation "'switch' ( e_val ) { cases }" := (Sswitch e_val%expr cases%print_cases Notation "continue;" := Scontinue (only printing, format "continue;", at level 10) : C_scope. Notation "break;" := Sbreak (only printing, format "break;", at level 10) : C_scope. Notation "'for' ( ; ; s2 ) { s1 }" := (Sloop s1%C s2%print_stmt_for) (only printing, s2 at level 26, s1 at level 26, right associativity, at level 26, format "'[v' 'for' ( ; '/' ; '/' s2 ) { '/ ' s1 '/' } ']'") : C_scope. -Notation "'for' ( ; e ; s2 ) { s1 }" := (Sloop (Ssequence (Sifthenelse e%expr Sbreak Sskip) s1%C) s2%print_stmt_for) (only printing, s2 at level 26, s1 at level 26, right associativity, at level 26, format "'[v' 'for' ( ; '/' e ; '/' s2 ) { '/ ' s1 '/' } ']'") : C_scope. +Notation "'for' ( ; e ; s2 ) { s1 }" := (Sloop (Ssequence (Sifthenelse e%expr Sskip Sbreak) s1%C) s2%print_stmt_for) (only printing, s2 at level 26, s1 at level 26, right associativity, at level 26, format "'[v' 'for' ( ; '/' e ; '/' s2 ) { '/ ' s1 '/' } ']'") : C_scope. Notation "'for' ( ; ; ) { s1 }" := (Sloop s1%C Sskip) (only printing, s1 at level 26, right associativity, at level 26, format "'[v' 'for' ( ; ; ) { '/ ' s1 '/' } ']'") : C_scope. Notation "'for' ( s1 ; e ; s2 ) { s3 }" := (Sfor s1%print_stmt_for e%expr s3%C s2%print_stmt_for) (only printing, s2 at level 26, s1 at level 26, right associativity, at level 26, format "'[v' 'for' ( '/' s1 ; '/' e ; '/' s2 ) { '/ ' s3 '/' } ']'") : C_scope. Notation "'if' ( e_val ) { s1 } 'else' { s2 }" := (Sifthenelse e_val%expr s1%C s2%C) (only printing, s1 at level 26, s2 at level 26, right associativity, at level 26, format "'[v' 'if' ( e_val ) { '/ ' s1 '/' } 'else' { '/ ' s2 '/' } ']'") : C_scope.