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: [C++ PATCH] Fix 11614


Jason Merrill <jason@redhat.com> writes:

| On Tue, 22 Jul 2003 18:49:58 +0100, Nathan Sidwell <nathan@codesourcery.com> wrote:
| 
| > Jason Merrill wrote:
| >> I think it's simpler to defer handling this until we've parsed the whole
| >> declarator.  Here's a patch I haven't gotten around to testing yet:
| >
| >>         }
| >>       else if (decl_context == FIELD)
| >>         {
| >> + 	/* The C99 flexible array extension.  */
| >> + 	if (!staticp && TREE_CODE (type) == ARRAY_TYPE
| >> + 	    && TYPE_DOMAIN (type) == NULL_TREE)
| >> + 	  {
| >> + 	    tree itype = compute_array_index_type (dname, integer_zero_node);
| >> + 	    type = build_cplus_array_type (TREE_TYPE (type), itype);
| >> + 	  }
| >> +   	if (type == error_mark_node)
| >>   	  {
| >>   	    /* Happens when declaring arrays of sizes which
| > What about
| > 	typedef int ary_t[];
| > 	struct { ary_t s; };
| > ? I think you'll be allowing that.
| 
| Yep.  From C99:
| 
|        As a special case, the last  element  of  a  structure
|        with more than one named member may have an incomplete array
|        type.  This is called a flexible array member...

Humm, however, that sort of conflicts with C++:

   typedef int ary_t[]; 

makes ary_t denote an incomplete type, therefore

     struct { ary_t s; };

should be ill-formed.

3.9/6

  A class that has been declared but not defined, or an array of
  unknown size or of incomplete element type, is an
  incompletely-defined object type.38) Incompletely-defined object
  types and the void types are incomplete types (3.9.1). Objects
  shall not be defined to have an incomplete type. 


-- Gaby


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