]> granicus.if.org Git - clang/commit
Diagnose attempts to apply ms_struct to records with base classes
authorJohn McCall <rjmccall@apple.com>
Thu, 27 Feb 2014 20:30:49 +0000 (20:30 +0000)
committerJohn McCall <rjmccall@apple.com>
Thu, 27 Feb 2014 20:30:49 +0000 (20:30 +0000)
commitf56a925b94bb24c056a8853ae168dbe1c38eb647
treee4bf99b1833347de48c66b5d4a731d0e2be53c16
parent04d3c8a09464f433b3d6ba46b6e658f537e73b89
Diagnose attempts to apply ms_struct to records with base classes
or virtual functions, but permit that error to be downgraded to
a warning (with -Wno-error=incompatible-ms-struct), and officially
support this kind of dual, ABI-mixing layout.

The basic problem here is that projects which use ms_struct are often
not very circumspect about what types they annotate; for example,
some projects enable the pragma in a prefix header and then only
selectively disable it around system header inclusions.  They may
only care about binary compatibility with MSVC for a subset of
those structs, but that doesn't mean they have no binary
compatibility concerns at all for the rest; thus we are essentially
forced into supporting this hybrid ABI.  But it's reasonable for
us to at least point out the places where we're not making
any guarantees.

The original diagnostic was for dynamic classes, i.e. those with
virtual functions or virtual bases; I've extended it to include
all classes with bases, because we are not actually making any
attempt to duplicate MSVC's base subobject layout in ms_struct
(and it is indeed quite different from Itanium, even for
non-virtual bases).

rdar://16178895

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@202427 91177308-0d34-0410-b5e6-96231b3b80d8
include/clang/Basic/DiagnosticGroups.td
include/clang/Basic/DiagnosticSemaKinds.td
lib/AST/RecordLayoutBuilder.cpp
lib/Sema/SemaDeclCXX.cpp
test/SemaCXX/ms_struct.cpp