From 98b2d43c2bd03be06da700b1f9dd4cac0ebf3f4c Mon Sep 17 00:00:00 2001 From: mrdudz Date: Wed, 22 Jul 2020 15:52:04 +0200 Subject: [PATCH] added tests related to pr #1110 --- test/err/pr1110.c | 15 +++++++++++++++ test/val/pr1110a.c | 19 +++++++++++++++++++ 2 files changed, 34 insertions(+) create mode 100644 test/err/pr1110.c create mode 100644 test/val/pr1110a.c diff --git a/test/err/pr1110.c b/test/err/pr1110.c new file mode 100644 index 000000000..86955c720 --- /dev/null +++ b/test/err/pr1110.c @@ -0,0 +1,15 @@ + +/* pr #1110 - not only should the current test case for #975 compile and work, + * but also the code piece below fail to compile and generate errors like commented: */ + +static const unsigned char array[3]; /* OK */ +static const unsigned char array[] = { 0, 1, 2 }; /* OK - complete definition*/ +static const unsigned char array[3]; /* OK */ +static const unsigned char array[]; /* OK */ +static const unsigned char array[] = { 1, 2, 3 }; /* Error - redefinition */ +static const unsigned char array[4]; /* Error - conflicting size */ + +int main(void) +{ + return 0; +} diff --git a/test/val/pr1110a.c b/test/val/pr1110a.c new file mode 100644 index 000000000..0e0d91f85 --- /dev/null +++ b/test/val/pr1110a.c @@ -0,0 +1,19 @@ + +/* pr #1110 - the part of the redefinition that should compile */ + +static const unsigned char array[3]; /* OK */ +static const unsigned char array[] = { 0, 1, 2 }; /* OK - complete definition*/ +static const unsigned char array[3]; /* OK */ +static const unsigned char array[]; /* OK */ + +#include +#include + +int main(void) +{ + printf("%u %u %u\n", array[0], array[1], array[2]); + if ((array[0] != 0) || (array[1] != 1) || (array[2] != 2)) { + return EXIT_FAILURE; + } + return EXIT_SUCCESS; +}