diff options
author | xleroy <xleroy@fca1b0fc-160b-0410-b1d3-a4f43f01ea2e> | 2011-04-16 09:16:26 +0000 |
---|---|---|
committer | xleroy <xleroy@fca1b0fc-160b-0410-b1d3-a4f43f01ea2e> | 2011-04-16 09:16:26 +0000 |
commit | 507e6c242ced3c7f083edc1657092c9ff7a9c8f2 (patch) | |
tree | 9f0a60c471493d25dd930dde79f0a15348d57dc7 /test | |
parent | abb6fbfe333173acfeeb9304f9c529778e58ff1c (diff) |
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
Diffstat (limited to 'test')
-rw-r--r-- | test/regression/Makefile | 2 | ||||
-rw-r--r-- | test/regression/Results/attribs1 | 4 | ||||
-rw-r--r-- | test/regression/attribs1.c | 39 |
3 files changed, 44 insertions, 1 deletions
diff --git a/test/regression/Makefile b/test/regression/Makefile index 377d205..5de19cc 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 0000000..e995474 --- /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 0000000..21d7556 --- /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 <stdio.h> + +/* 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; +} + + + |