OSDN Git Service

* decl.c (grokdeclarator): Reject VLAs as members.
authorloewis <loewis@138bc75d-0d04-0410-961f-82ee72b054a4>
Tue, 25 Apr 2000 05:59:26 +0000 (05:59 +0000)
committerloewis <loewis@138bc75d-0d04-0410-961f-82ee72b054a4>
Tue, 25 Apr 2000 05:59:26 +0000 (05:59 +0000)
git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@33399 138bc75d-0d04-0410-961f-82ee72b054a4

gcc/cp/ChangeLog
gcc/cp/decl.c

index 295be19..bf5b8a9 100644 (file)
@@ -1,3 +1,7 @@
+2000-04-25  Martin v. Löwis  <loewis@informatik.hu-berlin.de>
+
+       * decl.c (grokdeclarator): Reject VLAs as members.
+
 2000-04-24  Gabriel Dos Reis  <gdr@codesourcery.com>
 
        * call.c (standard_conversion): Accept conversion between
index 8a618b5..5b95920 100644 (file)
@@ -10352,6 +10352,20 @@ grokdeclarator (declarator, declspecs, decl_context, initialized, attrlist)
            declarator = TREE_OPERAND (declarator, 0);
 
            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))))
+             {
+               cp_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;