1/* $NetBSD: lsym_do.c,v 1.10 2023/06/05 09:41:40 rillig Exp $ */ 2 3/* 4 * Tests for the token lsym_do, which represents the keyword 'do' that starts 5 * a 'do-while' loop. 6 * 7 * See also: 8 * psym_do.c 9 * psym_do_stmt.c 10 * C11 6.8.5 "Iteration statements" 11 * C11 6.8.5.2 "The 'do' statement" 12 */ 13 14//indent input 15void 16function(void) 17{ 18 do stmt();while(cond); 19} 20//indent end 21 22//indent run 23void 24function(void) 25{ 26 do 27 stmt(); 28 while (cond); 29} 30//indent end 31 32 33//indent input 34void 35else_do(int i) 36{ 37 if (i > 0) return; else do {} while (0); 38} 39//indent end 40 41//indent run 42void 43else_do(int i) 44{ 45 if (i > 0) 46 return; 47 else 48 do { 49 } while (0); 50} 51//indent end 52 53 54//indent input 55void 56variants(void) 57{ 58 do stmt(); while (0); 59 60 do { stmt(); } while (0); 61 62 do /* comment */ stmt(); while (0); 63 64 while (0) do {} while (0); 65} 66//indent end 67 68//indent run 69void 70variants(void) 71{ 72 do 73 stmt(); 74 while (0); 75 76 do { 77 stmt(); 78 } while (0); 79 80 do /* comment */ 81 stmt(); 82 while (0); 83 84 while (0) 85 do { 86 } while (0); 87} 88//indent end 89 90//indent run -bl 91void 92variants(void) 93{ 94 do 95 stmt(); 96 while (0); 97 98 do 99 { 100 stmt(); 101 } while (0); 102 103 do /* comment */ 104 stmt(); 105 while (0); 106 107 while (0) 108 do 109 { 110 } while (0); 111} 112//indent end 113 114 115/* Ensure that the 'do' starts a line. */ 116//indent input 117{ 118 /* */ do {} while (false); 119 120 word do {} while (false); 121 122 label: do {} while (false); 123} 124//indent end 125 126//indent run 127{ 128 /* */ 129 do { 130 } while (false); 131 132 word 133 do { 134 } while (false); 135 136label: do { 137 } while (false); 138} 139//indent end 140 141//indent run-equals-prev-output -sob 142