[cfe-dev] [PATCH] fix for bug 7857 - incomplete type as array parameter in C mode

Francois Pichet pichet2000 at gmail.com
Wed Aug 18 03:18:12 PDT 2010


Hi,

Last week I raised CR 7857. Basically clang rejects the following code
in C mode (-x -c):
typedef struct type TYPE;
void foo(TYPE p[]); <=== incomplete type error.

After reading the C99 spec, clang is probably right to reject that
code. Comeau also rejects it in strict mode (but accept it in relaxed
mode).
But both gcc and msvc accept the above code.
This error is preventing clang from compile <Windows.h> in C mode.

Here is a tentative patch to get around the problem.
What I did is to issue a warning instead of an error when
    - within function prototype scope
 AND
    - building an array type of type T
 AND
    - T is an incomplete struct type.

At least the warning won't prevent the compilation from succeeding.

is that ok?
-------------- next part --------------
A non-text attachment was scrubbed...
Name: incomplete_struct_array_param.patch
Type: application/octet-stream
Size: 2423 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/cfe-dev/attachments/20100818/e2afa324/attachment.obj>


More information about the cfe-dev mailing list