Re: Incorrect pointer align

Petr Pisar <[email protected]> Wed, 12 Apr 2023 15:19:28 +0200
Newsgroups gmane.comp.gnu.indent.bugs
Message-ID <[email protected]>
--q1h9ZkiCUCzbf/Vq
Content-Type: text/plain; charset=utf-8
Content-Disposition: inline
Content-Transfer-Encoding: quoted-printable

V=C2=A0Mon, Apr 10, 2023 at 01:29:41PM -0600,=C2=A0Nicolas Bock napsal(a):
> The following code is aligned incorrectly using indent-2.2.12:
>=20
> ```C
> #include <stdlib.h>
>=20
> #define TYPED(name) name ## _typed
>=20
> typedef void matrix_t;
>=20
> void TYPED (testfunc) (void)
> {
>   matrix_t*A =3D NULL;
>   matrix_t*B =3D NULL;
> }
>=20
> void testfunc (void)
> {
>   matrix_t*A =3D NULL;
>   matrix_t*B =3D NULL;
> }
> ```
>=20
> ```console
> indent -par test.c
> ```
>=20
> ```diff
> --- test.c      2023-04-10 13:21:00.516535705 -0600
> +++ test-2.2.12.c        2023-04-10 13:21:04.172585827 -0600
> @@ -6,12 +6,13 @@
>=20
>  void TYPED (testfunc) (void)
>  {
> -  matrix_t*A =3D NULL;
> -  matrix_t*B =3D NULL;
> +  matrix_t * A =3D NULL;
> +  matrix_t *B =3D NULL;
>  }
>=20
> -void testfunc (void)
> +void
> +testfunc (void)
>  {
> -  matrix_t*A =3D NULL;
> -  matrix_t*B =3D NULL;
> +  matrix_t *A =3D NULL;
> +  matrix_t *B =3D NULL;
>  }
> ```
>=20
> The pointer's indirection operator '*' for variable A is incorrectly
> aligned in the first function definition. This is a regression from
> indent-2.2.11.
>=20
I confirm it with 2.2.13. Because indent does not perform a macro expansion,
the reproducer can be reduced to:

/* If a function name is hidden with a parametrized macro, and a variable t=
ype
 * is not a built-in type, then a first variable definition with a pointer =
of
 * that type in the function block will have a star character misaligned.
 * (indent -par) */
void TYPED (foo) (void)
{
  bar *A =3D NULL;
  bar *B =3D NULL;
  bar *C =3D NULL;
}

-- Petr

--q1h9ZkiCUCzbf/Vq
Content-Type: application/pgp-signature; name="signature.asc"

-----BEGIN PGP SIGNATURE-----

iQIzBAABCAAdFiEE4/QvzhVoMKgDWObpT9GuwzZa978FAmQ2r9YACgkQT9GuwzZa
97/3iBAAu3t+E1gztucFGL1jZhG0HPC/BNTL4JtCJXb13BN3/AlxCvLPpzKxU8mf
mX2uMctzsf+jm1vuI0RUlTuheoFeCIGGyfssN8PMC4f9UK6x4NqOz3otWmqN9c6e
qRbLZOwXRZ8Dm4nup5ojFdNQNdqh94entNUlyATdSKjyygYmLWLH2kBQRUloRwha
S5iDtH5C+HXJjHppgQ/vnoZDAKGADho8bh0WOVat4UwIK5TR4RgFE1I1oo/2NHkn
4Is9AgyKOhEsbMBQXSA9P6prJKTZBXRRuzBpCX1BBnqMFpcEB3fc26nv7b9npcnd
242l7O7sD4SfmvT86ZejNludaGW2mOglVw7HDOELy0Ly8DN6RkYytQ+ue37H48oO
yxMZUu8RxfWhDupFFtUYnfQUKzpcgRSwPxjWEqlbK2HShsWxk9OYXiyoEHCL4j1t
QbRERQpJmLGwIft43FXP/Sgvkbr2aoFN9IR4OKC1G1cyGK9ytWTo1vqMJ7FoY85K
m0v1w7sZfnytiyN5z6+QaALw3DdK6SoDNuuX2PVQd1iwASMkfcWAhZNsz1TyCze5
CUwBj8DUloDrZP1Ctm2bLR2LbpXDz4rWQWx2cD4AAdVFlaFiIFALvMvyxde4phnQ
0wJvJJFOJkZBHtT4DciHnbK6HZqfPvk5P2mfsyk3btmeoLuXLKo=
=hkiz
-----END PGP SIGNATURE-----

--q1h9ZkiCUCzbf/Vq--