https://llvm.org/bugs/show_bug.cgi?id=24007

            Bug ID: 24007
           Summary: -Wmissing-braces warns on braces missing in
                    initializers expanded from macros in system headers
           Product: clang
           Version: trunk
          Hardware: PC
                OS: All
            Status: NEW
          Severity: normal
          Priority: P
         Component: Frontend
          Assignee: [email protected]
          Reporter: [email protected]
                CC: [email protected]
    Classification: Unclassified

Consider:

$ cat foo/a.h
#define REGISTRY_EXTENSION_GUID { 0x35378eac, 0x683f, 0x11d2, 0xa8, 0x9a, 0x00,
0xc0, 0x4f, 0xbb, 0xcf, 0xa2 }
$ cat test.cc
#include "a.h"

typedef struct _GUID {
  unsigned Data1;
  unsigned short  Data2;
  unsigned short  Data3;
  unsigned char Data4[8];
} GUID;

void f() {
  GUID g = REGISTRY_EXTENSION_GUID;
}
$ bin/clang test.cc -c -isystem foo -Wall
test.cc:11:12: warning: suggest braces around initialization of subobject
[-Wmissing-braces]
  GUID g = REGISTRY_EXTENSION_GUID;
           ^~~~~~~~~~~~~~~~~~~~~~~
foo/a.h:1:63: note: expanded from macro 'REGISTRY_EXTENSION_GUID'
#define REGISTRY_EXTENSION_GUID { 0x35378eac, 0x683f, 0x11d2, 0xa8, 0x9a, 0x00,
0xc0, 0x4f, 0xbb, 0xcf, 0xa2 }
                                                             
^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
test.cc:11:8: warning: unused variable 'g' [-Wunused-variable]
  GUID g = REGISTRY_EXTENSION_GUID;
       ^
2 warnings generated.


In real life, REGISTRY_EXTENSION_GUID comes from some Windows header, so
there's nothing the user can do about this. The warning shouldn't fire if the
rhs is a macro from a system header.

-- 
You are receiving this mail because:
You are on the CC list for the bug.
_______________________________________________
LLVMbugs mailing list
[email protected]
http://lists.cs.uiuc.edu/mailman/listinfo/llvmbugs

Reply via email to