Issue 177607
Summary [Clang] Add CC1 option to enable Microsoft anonymous struct/union extensions
Labels clang
Assignees
Reporter riyaz86a
    Add a new internal CC1 option `-fms-anonymous-structs` to enable Microsoft anonymous struct/union support independently from `-fms-extensions`. 

This is needed to support code that uses anonymous structs extensively while avoiding conflicts with other Microsoft extensions (particularly `__ptr32`/`__ptr64` keywords).

The following program demonstrates this issue:

```
#include<stdio.h>
struct wInode
{
    int x;
};
struct inode {
    struct wInode;
};
int main()
{
    struct inode p;
    p.x = 20;
    printf ("%d\n",p.x);
        return 0;
}


# clang  -m64 -pthread -o out unnamed_struct.c -fms-extensions
In file included from unnamed_struct.c:1:
In file included from /usr/include/stdio.h:482:
/usr/include/sys/types.h:260:9: error: '__ptr32' attribute only applies to pointer arguments
  260 | typedef __ptr32 mid_t;          /* module ID    */
      | ^
/usr/include/sys/types.h:551:23: error: expected identifier or '('
  551 | typedef void * __ptr64;
      | ^
unnamed_struct.c:9:2: warning: anonymous structs are a Microsoft extension [-Wmicrosoft-anon-tag]
    9 |         struct wInode;  
      | ^
1 warning and 2 errors generated.
```

**Desired Behavior**:
Enable only the anonymous struct and union feature from Microsoft extensions.
_______________________________________________
llvm-bugs mailing list
[email protected]
https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-bugs

Reply via email to