This is the mail archive of the gcc-patches@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: Ping [PATCH] c++/42121 - diagnose invalid flexible array members


> 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


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]