aboutsummaryrefslogtreecommitdiff
path: root/gcc
diff options
context:
space:
mode:
authorMartin v. Löwis <loewis@informatik.hu-berlin.de>2000-04-25 05:59:26 +0000
committerMartin v. Löwis <loewis@gcc.gnu.org>2000-04-25 05:59:26 +0000
commitc1b177ec68c6b088673a40584e4c204b3381c71f (patch)
treefd7e24782b89720c594f5f91f0d7a5abd89340cc /gcc
parentaabb6c7408f8d51575e9cdaac5e9296d82d27b52 (diff)
downloadgcc-c1b177ec68c6b088673a40584e4c204b3381c71f.zip
gcc-c1b177ec68c6b088673a40584e4c204b3381c71f.tar.gz
gcc-c1b177ec68c6b088673a40584e4c204b3381c71f.tar.bz2
* decl.c (grokdeclarator): Reject VLAs as members.
From-SVN: r33399
Diffstat (limited to 'gcc')
-rw-r--r--gcc/cp/ChangeLog4
-rw-r--r--gcc/cp/decl.c14
2 files changed, 18 insertions, 0 deletions
diff --git a/gcc/cp/ChangeLog b/gcc/cp/ChangeLog
index 295be19..bf5b8a9 100644
--- a/gcc/cp/ChangeLog
+++ b/gcc/cp/ChangeLog
@@ -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
diff --git a/gcc/cp/decl.c b/gcc/cp/decl.c
index 8a618b5..5b959205 100644
--- a/gcc/cp/decl.c
+++ b/gcc/cp/decl.c
@@ -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;