diff options
author | xleroy <xleroy@fca1b0fc-160b-0410-b1d3-a4f43f01ea2e> | 2010-03-13 08:30:06 +0000 |
---|---|---|
committer | xleroy <xleroy@fca1b0fc-160b-0410-b1d3-a4f43f01ea2e> | 2010-03-13 08:30:06 +0000 |
commit | c0ff75a787c9b56699722fa672e76c97acfe93b5 (patch) | |
tree | 81eb50633cfa4b3ddfff0dc5dc1124cbc9fa55bd | |
parent | 2bdad21e991cc6fe720635e561eb2ae9728d1986 (diff) | |
download | compcert-c0ff75a787c9b56699722fa672e76c97acfe93b5.tar.gz compcert-c0ff75a787c9b56699722fa672e76c97acfe93b5.zip |
Bug in multidimensional read-only arrays
git-svn-id: https://yquem.inria.fr/compcert/svn/compcert/trunk@1290 fca1b0fc-160b-0410-b1d3-a4f43f01ea2e
-rw-r--r-- | cfrontend/C2Clight.ml | 15 | ||||
-rw-r--r-- | test/regression/pragmas.c | 2 |
2 files changed, 10 insertions, 7 deletions
diff --git a/cfrontend/C2Clight.ml b/cfrontend/C2Clight.ml index fb939a40..1be7aaea 100644 --- a/cfrontend/C2Clight.ml +++ b/cfrontend/C2Clight.ml @@ -764,13 +764,14 @@ let convertProgram p = (** ** Extracting information about global variables from their atom *) -let type_is_readonly env t = - let a1 = Cutil.attributes_of_type env t in - let a = - match Cutil.unroll env t with - | C.TArray(ty, _, _) -> a1 @ Cutil.attributes_of_type env ty - | _ -> a1 in - List.mem C.AConst a && not (List.mem C.AVolatile a) +let rec type_is_readonly env t = + let a = Cutil.attributes_of_type env t in + if List.mem C.AVolatile a then false else + if List.mem C.AConst a then true else + match Cutil.unroll env t with + | C.TArray(t', _, _) -> type_is_readonly env t' + | _ -> false + end let atom_is_static a = try diff --git a/test/regression/pragmas.c b/test/regression/pragmas.c index 43daa32a..36361cdb 100644 --- a/test/regression/pragmas.c +++ b/test/regression/pragmas.c @@ -35,11 +35,13 @@ int f(int n) /* Redefining some standard sections */ #pragma section SCONST ".myconst" ".myconst" far-absolute R +#pragma section CONST ".myconst" ".myconst" far-absolute R #pragma section DATA ".mysda_i" ".mysda_u" near-data RW #pragma section CODE ".mycode" ".mycode" standard RX const double v = 1.414; int w[10]; +const char t[5][5] = { 1, 2, 3 }; double h(int n) { |