From 507e6c242ced3c7f083edc1657092c9ff7a9c8f2 Mon Sep 17 00:00:00 2001 From: xleroy Date: Sat, 16 Apr 2011 09:16:26 +0000 Subject: cparser/Elab: __attribute, not attribute ia32/PrintAsm: wrong section name regression: added test attribs1 git-svn-id: https://yquem.inria.fr/compcert/svn/compcert/trunk@1636 fca1b0fc-160b-0410-b1d3-a4f43f01ea2e --- test/regression/Makefile | 2 +- test/regression/Results/attribs1 | 4 ++++ test/regression/attribs1.c | 39 +++++++++++++++++++++++++++++++++++++++ 3 files changed, 44 insertions(+), 1 deletion(-) create mode 100644 test/regression/Results/attribs1 create mode 100644 test/regression/attribs1.c (limited to 'test') diff --git a/test/regression/Makefile b/test/regression/Makefile index 377d2050..5de19cc2 100644 --- a/test/regression/Makefile +++ b/test/regression/Makefile @@ -8,7 +8,7 @@ LIBS=$(LIBMATH) # Can run and have reference output in Results -TESTS=bitfields1 bitfields2 bitfields3 bitfields4 \ +TESTS=attribs1 bitfields1 bitfields2 bitfields3 bitfields4 \ bitfields5 bitfields6 bitfields7 \ expr1 initializers volatile2 \ funct3 expr5 struct7 struct8 casts1 casts2 char1 \ diff --git a/test/regression/Results/attribs1 b/test/regression/Results/attribs1 new file mode 100644 index 00000000..e9954741 --- /dev/null +++ b/test/regression/Results/attribs1 @@ -0,0 +1,4 @@ +Address of a = 0 mod 16 +Address of b = 0 mod 8 +Delta d - c = 4 +Delta f - e = 4 diff --git a/test/regression/attribs1.c b/test/regression/attribs1.c new file mode 100644 index 00000000..21d7556c --- /dev/null +++ b/test/regression/attribs1.c @@ -0,0 +1,39 @@ +/* gcc-style "aligned" and "section" attributes */ + +/* Caveat: some C standard libraries, when preprocessed with -U__GNUC__, + #define away __attribute__, so we use __attribute in the following. */ + +#include + +/* Alignment */ + +char filler1 = 1; +__attribute((__aligned__(16))) int a = 1234; +char filler2 = 1; +__attribute((__aligned__(8))) char b = 'b'; + +/* Sections */ + +__attribute((__section__("mydata"))) int c = 78; +char filler3 = 1; +__attribute((__section__("mydata"))) int d = 90; + +__attribute((__section__("myconst"))) const int e = 12; +const char filler4 = 1; +__attribute((__section__("myconst"))) const int f = 34; + +__attribute((__section__("mycode"))) int myfunc(int x) { return x + 1; } + +/* Test harness */ + +int main() +{ + printf("Address of a = %u mod 16\n", ((unsigned int) &a) & 0xF); + printf("Address of b = %u mod 8\n", ((unsigned int) &b) & 0x7); + printf("Delta d - c = %u\n", ((unsigned int) &d) - ((unsigned int) &c)); + printf("Delta f - e = %u\n", ((unsigned int) &f) - ((unsigned int) &e)); + return 0; +} + + + -- cgit