From ce4951549999f403446415c135ad1403a16a15c3 Mon Sep 17 00:00:00 2001 From: xleroy Date: Mon, 12 Nov 2012 13:42:22 +0000 Subject: Globalenvs: allocate one-byte block with permissions Nonempty for each function definition, so that comparisons between function pointers are correctly defined. AST, Globalenvs, and many other files: represent programs as a list of (function or variable) definitions instead of two lists, one for functions and the other for variables. git-svn-id: https://yquem.inria.fr/compcert/svn/compcert/trunk@2067 fca1b0fc-160b-0410-b1d3-a4f43f01ea2e --- test/regression/Makefile | 2 +- test/regression/Results/funptr2 | 3 +++ test/regression/Results/initializers | 1 + test/regression/funptr2.c | 14 ++++++++++++++ test/regression/initializers.c | 3 +++ 5 files changed, 22 insertions(+), 1 deletion(-) create mode 100644 test/regression/Results/funptr2 create mode 100644 test/regression/funptr2.c (limited to 'test/regression') diff --git a/test/regression/Makefile b/test/regression/Makefile index a649f88..e8fb236 100644 --- a/test/regression/Makefile +++ b/test/regression/Makefile @@ -9,7 +9,7 @@ LIBS=$(LIBMATH) TESTS=attribs1 bitfields1 bitfields2 bitfields3 bitfields4 \ bitfields5 bitfields6 bitfields7 \ - expr1 expr6 initializers volatile1 volatile2 volatile3 \ + expr1 expr6 funptr2 initializers volatile1 volatile2 volatile3 \ funct3 expr5 struct7 struct8 struct11 casts1 casts2 char1 \ sizeof1 sizeof2 packedstruct1 packedstruct2 \ instrsel bool compar diff --git a/test/regression/Results/funptr2 b/test/regression/Results/funptr2 new file mode 100644 index 0000000..f364c59 --- /dev/null +++ b/test/regression/Results/funptr2 @@ -0,0 +1,3 @@ +f == f is 1 +f == g is 0 +f + 1 == f is 0 diff --git a/test/regression/Results/initializers b/test/regression/Results/initializers index d3fc91a..7474148 100644 --- a/test/regression/Results/initializers +++ b/test/regression/Results/initializers @@ -1,3 +1,4 @@ +x0 = 0 x1 = 'x' x2 = 12345 x3 = 3.14159 diff --git a/test/regression/funptr2.c b/test/regression/funptr2.c new file mode 100644 index 0000000..5c31dd2 --- /dev/null +++ b/test/regression/funptr2.c @@ -0,0 +1,14 @@ +/* Comparisons of pointers to functions */ + +#include + +int f(void) { return 0; } +int g(void) { return 1; } + +int main(void) { + printf ("f == f is %d\n", &f == &f); + printf ("f == g is %d\n", &f == &g); + /* The following is undefined behavior */ + printf ("f + 1 == f is %d\n", ((char *) &f) + 1 == (char *) &f); + return 0; +} diff --git a/test/regression/initializers.c b/test/regression/initializers.c index f831c67..d0a35f3 100644 --- a/test/regression/initializers.c +++ b/test/regression/initializers.c @@ -1,5 +1,7 @@ #include +int x0; + char x1 = 'x'; int x2 = 12345; @@ -67,6 +69,7 @@ int main() { int i; + printf("x0 = %d\n", x0); printf("x1 = '%c'\n", x1); printf("x2 = %d\n", x2); printf("x3 = %.5f\n", x3); -- cgit v1.2.3