~mcf/cproc#73: 
Incomplete enum is not caught in struct field

6.7.2.3p3 - A type specifier of the form enum identifier without an enumerator list shall only appear after the type it specifies is complete.

From what I understand out of this, enum identifier; syntax is only valid when used as type for a variable/field/etc. Using enum identifier; as a declaration makes it incomplete. cproc does catch when such an enum is used as a function argument type or a variable but not when used as return type or struct field. Both GCC and Clang error out when using it in either places.

Example (compiles fine on latest cproc):

/* Incomplete enum */
enum fruit;

struct wrapper {
	/* Does not raise compile error */
	enum fruit f;
};

void
make_fruit(struct wrapper w)
{
	// ...
}

enum fruit {
	FRUIT_APPLE,
	FRUIT_BANANA,
};
Status
RESOLVED FIXED
Submitter
~yerinalexey
Assigned to
No-one
Submitted
4 months ago
Updated
4 months ago
Labels
No labels applied.

~mcf REPORTED FIXED 4 months ago

Thanks for the report. This is fixed in eb4320fc.

I also added a few other checks to make sure that structs have at least one member and the flexible array member (if present) is last.

Register here or Log in to comment, or comment via email.