diff options
author | Olivier Hainque <hainque@adacore.com> | 2006-10-06 09:12:09 +0000 |
---|---|---|
committer | Olivier Hainque <hainque@gcc.gnu.org> | 2006-10-06 09:12:09 +0000 |
commit | 706c4bb76caf0bf9cef5f12d94c9b52d9594e433 (patch) | |
tree | 27fdba5cec2529f809c49eb8024849092cb5d4d5 /gcc/gimplify.c | |
parent | 4d51dc9ec6c2b5e94031936baca7763d9c3b4f1c (diff) | |
download | gcc-706c4bb76caf0bf9cef5f12d94c9b52d9594e433.zip gcc-706c4bb76caf0bf9cef5f12d94c9b52d9594e433.tar.gz gcc-706c4bb76caf0bf9cef5f12d94c9b52d9594e433.tar.bz2 |
gimplify.c (gimplify_type_sizes): Don't recurse on the pointed-to type.
* gimplify.c (gimplify_type_sizes) [POINTER_TYPE, REFERENCE_TYPE]:
Don't recurse on the pointed-to type.
* c-decl.c (grokdeclarator) [cdk_pointer]: If we are in a NORMAL or
DECL context, attach an artificial TYPE_DECL to anonymous pointed-to
types with components of variable size.
* testsuite/gcc.dg/typename-vla-1.c: New case.
* testsuite/gnat.dg/forward_vla.adb: New case.
From-SVN: r117493
Diffstat (limited to 'gcc/gimplify.c')
-rw-r--r-- | gcc/gimplify.c | 13 |
1 files changed, 12 insertions, 1 deletions
diff --git a/gcc/gimplify.c b/gcc/gimplify.c index 84c7219..faa5b48 100644 --- a/gcc/gimplify.c +++ b/gcc/gimplify.c @@ -6043,7 +6043,18 @@ gimplify_type_sizes (tree type, tree *list_p) case POINTER_TYPE: case REFERENCE_TYPE: - gimplify_type_sizes (TREE_TYPE (type), list_p); + /* We used to recurse on the pointed-to type here, which turned out to + be incorrect because its definition might refer to variables not + yet initialized at this point if a forward declaration is involved. + + It was actually useful for anonymous pointed-to types to ensure + that the sizes evaluation dominates every possible later use of the + values. Restricting to such types here would be safe since there + is no possible forward declaration around, but would introduce a + undesireable middle-end semantic to anonymity. We then defer to + front-ends the responsibilty of ensuring that the sizes are + evaluated both early and late enough, e.g. by attaching artifical + type declarations to the tree. */ break; default: |