From dac45b5c091237cb7e8f723e75b3897a8f763432 Mon Sep 17 00:00:00 2001 From: Mark Mitchell Date: Fri, 11 Oct 2002 19:55:21 +0000 Subject: 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 --- gcc/cp/decl.c | 21 ++++++++------------- 1 file changed, 8 insertions(+), 13 deletions(-) (limited to 'gcc/cp/decl.c') 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 -- cgit v1.1