[Top][All Lists]

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [Tinycc-devel] missing check after calling type_size in classify_x86

From: Pascal Cuoq
Subject: Re: [Tinycc-devel] missing check after calling type_size in classify_x86_64_arg
Date: Sun, 23 Jun 2019 14:20:32 +0000

On 22 Jun 2019, at 21:16, Michael Matz <address@hidden> wrote:

struct s {
  char a;
  enum e b[];
} s;
struct t {
  int a[3];
  void b[];
} t;
typedef void u;
struct v {
  int a[3];
  u b[];
} v;
struct w {
  int a[3];
  struct n b[];
} w;

The thing to realize about all these invalid examples is, that it's not the struct decl which is wrong, i.e. you don't need to change anything within struct_decl or struct_layout.  It's already the array declarator itself which is wrong: an array declarator requires a complete element type.

So, what you want to change is post_type (which cares for array and function declarators, given a base type) so that the incoming type is complete if necessary.

So, pushing the previous stuff down the stack and investigating post_type, it is currently making a minimal effort to reject arrays of functions, and I tried to insert a better filter at the place where the check was (see attached patch). The new version continues to reject this example:

typedef void f(void);

f t[3];

(with a more generic message)
The new version also rejects all my previous examples quoted above, and the following, which is currently accepted because type->t is not masked in the current implementation:

const f t[3];

If this patch can be tweaked into something acceptable, I will also add tests for the new rejected constructs and validate the message change for the existing test.


Attachment: arrays_of_incomplete.patch
Description: arrays_of_incomplete.patch

reply via email to

[Prev in Thread] Current Thread [Next in Thread]