From dbad64cf34ba43b24dc2d71bd260f137acc37ea5 Mon Sep 17 00:00:00 2001 From: Ernestas Kulik Date: Sat, 25 Jan 2020 18:44:11 +0100 Subject: tests: Prevent multiple-definition of symbols With GCC 10, -fno-common becomes default behavior, meaning that any subtly-broken code will be broken not so subtly anymore. This commit changes the linkage to variables declared in headers to external and, where needed, adds additional definitions in other compilation units. --- test cases/common/219 source set configuration_data/all.h | 6 ++++-- test cases/common/219 source set configuration_data/f.c | 2 ++ test cases/common/220 source set dictionary/all.h | 6 ++++-- test cases/common/220 source set dictionary/f.c | 2 ++ test cases/common/68 build always/version.h | 2 +- test cases/common/69 vcstag/tagprog.c | 2 +- 6 files changed, 14 insertions(+), 6 deletions(-) diff --git a/test cases/common/219 source set configuration_data/all.h b/test cases/common/219 source set configuration_data/all.h index 728a7f652..e3547dfdc 100644 --- a/test cases/common/219 source set configuration_data/all.h +++ b/test cases/common/219 source set configuration_data/all.h @@ -3,5 +3,7 @@ extern void g(void); extern void h(void); extern void undefined(void); -/* No extern here to get a common symbol */ -void (*p)(void); +/* Defined in nope.c and f.c, + * value depends on the source set and configuration used. + */ +extern void (*p)(void); diff --git a/test cases/common/219 source set configuration_data/f.c b/test cases/common/219 source set configuration_data/f.c index a50ecda32..33d2f18f0 100644 --- a/test cases/common/219 source set configuration_data/f.c +++ b/test cases/common/219 source set configuration_data/f.c @@ -1,5 +1,7 @@ #include "all.h" +void (*p)(void) = (void *)0x12AB34CD; + void f(void) { } diff --git a/test cases/common/220 source set dictionary/all.h b/test cases/common/220 source set dictionary/all.h index 728a7f652..e3547dfdc 100644 --- a/test cases/common/220 source set dictionary/all.h +++ b/test cases/common/220 source set dictionary/all.h @@ -3,5 +3,7 @@ extern void g(void); extern void h(void); extern void undefined(void); -/* No extern here to get a common symbol */ -void (*p)(void); +/* Defined in nope.c and f.c, + * value depends on the source set and configuration used. + */ +extern void (*p)(void); diff --git a/test cases/common/220 source set dictionary/f.c b/test cases/common/220 source set dictionary/f.c index a50ecda32..9c5bb1cb9 100644 --- a/test cases/common/220 source set dictionary/f.c +++ b/test cases/common/220 source set dictionary/f.c @@ -1,5 +1,7 @@ #include "all.h" +void (*p)(void) = (void *)0x1234ABCD; + void f(void) { } diff --git a/test cases/common/68 build always/version.h b/test cases/common/68 build always/version.h index d3fe5c695..7d433f035 100644 --- a/test cases/common/68 build always/version.h +++ b/test cases/common/68 build always/version.h @@ -1,3 +1,3 @@ #pragma once -const char *version_string; +extern const char *version_string; diff --git a/test cases/common/69 vcstag/tagprog.c b/test cases/common/69 vcstag/tagprog.c index 19b775456..27c3cc58d 100644 --- a/test cases/common/69 vcstag/tagprog.c +++ b/test cases/common/69 vcstag/tagprog.c @@ -1,6 +1,6 @@ #include -const char *vcstag; +extern const char *vcstag; int main(void) { printf("Version is %s\n", vcstag); -- cgit v1.2.3