c-decl.c (finish_struct): Add DECL_EXPR for variable sized structures seen inside functions.

* c-decl.c (finish_struct): Add DECL_EXPR for variable sized
        structures seen inside functions.

From-SVN: r92371
This commit is contained in:
Richard Henderson 2004-12-18 20:07:54 -08:00 committed by Richard Henderson
parent 8b0b9aefd2
commit ca6af4f857
3 changed files with 26 additions and 0 deletions

View File

@ -1,3 +1,8 @@
2004-12-18 Richard Henderson <rth@redhat.com>
* c-decl.c (finish_struct): Add DECL_EXPR for variable sized
structures seen inside functions.
2004-12-18 Richard Henderson <rth@redhat.com>
* c-decl.c (grokdeclarator): Save variable array size before

View File

@ -5401,6 +5401,12 @@ finish_struct (tree t, tree fieldlist, tree attributes)
/* Finish debugging output for this type. */
rest_of_type_compilation (t, toplevel);
/* If we're inside a function proper, i.e. not file-scope and not still
parsing parameters, then arrange for the size of a variable sized type
to be bound now. */
if (cur_stmt_list && variably_modified_type_p (t, NULL))
add_stmt (build_stmt (DECL_EXPR, build_decl (TYPE_DECL, NULL, t)));
return t;
}

View File

@ -0,0 +1,15 @@
extern void abort (void);
int test(int n)
{
struct s { char b[n]; };
n++;
return sizeof(struct s);
}
int main()
{
if (test(123) != 123)
abort ();
return 0;
}