This is the mail archive of the
gcc-patches@gcc.gnu.org
mailing list for the GCC project.
Re: Ping [PATCH] c++/42121 - diagnose invalid flexible array members
- From: Bernd Schmidt <bschmidt at redhat dot com>
- To: Martin Sebor <msebor at gmail dot com>, Gcc Patch List <gcc-patches at gcc dot gnu dot org>, Jason Merrill <jason at redhat dot com>, "Joseph S. Myers" <joseph at codesourcery dot com>
- Date: Fri, 4 Dec 2015 12:33:27 +0100
- Subject: Re: Ping [PATCH] c++/42121 - diagnose invalid flexible array members
- Authentication-results: sourceware.org; auth=none
- References: <5650ED6B dot 2040404 at gmail dot com> <566119C6 dot 8020201 at gmail dot com>
> The patch should bring C++ support for flexible array members closer
> to C (most of the same constructs should be accepted and rejected).
> The only C change in this patch is to include the size of excessively
> large types in diagnostics (I found knowing the size helpful when
> adding tests and I think it might be helpful to others as well).
Can't really comment on the C++ parts, but I spotted some formatting issues.
+ && TREE_CODE (type) != ERROR_MARK
+ && (DECL_NAME (fld) || RECORD_OR_UNION_TYPE_P (type)))
+ {
+
+ return TYPE_SIZE (type)
+ && (TREE_CODE (TYPE_SIZE (type)) != INTEGER_CST
+ || !tree_int_cst_equal (size_zero_node, TYPE_SIZE (type)));
Unnecessary blank line. Multi-line expressions should be wrapped in
parentheses for indentation. Lose braces around single statements.
+ a flexible array member or a zero-size array.
+*/
Comment terminators go at the end of the line.
+ tree size_max_node =
+ int_const_binop (MINUS_EXPR, size_zero_node, size_one_node);
The = operator should start the line.
+ tree flexarray =
+ check_flexarrays (t, TYPE_FIELDS (fldtype), seen_field);
Here too.
+ {
+ bool dummy = false;
+ check_flexarrays (t, TYPE_FIELDS (t), &dummy);
+ }
No reason to wrap this in braces.
+ if (NULL_TREE == size)
+ return build_index_type (NULL_TREE);
Don't know whether the conventions in cp/ are different, but usually
this is "size == NULL_TREE".
+ pedwarn (input_location, OPT_Wpedantic,
+ "ISO C++ forbids zero-size arrays");
}
+
}
Extra blank line.
@@ -11082,6 +11094,10 @@ grokdeclarator (const cp_declarator *declarator,
|| !COMPLETE_TYPE_P (TREE_TYPE (type))
|| initialized == 0))
{
+ if (TREE_CODE (type) != ARRAY_TYPE
+ || !COMPLETE_TYPE_P (TREE_TYPE (type)))
+ {
+
if (unqualified_id)
Here too.
Bernd