diff options
author | Mark Mitchell <mark@codesourcery.com> | 2002-10-11 19:55:21 +0000 |
---|---|---|
committer | Mark Mitchell <mmitchel@gcc.gnu.org> | 2002-10-11 19:55:21 +0000 |
commit | dac45b5c091237cb7e8f723e75b3897a8f763432 (patch) | |
tree | 4a570b2a83e5295f39745305c4a521b00d6df0f7 /gcc/cp/decl.c | |
parent | 46dd38849ba39f228f467edab38cfd60e6809b6e (diff) | |
download | gcc-dac45b5c091237cb7e8f723e75b3897a8f763432.zip gcc-dac45b5c091237cb7e8f723e75b3897a8f763432.tar.gz gcc-dac45b5c091237cb7e8f723e75b3897a8f763432.tar.bz2 |
re PR c++/5661 (Gcc 3.0.3 Seg faults compiling bad code)
PR c++/5661
* cp-tree.h (variably_modified_type_p): New function.
(grokdeclarator) Tighten check for variably modified types as
fields.
* pt.c (convert_template_argument): Do not allow variably modified
types as template arguments.
* tree.c (variably_modified_type_p): New function.
PR c++/5661
* g++.dg/ext/vlm1.C: New test.
* g++.dg/ext/vlm2.C: Likewise.
From-SVN: r58060
Diffstat (limited to 'gcc/cp/decl.c')
-rw-r--r-- | gcc/cp/decl.c | 21 |
1 files changed, 8 insertions, 13 deletions
diff --git a/gcc/cp/decl.c b/gcc/cp/decl.c index f8202b4..4401954 100644 --- a/gcc/cp/decl.c +++ b/gcc/cp/decl.c @@ -10928,19 +10928,6 @@ grokdeclarator (declarator, declspecs, decl_context, initialized, attrlist) type = create_array_type_for_decl (dname, type, size); - /* VLAs never work as fields. */ - if (decl_context == FIELD && !processing_template_decl - && TREE_CODE (type) == ARRAY_TYPE - && TYPE_DOMAIN (type) != NULL_TREE - && !TREE_CONSTANT (TYPE_MAX_VALUE (TYPE_DOMAIN (type)))) - { - error ("size of member `%D' is not constant", dname); - /* Proceed with arbitrary constant size, so that offset - computations don't get confused. */ - type = create_array_type_for_decl (dname, TREE_TYPE (type), - integer_one_node); - } - ctype = NULL_TREE; } break; @@ -11420,6 +11407,14 @@ grokdeclarator (declarator, declspecs, decl_context, initialized, attrlist) type = error_mark_node; } + if (decl_context == FIELD + && !processing_template_decl + && variably_modified_type_p (type)) + { + error ("data member may not have variably modified type `%T'", type); + type = error_mark_node; + } + if (explicitp == 1 || (explicitp && friendp)) { /* [dcl.fct.spec] The explicit specifier shall only be used in |