Module Name: src Committed By: rillig Date: Sat Feb 12 19:46:56 UTC 2022
Modified Files: src/tests/usr.bin/indent: lsym_tag.c Log Message: tests/indent: add another test for indentation of enum constants To prevent an overzealous quick hack for indenting enum constants in a typedef, as part of fixing PR#55453. To generate a diff of this commit: cvs rdiff -u -r1.1 -r1.2 src/tests/usr.bin/indent/lsym_tag.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files.
Modified files: Index: src/tests/usr.bin/indent/lsym_tag.c diff -u src/tests/usr.bin/indent/lsym_tag.c:1.1 src/tests/usr.bin/indent/lsym_tag.c:1.2 --- src/tests/usr.bin/indent/lsym_tag.c:1.1 Thu Nov 18 21:19:19 2021 +++ src/tests/usr.bin/indent/lsym_tag.c Sat Feb 12 19:46:56 2022 @@ -1,4 +1,4 @@ -/* $NetBSD: lsym_tag.c,v 1.1 2021/11/18 21:19:19 rillig Exp $ */ +/* $NetBSD: lsym_tag.c,v 1.2 2022/02/12 19:46:56 rillig Exp $ */ /* $FreeBSD$ */ /* @@ -6,8 +6,38 @@ * 'struct', 'union' or 'enum' that declare, define or use a tagged type. */ +/* TODO: Add systematic tests for 'struct'. */ +/* TODO: Add systematic tests for 'union'. */ +/* TODO: Add systematic tests for 'enum'. */ + + #indent input -// TODO: add input +int +indent_enum_constants(void) +{ + enum color { + red, + green + }; + enum color colors[] = { + red, + red, + red, + }; + /* + * Ensure that the token sequence 'enum type {' only matches if there + * are no other tokens in between, to prevent statement continuations + * from being indented like enum constant declarations. + * + * See https://gnats.netbsd.org/55453. + */ + if (colors[0] == (enum color)1) { + return 1 + + 2 + + 3; + } + return 0; +} #indent end -#indent run-equals-input +#indent run-equals-input -ci2