diff options
author | Xavier Leroy <xavier.leroy@inria.fr> | 2016-10-06 09:49:50 +0200 |
---|---|---|
committer | Xavier Leroy <xavier.leroy@inria.fr> | 2016-10-06 09:49:50 +0200 |
commit | fecf2472ee5c2f6da25eb1ea340e0f07dcdaec69 (patch) | |
tree | 5bbe7afa05895ba7857b86e7c5d7d40c29076e1b /cfrontend/Initializersproof.v | |
parent | 67c58f9ee025fb2fc0de6d932366b7e5db7a6678 (diff) | |
download | compcert-fecf2472ee5c2f6da25eb1ea340e0f07dcdaec69.tar.gz compcert-fecf2472ee5c2f6da25eb1ea340e0f07dcdaec69.zip |
Regression: compile-time evaluation of ((struct s *)0)->field
This somewhat useful idiom was broken when Val.add was replaced by Val.offset_ptr in the Efield case. This commit restores the previous behavior.
This used to be supported (and is useful
Diffstat (limited to 'cfrontend/Initializersproof.v')
-rw-r--r-- | cfrontend/Initializersproof.v | 7 |
1 files changed, 4 insertions, 3 deletions
diff --git a/cfrontend/Initializersproof.v b/cfrontend/Initializersproof.v index 49ac858e..fee25c48 100644 --- a/cfrontend/Initializersproof.v +++ b/cfrontend/Initializersproof.v @@ -446,9 +446,10 @@ Proof. (* field struct *) rewrite H0 in CV. monadInv CV. unfold lookup_composite in EQ; rewrite H1 in EQ; monadInv EQ. exploit constval_rvalue; eauto. intro MV. inv MV. - simpl. replace x0 with delta by congruence. econstructor; eauto. - rewrite ! Ptrofs.add_assoc. f_equal. apply Ptrofs.add_commut. - simpl. auto. + replace x0 with delta by congruence. rewrite Ptrofs.add_assoc. rewrite (Ptrofs.add_commut (Ptrofs.repr delta0)). + simpl; destruct Archi.ptr64 eqn:SF; + econstructor; eauto; rewrite ! Ptrofs.add_assoc; f_equal; f_equal; symmetry; auto with ptrofs. + destruct Archi.ptr64; auto. (* field union *) rewrite H0 in CV. eauto. Qed. |