This is an archive of the discontinued LLVM Phabricator instance.

Treat enumerator_too_large as an extension in MS ABI mode
AbandonedPublic

Authored by DaveBartolomeo on Jul 12 2016, 12:15 PM.

Details

Summary

When compiling as C targeting the MS ABI, but with -fno-ms-compatibility, an enumerator initializer that is not representable as an int is treated as an error. This is correct according to the C standard, but Clang already treats it as an extension both in -fms-compatibility mode and when compiling as C for non-MS ABI targets. It seemed odd that it would be treated as a hard error only in this one particular configuration, so I relaxed it to be an extension when targeting the MS ABI, regardless of MS compatibility mode.

There are dozens of occurrences of this issue in Windows SDK headers. By treating it as an extension, Clang users can include <windows.h> in a C program without having to use -fms-compatibility.

Diff Detail

Event Timeline

DaveBartolomeo retitled this revision from to Treat enumerator_too_large as an extension in MS ABI mode.
DaveBartolomeo updated this object.
DaveBartolomeo added reviewers: rnk, cfe-commits.
majnemer requested changes to this revision.Jul 12 2016, 12:44 PM
majnemer added a reviewer: majnemer.
majnemer added a subscriber: majnemer.

This requires an associated test case.

lib/Sema/SemaDecl.cpp
14354–14355

I would remove the getLangOpts().MSVCCompat.

This revision now requires changes to proceed.Jul 12 2016, 12:44 PM
rnk edited edge metadata.Jul 12 2016, 12:56 PM

I think this is just a consequence of https://llvm.org/bugs/show_bug.cgi?id=27098

We should just fix the underlying bug so that EnumDecl::isFixed() doesn't return true for plain enums in C or C++ when targeting Windows.

DaveBartolomeo abandoned this revision.Jul 15 2016, 1:35 PM

I'll attempt to fix the underlying issue https://llvm.org/bugs/show_bug.cgi?id=27098 instead.