lsym_case_label.c revision 1.3
11.3Srillig/* $NetBSD: lsym_case_label.c,v 1.3 2021/11/24 21:34:34 rillig Exp $ */ 21.1Srillig/* $FreeBSD$ */ 31.1Srillig 41.1Srillig/* 51.1Srillig * Tests for the token lsym_case_label, which represents either the keyword 61.1Srillig * 'case' or the keyword 'default', which are both used in 'switch' 71.1Srillig * statements. 81.1Srillig * 91.1Srillig * Since C11, the keyword 'default' is used in _Generic selections as well. 101.1Srillig * 111.1Srillig * See also: 121.2Srillig * opt_cli.c 131.1Srillig * psym_switch_expr.c 141.1Srillig * C11 6.5.1.1 "Generic selection" 151.1Srillig */ 161.1Srillig 171.1Srillig// TODO: test C11 _Generic 181.1Srillig 191.1Srillig#indent input 201.1Srillig// TODO: add input 211.1Srillig#indent end 221.1Srillig 231.1Srillig#indent run-equals-input 241.3Srillig 251.3Srillig 261.3Srillig/* 271.3Srillig * If there is a '{' after a case label, it gets indented using tabs instead 281.3Srillig * of spaces. Indent does not necessarily insert a space in this situation, 291.3Srillig * which looks strange. 301.3Srillig */ 311.3Srillig#indent input 321.3Srilligvoid 331.3Srilligfunction(void) 341.3Srillig{ 351.3Srillig switch (expr) { 361.3Srillig case 1: { 371.3Srillig break; 381.3Srillig } 391.3Srillig case 11: { 401.3Srillig break; 411.3Srillig } 421.3Srillig } 431.3Srillig} 441.3Srillig#indent end 451.3Srillig 461.3Srillig#indent run 471.3Srilligvoid 481.3Srilligfunction(void) 491.3Srillig{ 501.3Srillig switch (expr) { 511.3Srillig /* $ The space between the ':' and the '{' is actually a tab. */ 521.3Srillig case 1: { 531.3Srillig break; 541.3Srillig } 551.3Srillig /* $ FIXME: missing space between ':' and '{'. */ 561.3Srillig case 11:{ 571.3Srillig break; 581.3Srillig } 591.3Srillig } 601.3Srillig} 611.3Srillig#indent end 62