<div dir="ltr">I verified that this is due to this change. I filed <a href="https://llvm.org/bugs/show_bug.cgi?id=27666">https://llvm.org/bugs/show_bug.cgi?id=27666</a> with a reduced repro and reverted this change in r268736.</div><div class="gmail_extra"><br><div class="gmail_quote">On Fri, May 6, 2016 at 9:52 AM, Nico Weber <span dir="ltr"><<a href="mailto:thakis@chromium.org" target="_blank">thakis@chromium.org</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div dir="ltr"><div>We're getting this crash now with a regression range of 268724:268729 -- i.e. almost certainly this change:</div><div><br></div><div>FAILED: obj/net/dns/net.mdns_client.obj </div><div>ninja -t msvc -e environment.x64 -- "..\..\third_party/llvm-build/Release+Asserts/bin/clang-cl" -m64 /nologo /showIncludes /FC @obj\net\dns\net.mdns_client.obj.rsp /c ..\..\net\dns\mdns_client.cc /Foobj\net\dns\net.mdns_client.obj /Fdobj\net\net.cc.pdb </div><div>In file included from ..\..\net\dns\mdns_client.cc:11:</div><div>In file included from ..\..\net/dns/mdns_client_impl.h:26:</div><div>In file included from ..\..\net/udp/udp_server_socket.h:13:</div><div>In file included from ..\..\net/udp/udp_socket.h:11:</div><div>In file included from ..\..\net/udp/udp_socket_win.h:8:</div><div>In file included from C:\b\depot_tools\win_toolchain\vs_files\95ddda401ec5678f15eeed01d2bee08fcbc5ee97\win_sdk\bin\..\..\win_sdk\Include\10.0.10586.0\um\qos2.h:23:</div><div>C:\b\depot_tools\win_toolchain\vs_files\95ddda401ec5678f15eeed01d2bee08fcbc5ee97\win_sdk\bin\..\..\win_sdk\Include\10.0.10586.0\shared\mstcpip.h(588,13): error: no matching constructor for initialization of 'IN_ADDR' (aka 'in_addr')</div><div> IN_ADDR Ipv4Address = *a;</div><div> ^ ~~</div><div>Assertion failed: CVR && "unexpected qualifiers mismatch", file C:\b\build\slave\ClangToTWin64\build\src\third_party\llvm\tools\clang\lib\Sema\SemaOverload.cpp, line 9118</div><div><br></div><div>Can you revert again? Should be easy to repro, just include <qos2.h> in a cc file and compile that. Let me know if you need help reproducing.</div></div><div class="HOEnZb"><div class="h5"><div class="gmail_extra"><br><div class="gmail_quote">On Fri, May 6, 2016 at 7:47 AM, Andrey Bokhanko via cfe-commits <span dir="ltr"><<a href="mailto:cfe-commits@lists.llvm.org" target="_blank">cfe-commits@lists.llvm.org</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">Author: asbokhan<br>
Date: Fri May 6 06:47:55 2016<br>
New Revision: 268727<br>
<br>
URL: <a href="http://llvm.org/viewvc/llvm-project?rev=268727&view=rev" rel="noreferrer" target="_blank">http://llvm.org/viewvc/llvm-project?rev=268727&view=rev</a><br>
Log:<br>
[MSVC] Implementation of __unaligned as a proper type qualifier<br>
<br>
This patch implements __unaligned (MS extension) as a proper type qualifier<br>
(before that, it was implemented as an ignored attribute).<br>
<br>
It also fixes PR27367.<br>
<br>
Differential Revision: <a href="http://reviews.llvm.org/D19654" rel="noreferrer" target="_blank">http://reviews.llvm.org/D19654</a><br>
<br>
Modified:<br>
cfe/trunk/include/clang/AST/Type.h<br>
cfe/trunk/include/clang/Basic/AddressSpaces.h<br>
cfe/trunk/include/clang/Basic/Attr.td<br>
cfe/trunk/include/clang/Sema/DeclSpec.h<br>
cfe/trunk/include/clang/Sema/Sema.h<br>
cfe/trunk/lib/AST/MicrosoftMangle.cpp<br>
cfe/trunk/lib/AST/TypePrinter.cpp<br>
cfe/trunk/lib/Parse/ParseDecl.cpp<br>
cfe/trunk/lib/Parse/ParseTentative.cpp<br>
cfe/trunk/lib/Sema/DeclSpec.cpp<br>
cfe/trunk/lib/Sema/SemaCodeComplete.cpp<br>
cfe/trunk/lib/Sema/SemaDecl.cpp<br>
cfe/trunk/lib/Sema/SemaDeclObjC.cpp<br>
cfe/trunk/lib/Sema/SemaExpr.cpp<br>
cfe/trunk/lib/Sema/SemaOverload.cpp<br>
cfe/trunk/lib/Sema/SemaType.cpp<br>
cfe/trunk/test/CodeGenCXX/mangle-ms-cxx11.cpp<br>
cfe/trunk/test/CodeGenCXX/mangle-ms-cxx14.cpp<br>
cfe/trunk/test/Sema/MicrosoftExtensions.c<br>
cfe/trunk/test/Sema/address_spaces.c<br>
cfe/trunk/test/Sema/invalid-assignment-constant-address-space.c<br>
cfe/trunk/test/SemaCXX/MicrosoftExtensions.cpp<br>
<br>
Modified: cfe/trunk/include/clang/AST/Type.h<br>
URL: <a href="http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/AST/Type.h?rev=268727&r1=268726&r2=268727&view=diff" rel="noreferrer" target="_blank">http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/AST/Type.h?rev=268727&r1=268726&r2=268727&view=diff</a><br>
==============================================================================<br>
--- cfe/trunk/include/clang/AST/Type.h (original)<br>
+++ cfe/trunk/include/clang/AST/Type.h Fri May 6 06:47:55 2016<br>
@@ -152,8 +152,8 @@ public:<br>
<br>
enum {<br>
/// The maximum supported address space number.<br>
- /// 24 bits should be enough for anyone.<br>
- MaxAddressSpace = 0xffffffu,<br>
+ /// 23 bits should be enough for anyone.<br>
+ MaxAddressSpace = 0x7fffffu,<br>
<br>
/// The width of the "fast" qualifier mask.<br>
FastWidth = 3,<br>
@@ -265,6 +265,13 @@ public:<br>
Mask |= mask;<br>
}<br>
<br>
+ bool hasUnaligned() const { return Mask & UMask; }<br>
+ void setUnaligned(bool flag) {<br>
+ Mask = (Mask & ~UMask) | (flag ? UMask : 0);<br>
+ }<br>
+ void removeUnaligned() { Mask &= ~UMask; }<br>
+ void addUnaligned() { Mask |= UMask; }<br>
+<br>
bool hasObjCGCAttr() const { return Mask & GCAttrMask; }<br>
GC getObjCGCAttr() const { return GC((Mask & GCAttrMask) >> GCAttrShift); }<br>
void setObjCGCAttr(GC type) {<br>
@@ -433,7 +440,9 @@ public:<br>
// ObjC lifetime qualifiers must match exactly.<br>
getObjCLifetime() == other.getObjCLifetime() &&<br>
// CVR qualifiers may subset.<br>
- (((Mask & CVRMask) | (other.Mask & CVRMask)) == (Mask & CVRMask));<br>
+ (((Mask & CVRMask) | (other.Mask & CVRMask)) == (Mask & CVRMask)) &&<br>
+ // U qualifier may superset.<br>
+ (!(other.Mask & UMask) || (Mask & UMask));<br>
}<br>
<br>
/// \brief Determines if these qualifiers compatibly include another set of<br>
@@ -501,16 +510,19 @@ public:<br>
<br>
private:<br>
<br>
- // bits: |0 1 2|3 .. 4|5 .. 7|8 ... 31|<br>
- // |C R V|GCAttr|Lifetime|AddressSpace|<br>
+ // bits: |0 1 2|3|4 .. 5|6 .. 8|9 ... 31|<br>
+ // |C R V|U|GCAttr|Lifetime|AddressSpace|<br>
uint32_t Mask;<br>
<br>
- static const uint32_t GCAttrMask = 0x18;<br>
- static const uint32_t GCAttrShift = 3;<br>
- static const uint32_t LifetimeMask = 0xE0;<br>
- static const uint32_t LifetimeShift = 5;<br>
- static const uint32_t AddressSpaceMask = ~(CVRMask|GCAttrMask|LifetimeMask);<br>
- static const uint32_t AddressSpaceShift = 8;<br>
+ static const uint32_t UMask = 0x8;<br>
+ static const uint32_t UShift = 3;<br>
+ static const uint32_t GCAttrMask = 0x30;<br>
+ static const uint32_t GCAttrShift = 4;<br>
+ static const uint32_t LifetimeMask = 0x1C0;<br>
+ static const uint32_t LifetimeShift = 6;<br>
+ static const uint32_t AddressSpaceMask =<br>
+ ~(CVRMask | UMask | GCAttrMask | LifetimeMask);<br>
+ static const uint32_t AddressSpaceShift = 9;<br>
};<br>
<br>
/// A std::pair-like structure for storing a qualified type split<br>
@@ -5377,7 +5389,13 @@ inline bool QualType::isMoreQualifiedTha<br>
/// int" is at least as qualified as "const int", "volatile int",<br>
/// "int", and "const volatile int".<br>
inline bool QualType::isAtLeastAsQualifiedAs(QualType other) const {<br>
- return getQualifiers().compatiblyIncludes(other.getQualifiers());<br>
+ Qualifiers otherQuals = other.getQualifiers();<br>
+<br>
+ // Ignore __unaligned qualifier if this type is a void.<br>
+ if (getUnqualifiedType()->isVoidType())<br>
+ otherQuals.removeUnaligned();<br>
+<br>
+ return getQualifiers().compatiblyIncludes(otherQuals);<br>
}<br>
<br>
/// If Type is a reference type (e.g., const<br>
<br>
Modified: cfe/trunk/include/clang/Basic/AddressSpaces.h<br>
URL: <a href="http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Basic/AddressSpaces.h?rev=268727&r1=268726&r2=268727&view=diff" rel="noreferrer" target="_blank">http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Basic/AddressSpaces.h?rev=268727&r1=268726&r2=268727&view=diff</a><br>
==============================================================================<br>
--- cfe/trunk/include/clang/Basic/AddressSpaces.h (original)<br>
+++ cfe/trunk/include/clang/Basic/AddressSpaces.h Fri May 6 06:47:55 2016<br>
@@ -25,7 +25,7 @@ namespace LangAS {<br>
/// This uses a high starting offset so as not to conflict with any address<br>
/// space used by a target.<br>
enum ID {<br>
- Offset = 0xFFFF00,<br>
+ Offset = 0x7FFF00,<br>
<br>
opencl_global = Offset,<br>
opencl_local,<br>
<br>
Modified: cfe/trunk/include/clang/Basic/Attr.td<br>
URL: <a href="http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Basic/Attr.td?rev=268727&r1=268726&r2=268727&view=diff" rel="noreferrer" target="_blank">http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Basic/Attr.td?rev=268727&r1=268726&r2=268727&view=diff</a><br>
==============================================================================<br>
--- cfe/trunk/include/clang/Basic/Attr.td (original)<br>
+++ cfe/trunk/include/clang/Basic/Attr.td Fri May 6 06:47:55 2016<br>
@@ -2157,10 +2157,6 @@ def InitSeg : Attr {<br>
}];<br>
}<br>
<br>
-def Unaligned : IgnoredAttr {<br>
- let Spellings = [Keyword<"__unaligned">];<br>
-}<br>
-<br>
def LoopHint : Attr {<br>
/// #pragma clang loop <option> directive<br>
/// vectorize: vectorizes loop operations if State == Enable.<br>
<br>
Modified: cfe/trunk/include/clang/Sema/DeclSpec.h<br>
URL: <a href="http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Sema/DeclSpec.h?rev=268727&r1=268726&r2=268727&view=diff" rel="noreferrer" target="_blank">http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Sema/DeclSpec.h?rev=268727&r1=268726&r2=268727&view=diff</a><br>
==============================================================================<br>
--- cfe/trunk/include/clang/Sema/DeclSpec.h (original)<br>
+++ cfe/trunk/include/clang/Sema/DeclSpec.h Fri May 6 06:47:55 2016<br>
@@ -312,7 +312,10 @@ public:<br>
TQ_volatile = 4,<br>
// This has no corresponding Qualifiers::TQ value, because it's not treated<br>
// as a qualifier in our type system.<br>
- TQ_atomic = 8<br>
+ TQ_atomic = 8,<br>
+ // There is no corresponding Qualifiers::TQ value, but it's kept separately<br>
+ // in a dedicated Qualifiers::Mask bit.<br>
+ TQ_unaligned = 16<br>
};<br>
<br>
/// ParsedSpecifiers - Flags to query which specifiers were applied. This is<br>
@@ -343,7 +346,7 @@ private:<br>
unsigned TypeSpecPipe : 1;<br>
<br>
// type-qualifiers<br>
- unsigned TypeQualifiers : 4; // Bitwise OR of TQ.<br>
+ unsigned TypeQualifiers : 5; // Bitwise OR of TQ.<br>
<br>
// function-specifier<br>
unsigned FS_inline_specified : 1;<br>
@@ -385,7 +388,8 @@ private:<br>
/// TSTNameLoc provides source range info for tag types.<br>
SourceLocation TSTNameLoc;<br>
SourceRange TypeofParensRange;<br>
- SourceLocation TQ_constLoc, TQ_restrictLoc, TQ_volatileLoc, TQ_atomicLoc;<br>
+ SourceLocation TQ_constLoc, TQ_restrictLoc, TQ_volatileLoc, TQ_atomicLoc,<br>
+ TQ_unalignedLoc;<br>
SourceLocation FS_inlineLoc, FS_virtualLoc, FS_explicitLoc, FS_noreturnLoc;<br>
SourceLocation FS_forceinlineLoc;<br>
SourceLocation FriendLoc, ModulePrivateLoc, ConstexprLoc, ConceptLoc;<br>
@@ -539,6 +543,7 @@ public:<br>
SourceLocation getRestrictSpecLoc() const { return TQ_restrictLoc; }<br>
SourceLocation getVolatileSpecLoc() const { return TQ_volatileLoc; }<br>
SourceLocation getAtomicSpecLoc() const { return TQ_atomicLoc; }<br>
+ SourceLocation getUnalignedSpecLoc() const { return TQ_unalignedLoc; }<br>
SourceLocation getPipeLoc() const { return TQ_pipeLoc; }<br>
<br>
/// \brief Clear out all of the type qualifiers.<br>
@@ -548,6 +553,7 @@ public:<br>
TQ_restrictLoc = SourceLocation();<br>
TQ_volatileLoc = SourceLocation();<br>
TQ_atomicLoc = SourceLocation();<br>
+ TQ_unalignedLoc = SourceLocation();<br>
TQ_pipeLoc = SourceLocation();<br>
}<br>
<br>
@@ -1113,8 +1119,8 @@ struct DeclaratorChunk {<br>
};<br>
<br>
struct PointerTypeInfo : TypeInfoCommon {<br>
- /// The type qualifiers: const/volatile/restrict/atomic.<br>
- unsigned TypeQuals : 4;<br>
+ /// The type qualifiers: const/volatile/restrict/atomic/unaligned.<br>
+ unsigned TypeQuals : 5;<br>
<br>
/// The location of the const-qualifier, if any.<br>
unsigned ConstQualLoc;<br>
@@ -1128,6 +1134,9 @@ struct DeclaratorChunk {<br>
/// The location of the _Atomic-qualifier, if any.<br>
unsigned AtomicQualLoc;<br>
<br>
+ /// The location of the __unaligned-qualifier, if any.<br>
+ unsigned UnalignedQualLoc;<br>
+<br>
void destroy() {<br>
}<br>
};<br>
@@ -1468,7 +1477,8 @@ struct DeclaratorChunk {<br>
SourceLocation ConstQualLoc,<br>
SourceLocation VolatileQualLoc,<br>
SourceLocation RestrictQualLoc,<br>
- SourceLocation AtomicQualLoc) {<br>
+ SourceLocation AtomicQualLoc,<br>
+ SourceLocation UnalignedQualLoc) {<br>
DeclaratorChunk I;<br>
I.Kind = Pointer;<br>
I.Loc = Loc;<br>
@@ -1477,6 +1487,7 @@ struct DeclaratorChunk {<br>
I.Ptr.VolatileQualLoc = VolatileQualLoc.getRawEncoding();<br>
I.Ptr.RestrictQualLoc = RestrictQualLoc.getRawEncoding();<br>
I.Ptr.AtomicQualLoc = AtomicQualLoc.getRawEncoding();<br>
+ I.Ptr.UnalignedQualLoc = UnalignedQualLoc.getRawEncoding();<br>
I.Ptr.AttrList = nullptr;<br>
return I;<br>
}<br>
<br>
Modified: cfe/trunk/include/clang/Sema/Sema.h<br>
URL: <a href="http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Sema/Sema.h?rev=268727&r1=268726&r2=268727&view=diff" rel="noreferrer" target="_blank">http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Sema/Sema.h?rev=268727&r1=268726&r2=268727&view=diff</a><br>
==============================================================================<br>
--- cfe/trunk/include/clang/Sema/Sema.h (original)<br>
+++ cfe/trunk/include/clang/Sema/Sema.h Fri May 6 06:47:55 2016<br>
@@ -1675,7 +1675,8 @@ public:<br>
SourceLocation ConstQualLoc = SourceLocation(),<br>
SourceLocation VolatileQualLoc = SourceLocation(),<br>
SourceLocation RestrictQualLoc = SourceLocation(),<br>
- SourceLocation AtomicQualLoc = SourceLocation());<br>
+ SourceLocation AtomicQualLoc = SourceLocation(),<br>
+ SourceLocation UnalignedQualLoc = SourceLocation());<br>
<br>
static bool adjustContextForLocalExternDecl(DeclContext *&DC);<br>
void DiagnoseFunctionSpecifiers(const DeclSpec &DS);<br>
<br>
Modified: cfe/trunk/lib/AST/MicrosoftMangle.cpp<br>
URL: <a href="http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/AST/MicrosoftMangle.cpp?rev=268727&r1=268726&r2=268727&view=diff" rel="noreferrer" target="_blank">http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/AST/MicrosoftMangle.cpp?rev=268727&r1=268726&r2=268727&view=diff</a><br>
==============================================================================<br>
--- cfe/trunk/lib/AST/MicrosoftMangle.cpp (original)<br>
+++ cfe/trunk/lib/AST/MicrosoftMangle.cpp Fri May 6 06:47:55 2016<br>
@@ -1446,6 +1446,9 @@ void MicrosoftCXXNameMangler::manglePoin<br>
<br>
if (HasRestrict)<br>
Out << 'I';<br>
+<br>
+ if (!PointeeType.isNull() && PointeeType.getLocalQualifiers().hasUnaligned())<br>
+ Out << 'F';<br>
}<br>
<br>
void MicrosoftCXXNameMangler::manglePointerCVQualifiers(Qualifiers Quals) {<br>
@@ -1577,6 +1580,8 @@ void MicrosoftCXXNameMangler::mangleType<br>
}<br>
break;<br>
case QMM_Result:<br>
+ // Presence of __unaligned qualifier shouldn't affect mangling here.<br>
+ Quals.removeUnaligned();<br>
if ((!IsPointer && Quals) || isa<TagType>(T)) {<br>
Out << '?';<br>
mangleQualifiers(Quals, false);<br>
<br>
Modified: cfe/trunk/lib/AST/TypePrinter.cpp<br>
URL: <a href="http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/AST/TypePrinter.cpp?rev=268727&r1=268726&r2=268727&view=diff" rel="noreferrer" target="_blank">http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/AST/TypePrinter.cpp?rev=268727&r1=268726&r2=268727&view=diff</a><br>
==============================================================================<br>
--- cfe/trunk/lib/AST/TypePrinter.cpp (original)<br>
+++ cfe/trunk/lib/AST/TypePrinter.cpp Fri May 6 06:47:55 2016<br>
@@ -1593,6 +1593,12 @@ void Qualifiers::print(raw_ostream &OS,<br>
AppendTypeQualList(OS, quals, Policy.LangOpts.C99);<br>
addSpace = true;<br>
}<br>
+ if (hasUnaligned()) {<br>
+ if (addSpace)<br>
+ OS << ' ';<br>
+ OS << "__unaligned";<br>
+ addSpace = true;<br>
+ }<br>
if (unsigned addrspace = getAddressSpace()) {<br>
if (addSpace)<br>
OS << ' ';<br>
<br>
Modified: cfe/trunk/lib/Parse/ParseDecl.cpp<br>
URL: <a href="http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Parse/ParseDecl.cpp?rev=268727&r1=268726&r2=268727&view=diff" rel="noreferrer" target="_blank">http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Parse/ParseDecl.cpp?rev=268727&r1=268726&r2=268727&view=diff</a><br>
==============================================================================<br>
--- cfe/trunk/lib/Parse/ParseDecl.cpp (original)<br>
+++ cfe/trunk/lib/Parse/ParseDecl.cpp Fri May 6 06:47:55 2016<br>
@@ -609,7 +609,6 @@ void Parser::ParseMicrosoftTypeAttribute<br>
case tok::kw___ptr64:<br>
case tok::kw___w64:<br>
case tok::kw___ptr32:<br>
- case tok::kw___unaligned:<br>
case tok::kw___sptr:<br>
case tok::kw___uptr: {<br>
IdentifierInfo *AttrName = Tok.getIdentifierInfo();<br>
@@ -3087,6 +3086,11 @@ void Parser::ParseDeclarationSpecifiers(<br>
break;<br>
}<br>
<br>
+ case tok::kw___unaligned:<br>
+ isInvalid = DS.SetTypeQual(DeclSpec::TQ_unaligned, Loc, PrevSpec, DiagID,<br>
+ getLangOpts());<br>
+ break;<br>
+<br>
case tok::kw___sptr:<br>
case tok::kw___uptr:<br>
case tok::kw___ptr64:<br>
@@ -3097,7 +3101,6 @@ void Parser::ParseDeclarationSpecifiers(<br>
case tok::kw___fastcall:<br>
case tok::kw___thiscall:<br>
case tok::kw___vectorcall:<br>
- case tok::kw___unaligned:<br>
ParseMicrosoftTypeAttributes(DS.getAttributes());<br>
continue;<br>
<br>
@@ -4791,6 +4794,10 @@ void Parser::ParseTypeQualifierListOpt(D<br>
ParseOpenCLQualifiers(DS.getAttributes());<br>
break;<br>
<br>
+ case tok::kw___unaligned:<br>
+ isInvalid = DS.SetTypeQual(DeclSpec::TQ_unaligned, Loc, PrevSpec, DiagID,<br>
+ getLangOpts());<br>
+ break;<br>
case tok::kw___uptr:<br>
// GNU libc headers in C mode use '__uptr' as an identifer which conflicts<br>
// with the MS modifier keyword.<br>
@@ -4808,7 +4815,6 @@ void Parser::ParseTypeQualifierListOpt(D<br>
case tok::kw___fastcall:<br>
case tok::kw___thiscall:<br>
case tok::kw___vectorcall:<br>
- case tok::kw___unaligned:<br>
if (AttrReqs & AR_DeclspecAttributesParsed) {<br>
ParseMicrosoftTypeAttributes(DS.getAttributes());<br>
continue;<br>
@@ -5031,7 +5037,8 @@ void Parser::ParseDeclaratorInternal(Dec<br>
DS.getConstSpecLoc(),<br>
DS.getVolatileSpecLoc(),<br>
DS.getRestrictSpecLoc(),<br>
- DS.getAtomicSpecLoc()),<br>
+ DS.getAtomicSpecLoc(),<br>
+ DS.getUnalignedSpecLoc()),<br>
DS.getAttributes(),<br>
SourceLocation());<br>
else<br>
<br>
Modified: cfe/trunk/lib/Parse/ParseTentative.cpp<br>
URL: <a href="http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Parse/ParseTentative.cpp?rev=268727&r1=268726&r2=268727&view=diff" rel="noreferrer" target="_blank">http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Parse/ParseTentative.cpp?rev=268727&r1=268726&r2=268727&view=diff</a><br>
==============================================================================<br>
--- cfe/trunk/lib/Parse/ParseTentative.cpp (original)<br>
+++ cfe/trunk/lib/Parse/ParseTentative.cpp Fri May 6 06:47:55 2016<br>
@@ -833,7 +833,7 @@ Parser::TPResult Parser::TryParseDeclara<br>
// '(' abstract-declarator ')'<br>
if (Tok.isOneOf(tok::kw___attribute, tok::kw___declspec, tok::kw___cdecl,<br>
tok::kw___stdcall, tok::kw___fastcall, tok::kw___thiscall,<br>
- tok::kw___vectorcall, tok::kw___unaligned))<br>
+ tok::kw___vectorcall))<br>
return TPResult::True; // attributes indicate declaration<br>
TPResult TPR = TryParseDeclarator(mayBeAbstract, mayHaveIdentifier);<br>
if (TPR != TPResult::Ambiguous)<br>
<br>
Modified: cfe/trunk/lib/Sema/DeclSpec.cpp<br>
URL: <a href="http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/DeclSpec.cpp?rev=268727&r1=268726&r2=268727&view=diff" rel="noreferrer" target="_blank">http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/DeclSpec.cpp?rev=268727&r1=268726&r2=268727&view=diff</a><br>
==============================================================================<br>
--- cfe/trunk/lib/Sema/DeclSpec.cpp (original)<br>
+++ cfe/trunk/lib/Sema/DeclSpec.cpp Fri May 6 06:47:55 2016<br>
@@ -492,6 +492,7 @@ const char *DeclSpec::getSpecifierName(T<br>
case DeclSpec::TQ_restrict: return "restrict";<br>
case DeclSpec::TQ_volatile: return "volatile";<br>
case DeclSpec::TQ_atomic: return "_Atomic";<br>
+ case DeclSpec::TQ_unaligned: return "__unaligned";<br>
}<br>
llvm_unreachable("Unknown typespec!");<br>
}<br>
@@ -794,6 +795,7 @@ bool DeclSpec::SetTypeQual(TQ T, SourceL<br>
case TQ_restrict: TQ_restrictLoc = Loc; return false;<br>
case TQ_volatile: TQ_volatileLoc = Loc; return false;<br>
case TQ_atomic: TQ_atomicLoc = Loc; return false;<br>
+ case TQ_unaligned: TQ_unalignedLoc = Loc; return false;<br>
}<br>
<br>
llvm_unreachable("Unknown type qualifier!");<br>
@@ -959,10 +961,10 @@ void DeclSpec::Finish(Sema &S, const Pri<br>
TypeSpecSign != TSS_unspecified ||<br>
TypeAltiVecVector || TypeAltiVecPixel || TypeAltiVecBool ||<br>
TypeQualifiers)) {<br>
- const unsigned NumLocs = 8;<br>
+ const unsigned NumLocs = 9;<br>
SourceLocation ExtraLocs[NumLocs] = {<br>
TSWLoc, TSCLoc, TSSLoc, AltiVecLoc,<br>
- TQ_constLoc, TQ_restrictLoc, TQ_volatileLoc, TQ_atomicLoc<br>
+ TQ_constLoc, TQ_restrictLoc, TQ_volatileLoc, TQ_atomicLoc, TQ_unalignedLoc<br>
};<br>
FixItHint Hints[NumLocs];<br>
SourceLocation FirstLoc;<br>
<br>
Modified: cfe/trunk/lib/Sema/SemaCodeComplete.cpp<br>
URL: <a href="http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaCodeComplete.cpp?rev=268727&r1=268726&r2=268727&view=diff" rel="noreferrer" target="_blank">http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaCodeComplete.cpp?rev=268727&r1=268726&r2=268727&view=diff</a><br>
==============================================================================<br>
--- cfe/trunk/lib/Sema/SemaCodeComplete.cpp (original)<br>
+++ cfe/trunk/lib/Sema/SemaCodeComplete.cpp Fri May 6 06:47:55 2016<br>
@@ -3812,6 +3812,9 @@ void Sema::CodeCompleteTypeQualifiers(De<br>
if (getLangOpts().C11 &&<br>
!(DS.getTypeQualifiers() & DeclSpec::TQ_atomic))<br>
Results.AddResult("_Atomic");<br>
+ if (getLangOpts().MSVCCompat &&<br>
+ !(DS.getTypeQualifiers() & DeclSpec::TQ_unaligned))<br>
+ Results.AddResult("__unaligned");<br>
Results.ExitScope();<br>
HandleCodeCompleteResults(this, CodeCompleter,<br>
Results.getCompletionContext(),<br>
<br>
Modified: cfe/trunk/lib/Sema/SemaDecl.cpp<br>
URL: <a href="http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaDecl.cpp?rev=268727&r1=268726&r2=268727&view=diff" rel="noreferrer" target="_blank">http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaDecl.cpp?rev=268727&r1=268726&r2=268727&view=diff</a><br>
==============================================================================<br>
--- cfe/trunk/lib/Sema/SemaDecl.cpp (original)<br>
+++ cfe/trunk/lib/Sema/SemaDecl.cpp Fri May 6 06:47:55 2016<br>
@@ -3983,6 +3983,8 @@ Sema::ParsedFreeStandingDeclSpec(Scope *<br>
// Restrict is covered above.<br>
if (DS.getTypeQualifiers() & DeclSpec::TQ_atomic)<br>
Diag(DS.getAtomicSpecLoc(), DiagID) << "_Atomic";<br>
+ if (DS.getTypeQualifiers() & DeclSpec::TQ_unaligned)<br>
+ Diag(DS.getUnalignedSpecLoc(), DiagID) << "__unaligned";<br>
}<br>
<br>
// Warn about ignored type attributes, for example:<br>
@@ -4240,6 +4242,11 @@ Decl *Sema::BuildAnonymousStructOrUnion(<br>
diag::ext_anonymous_struct_union_qualified)<br>
<< Record->isUnion() << "_Atomic"<br>
<< FixItHint::CreateRemoval(DS.getAtomicSpecLoc());<br>
+ if (DS.getTypeQualifiers() & DeclSpec::TQ_unaligned)<br>
+ Diag(DS.getUnalignedSpecLoc(),<br>
+ diag::ext_anonymous_struct_union_qualified)<br>
+ << Record->isUnion() << "__unaligned"<br>
+ << FixItHint::CreateRemoval(DS.getUnalignedSpecLoc());<br>
<br>
DS.ClearTypeQualifiers();<br>
}<br>
<br>
Modified: cfe/trunk/lib/Sema/SemaDeclObjC.cpp<br>
URL: <a href="http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaDeclObjC.cpp?rev=268727&r1=268726&r2=268727&view=diff" rel="noreferrer" target="_blank">http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaDeclObjC.cpp?rev=268727&r1=268726&r2=268727&view=diff</a><br>
==============================================================================<br>
--- cfe/trunk/lib/Sema/SemaDeclObjC.cpp (original)<br>
+++ cfe/trunk/lib/Sema/SemaDeclObjC.cpp Fri May 6 06:47:55 2016<br>
@@ -1503,6 +1503,7 @@ void Sema::actOnObjCTypeArgsOrProtocolQu<br>
SourceLocation(),<br>
SourceLocation(),<br>
SourceLocation(),<br>
+ SourceLocation(),<br>
SourceLocation()),<br>
parsedAttrs,<br>
starLoc);<br>
<br>
Modified: cfe/trunk/lib/Sema/SemaExpr.cpp<br>
URL: <a href="http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaExpr.cpp?rev=268727&r1=268726&r2=268727&view=diff" rel="noreferrer" target="_blank">http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaExpr.cpp?rev=268727&r1=268726&r2=268727&view=diff</a><br>
==============================================================================<br>
--- cfe/trunk/lib/Sema/SemaExpr.cpp (original)<br>
+++ cfe/trunk/lib/Sema/SemaExpr.cpp Fri May 6 06:47:55 2016<br>
@@ -7080,7 +7080,7 @@ checkPointerTypesForAssignment(Sema &S,<br>
else if (lhq.getObjCLifetime() != rhq.getObjCLifetime())<br>
ConvTy = Sema::IncompatiblePointerDiscardsQualifiers;<br>
<br>
- // For GCC compatibility, other qualifier mismatches are treated<br>
+ // For GCC/MS compatibility, other qualifier mismatches are treated<br>
// as still compatible in C.<br>
else ConvTy = Sema::CompatiblePointerDiscardsQualifiers;<br>
}<br>
<br>
Modified: cfe/trunk/lib/Sema/SemaOverload.cpp<br>
URL: <a href="http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaOverload.cpp?rev=268727&r1=268726&r2=268727&view=diff" rel="noreferrer" target="_blank">http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaOverload.cpp?rev=268727&r1=268726&r2=268727&view=diff</a><br>
==============================================================================<br>
--- cfe/trunk/lib/Sema/SemaOverload.cpp (original)<br>
+++ cfe/trunk/lib/Sema/SemaOverload.cpp Fri May 6 06:47:55 2016<br>
@@ -2936,6 +2936,10 @@ Sema::IsQualificationConversion(QualType<br>
<br>
Qualifiers FromQuals = FromType.getQualifiers();<br>
Qualifiers ToQuals = ToType.getQualifiers();<br>
+<br>
+ // Ignore __unaligned qualifier if this type is void.<br>
+ if (ToType.getUnqualifiedType()->isVoidType())<br>
+ FromQuals.removeUnaligned();<br>
<br>
// Objective-C ARC:<br>
// Check Objective-C lifetime conversions.<br>
<br>
Modified: cfe/trunk/lib/Sema/SemaType.cpp<br>
URL: <a href="http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaType.cpp?rev=268727&r1=268726&r2=268727&view=diff" rel="noreferrer" target="_blank">http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaType.cpp?rev=268727&r1=268726&r2=268727&view=diff</a><br>
==============================================================================<br>
--- cfe/trunk/lib/Sema/SemaType.cpp (original)<br>
+++ cfe/trunk/lib/Sema/SemaType.cpp Fri May 6 06:47:55 2016<br>
@@ -1778,12 +1778,13 @@ QualType Sema::BuildQualifiedType(QualTy<br>
}<br>
<br>
QualType Sema::BuildQualifiedType(QualType T, SourceLocation Loc,<br>
- unsigned CVRA, const DeclSpec *DS) {<br>
+ unsigned CVRAU, const DeclSpec *DS) {<br>
if (T.isNull())<br>
return QualType();<br>
<br>
- // Convert from DeclSpec::TQ to Qualifiers::TQ by just dropping TQ_atomic.<br>
- unsigned CVR = CVRA & ~DeclSpec::TQ_atomic;<br>
+ // Convert from DeclSpec::TQ to Qualifiers::TQ by just dropping TQ_atomic and<br>
+ // TQ_unaligned;<br>
+ unsigned CVR = CVRAU & ~(DeclSpec::TQ_atomic | DeclSpec::TQ_unaligned);<br>
<br>
// C11 6.7.3/5:<br>
// If the same qualifier appears more than once in the same<br>
@@ -1793,7 +1794,7 @@ QualType Sema::BuildQualifiedType(QualTy<br>
// It's not specified what happens when the _Atomic qualifier is applied to<br>
// a type specified with the _Atomic specifier, but we assume that this<br>
// should be treated as if the _Atomic qualifier appeared multiple times.<br>
- if (CVRA & DeclSpec::TQ_atomic && !T->isAtomicType()) {<br>
+ if (CVRAU & DeclSpec::TQ_atomic && !T->isAtomicType()) {<br>
// C11 6.7.3/5:<br>
// If other qualifiers appear along with the _Atomic qualifier in a<br>
// specifier-qualifier-list, the resulting type is the so-qualified<br>
@@ -1810,7 +1811,9 @@ QualType Sema::BuildQualifiedType(QualTy<br>
return BuildQualifiedType(T, Loc, Split.Quals);<br>
}<br>
<br>
- return BuildQualifiedType(T, Loc, Qualifiers::fromCVRMask(CVR), DS);<br>
+ Qualifiers Q = Qualifiers::fromCVRMask(CVR);<br>
+ Q.setUnaligned(CVRAU & DeclSpec::TQ_unaligned);<br>
+ return BuildQualifiedType(T, Loc, Q, DS);<br>
}<br>
<br>
/// \brief Build a paren type including \p T.<br>
@@ -2645,7 +2648,8 @@ void Sema::diagnoseIgnoredQualifiers(uns<br>
SourceLocation ConstQualLoc,<br>
SourceLocation VolatileQualLoc,<br>
SourceLocation RestrictQualLoc,<br>
- SourceLocation AtomicQualLoc) {<br>
+ SourceLocation AtomicQualLoc,<br>
+ SourceLocation UnalignedQualLoc) {<br>
if (!Quals)<br>
return;<br>
<br>
@@ -2653,20 +2657,21 @@ void Sema::diagnoseIgnoredQualifiers(uns<br>
const char *Name;<br>
unsigned Mask;<br>
SourceLocation Loc;<br>
- } const QualKinds[4] = {<br>
+ } const QualKinds[5] = {<br>
{ "const", DeclSpec::TQ_const, ConstQualLoc },<br>
{ "volatile", DeclSpec::TQ_volatile, VolatileQualLoc },<br>
{ "restrict", DeclSpec::TQ_restrict, RestrictQualLoc },<br>
- { "_Atomic", DeclSpec::TQ_atomic, AtomicQualLoc }<br>
+ { "_Atomic", DeclSpec::TQ_atomic, AtomicQualLoc },<br>
+ { "__unaligned", DeclSpec::TQ_unaligned, UnalignedQualLoc }<br>
};<br>
<br>
SmallString<32> QualStr;<br>
unsigned NumQuals = 0;<br>
SourceLocation Loc;<br>
- FixItHint FixIts[4];<br>
+ FixItHint FixIts[5];<br>
<br>
// Build a string naming the redundant qualifiers.<br>
- for (unsigned I = 0; I != 4; ++I) {<br>
+ for (unsigned I = 0; I != 5; ++I) {<br>
if (Quals & QualKinds[I].Mask) {<br>
if (!QualStr.empty()) QualStr += ' ';<br>
QualStr += QualKinds[I].Name;<br>
@@ -2718,7 +2723,8 @@ static void diagnoseRedundantReturnTypeQ<br>
SourceLocation::getFromRawEncoding(PTI.ConstQualLoc),<br>
SourceLocation::getFromRawEncoding(PTI.VolatileQualLoc),<br>
SourceLocation::getFromRawEncoding(PTI.RestrictQualLoc),<br>
- SourceLocation::getFromRawEncoding(PTI.AtomicQualLoc));<br>
+ SourceLocation::getFromRawEncoding(PTI.AtomicQualLoc),<br>
+ SourceLocation::getFromRawEncoding(PTI.UnalignedQualLoc));<br>
return;<br>
}<br>
<br>
@@ -2754,7 +2760,8 @@ static void diagnoseRedundantReturnTypeQ<br>
D.getDeclSpec().getConstSpecLoc(),<br>
D.getDeclSpec().getVolatileSpecLoc(),<br>
D.getDeclSpec().getRestrictSpecLoc(),<br>
- D.getDeclSpec().getAtomicSpecLoc());<br>
+ D.getDeclSpec().getAtomicSpecLoc(),<br>
+ D.getDeclSpec().getUnalignedSpecLoc());<br>
}<br>
<br>
static QualType GetDeclSpecTypeForDeclarator(TypeProcessingState &state,<br>
<br>
Modified: cfe/trunk/test/CodeGenCXX/mangle-ms-cxx11.cpp<br>
URL: <a href="http://llvm.org/viewvc/llvm-project/cfe/trunk/test/CodeGenCXX/mangle-ms-cxx11.cpp?rev=268727&r1=268726&r2=268727&view=diff" rel="noreferrer" target="_blank">http://llvm.org/viewvc/llvm-project/cfe/trunk/test/CodeGenCXX/mangle-ms-cxx11.cpp?rev=268727&r1=268726&r2=268727&view=diff</a><br>
==============================================================================<br>
--- cfe/trunk/test/CodeGenCXX/mangle-ms-cxx11.cpp (original)<br>
+++ cfe/trunk/test/CodeGenCXX/mangle-ms-cxx11.cpp Fri May 6 06:47:55 2016<br>
@@ -293,3 +293,19 @@ int PR26105() {<br>
}<br>
// CHECK-DAG: @"\01??R<lambda_0>@?0??PR26105@@YAHXZ@QBE@H@Z"<br>
// CHECK-DAG: @"\01??R<lambda_1>@?0???R<lambda_0>@?0??PR26105@@YAHXZ@QBE@H@Z@QBE@H@Z"<br>
+<br>
+int __unaligned * unaligned_foo1() { return 0; }<br>
+int __unaligned * __unaligned * unaligned_foo2() { return 0; }<br>
+__unaligned int unaligned_foo3() { return 0; }<br>
+void unaligned_foo4(int __unaligned *p1) {}<br>
+void unaligned_foo5(int __unaligned * __restrict p1) {}<br>
+template <typename T> T unaligned_foo6(T t) { return t; }<br>
+void unaligned_foo7() { unaligned_foo6<int *>(0); unaligned_foo6<int __unaligned *>(0); }<br>
+<br>
+// CHECK-DAG: @"\01?unaligned_foo1@@YAPFAHXZ"<br>
+// CHECK-DAG: @"\01?unaligned_foo2@@YAPFAPFAHXZ"<br>
+// CHECK-DAG: @"\01?unaligned_foo3@@YAHXZ"<br>
+// CHECK-DAG: @"\01?unaligned_foo4@@YAXPFAH@Z"<br>
+// CHECK-DAG: @"\01?unaligned_foo5@@YAXPIFAH@Z"<br>
+// CHECK-DAG: @"\01??$unaligned_foo6@PAH@@YAPAHPAH@Z"<br>
+// CHECK-DAG: @"\01??$unaligned_foo6@PFAH@@YAPFAHPFAH@Z"<br>
<br>
Modified: cfe/trunk/test/CodeGenCXX/mangle-ms-cxx14.cpp<br>
URL: <a href="http://llvm.org/viewvc/llvm-project/cfe/trunk/test/CodeGenCXX/mangle-ms-cxx14.cpp?rev=268727&r1=268726&r2=268727&view=diff" rel="noreferrer" target="_blank">http://llvm.org/viewvc/llvm-project/cfe/trunk/test/CodeGenCXX/mangle-ms-cxx14.cpp?rev=268727&r1=268726&r2=268727&view=diff</a><br>
==============================================================================<br>
--- cfe/trunk/test/CodeGenCXX/mangle-ms-cxx14.cpp (original)<br>
+++ cfe/trunk/test/CodeGenCXX/mangle-ms-cxx14.cpp Fri May 6 06:47:55 2016<br>
@@ -55,3 +55,8 @@ struct Foo {};<br>
<br>
Foo<&x<int>, &x<int>> Zoo;<br>
// CHECK-DAG: "\01?Zoo@@3U?$Foo@$1??$x@H@@3HA$1?1@3HA@@A"<br>
+<br>
+template <typename T> T unaligned_x;<br>
+extern auto test_unaligned() { return unaligned_x<int __unaligned *>; }<br>
+// CHECK-DAG: "\01??$unaligned_x@PFAH@@3PFAHA"<br>
+<br>
<br>
Modified: cfe/trunk/test/Sema/MicrosoftExtensions.c<br>
URL: <a href="http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Sema/MicrosoftExtensions.c?rev=268727&r1=268726&r2=268727&view=diff" rel="noreferrer" target="_blank">http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Sema/MicrosoftExtensions.c?rev=268727&r1=268726&r2=268727&view=diff</a><br>
==============================================================================<br>
--- cfe/trunk/test/Sema/MicrosoftExtensions.c (original)<br>
+++ cfe/trunk/test/Sema/MicrosoftExtensions.c Fri May 6 06:47:55 2016<br>
@@ -170,3 +170,11 @@ void myprintf(const char *f, ...) {<br>
__va_start(ap, f); // expected-warning {{incompatible pointer types passing 'my_va_list'}}<br>
}<br>
}<br>
+<br>
+// __unaligned handling<br>
+void test_unaligned() {<br>
+ __unaligned int *p1 = 0;<br>
+ int *p2 = p1; // expected-warning {{initializing 'int *' with an expression of type '__unaligned int *' discards qualifiers}}<br>
+ __unaligned int *p3 = p2;<br>
+}<br>
+<br>
<br>
Modified: cfe/trunk/test/Sema/address_spaces.c<br>
URL: <a href="http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Sema/address_spaces.c?rev=268727&r1=268726&r2=268727&view=diff" rel="noreferrer" target="_blank">http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Sema/address_spaces.c?rev=268727&r1=268726&r2=268727&view=diff</a><br>
==============================================================================<br>
--- cfe/trunk/test/Sema/address_spaces.c (original)<br>
+++ cfe/trunk/test/Sema/address_spaces.c Fri May 6 06:47:55 2016<br>
@@ -20,7 +20,7 @@ void foo(_AS3 float *a,<br>
_AS1 int arrarr[5][5]; // expected-error {{automatic variable qualified with an address space}}<br>
<br>
__attribute__((address_space(-1))) int *_boundsA; // expected-error {{address space is negative}}<br>
- __attribute__((address_space(0xFFFFFF))) int *_boundsB;<br>
+ __attribute__((address_space(0x7FFFFF))) int *_boundsB;<br>
__attribute__((address_space(0x1000000))) int *_boundsC; // expected-error {{address space is larger than the maximum supported}}<br>
// chosen specifically to overflow 32 bits and come out reasonable<br>
__attribute__((address_space(4294967500))) int *_boundsD; // expected-error {{address space is larger than the maximum supported}}<br>
@@ -71,4 +71,4 @@ __attribute__((address_space("12"))) int<br>
// Clang extension doesn't forbid operations on pointers to different address spaces.<br>
char* cmp(_AS1 char *x, _AS2 char *y) {<br>
return x < y ? x : y; // expected-warning {{pointer type mismatch ('__attribute__((address_space(1))) char *' and '__attribute__((address_space(2))) char *')}}<br>
-}<br>
\ No newline at end of file<br>
+}<br>
<br>
Modified: cfe/trunk/test/Sema/invalid-assignment-constant-address-space.c<br>
URL: <a href="http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Sema/invalid-assignment-constant-address-space.c?rev=268727&r1=268726&r2=268727&view=diff" rel="noreferrer" target="_blank">http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Sema/invalid-assignment-constant-address-space.c?rev=268727&r1=268726&r2=268727&view=diff</a><br>
==============================================================================<br>
--- cfe/trunk/test/Sema/invalid-assignment-constant-address-space.c (original)<br>
+++ cfe/trunk/test/Sema/invalid-assignment-constant-address-space.c Fri May 6 06:47:55 2016<br>
@@ -1,6 +1,6 @@<br>
// RUN: %clang_cc1 %s -verify -pedantic -fsyntax-only<br>
<br>
-#define OPENCL_CONSTANT 16776962<br>
+#define OPENCL_CONSTANT 8388354<br>
int __attribute__((address_space(OPENCL_CONSTANT))) c[3] = {0};<br>
<br>
void foo() {<br>
<br>
Modified: cfe/trunk/test/SemaCXX/MicrosoftExtensions.cpp<br>
URL: <a href="http://llvm.org/viewvc/llvm-project/cfe/trunk/test/SemaCXX/MicrosoftExtensions.cpp?rev=268727&r1=268726&r2=268727&view=diff" rel="noreferrer" target="_blank">http://llvm.org/viewvc/llvm-project/cfe/trunk/test/SemaCXX/MicrosoftExtensions.cpp?rev=268727&r1=268726&r2=268727&view=diff</a><br>
==============================================================================<br>
--- cfe/trunk/test/SemaCXX/MicrosoftExtensions.cpp (original)<br>
+++ cfe/trunk/test/SemaCXX/MicrosoftExtensions.cpp Fri May 6 06:47:55 2016<br>
@@ -1,5 +1,7 @@<br>
-// RUN: %clang_cc1 %s -triple i686-pc-win32 -fsyntax-only -Wmicrosoft -Wc++11-extensions -Wno-long-long -verify -fms-extensions -fexceptions -fcxx-exceptions<br>
+// RUN: %clang_cc1 %s -triple i686-pc-win32 -fsyntax-only -Wmicrosoft -Wc++11-extensions -Wno-long-long -verify -fms-extensions -fexceptions -fcxx-exceptions -DTEST1<br>
+// RUN: %clang_cc1 %s -triple i686-pc-win32 -fsyntax-only -Wmicrosoft -Wc++11-extensions -Wno-long-long -verify -fexceptions -fcxx-exceptions -DTEST2<br>
<br>
+#if TEST1<br>
<br>
// Microsoft doesn't validate exception specification.<br>
namespace microsoft_exception_spec {<br>
@@ -80,7 +82,44 @@ struct M {<br>
// __unaligned handling<br>
typedef char __unaligned *aligned_type;<br>
typedef struct UnalignedTag { int f; } __unaligned *aligned_type2;<br>
+typedef char __unaligned aligned_type3;<br>
<br>
+// Check that __unaligned qualifier can be used for overloading<br>
+void foo_unaligned(int *arg) {}<br>
+void foo_unaligned(__unaligned int *arg) {}<br>
+void foo_unaligned(int arg) {} // expected-note {{previous definition is here}}<br>
+void foo_unaligned(__unaligned int arg) {} // expected-error {{redefinition of 'foo_unaligned'}}<br>
+class A_unaligned {};<br>
+class B_unaligned : public A_unaligned {};<br>
+int foo_unaligned(__unaligned A_unaligned *arg) { return 0; }<br>
+void *foo_unaligned(B_unaligned *arg) { return 0; }<br>
+<br>
+void test_unaligned() {<br>
+ int *p1 = 0;<br>
+ foo_unaligned(p1);<br>
+<br>
+ __unaligned int *p2 = 0;<br>
+ foo_unaligned(p2);<br>
+<br>
+ __unaligned B_unaligned *p3 = 0;<br>
+ int p4 = foo_unaligned(p3);<br>
+<br>
+ B_unaligned *p5 = p3; // expected-error {{cannot initialize a variable of type 'B_unaligned *' with an lvalue of type '__unaligned B_unaligned *'}}<br>
+<br>
+ __unaligned B_unaligned *p6 = p3;<br>
+}<br>
+<br>
+// Test from PR27367<br>
+// We should accept assignment of an __unaligned pointer to a non-__unaligned<br>
+// pointer to void<br>
+typedef struct _ITEMIDLIST { int i; } ITEMIDLIST;<br>
+typedef ITEMIDLIST __unaligned *LPITEMIDLIST;<br>
+extern "C" __declspec(dllimport) void __stdcall CoTaskMemFree(void* pv);<br>
+__inline void FreeIDListArray(LPITEMIDLIST *ppidls) {<br>
+ CoTaskMemFree(*ppidls);<br>
+ __unaligned int *x = 0;<br>
+ void *y = x;<br>
+}<br>
<br>
template<typename T> void h1(T (__stdcall M::* const )()) { }<br>
<br>
@@ -420,3 +459,15 @@ struct S {<br>
<br>
int S::fn() { return 0; } // expected-warning {{is missing exception specification}}<br>
}<br>
+<br>
+#elif TEST2<br>
+<br>
+// Check that __unaligned is not recognized if MS extensions are not enabled<br>
+typedef char __unaligned *aligned_type; // expected-error {{expected ';' after top level declarator}}<br>
+<br>
+#else<br>
+<br>
+#error Unknown test mode<br>
+<br>
+#endif<br>
+<br>
<br>
<br>
_______________________________________________<br>
cfe-commits mailing list<br>
<a href="mailto:cfe-commits@lists.llvm.org" target="_blank">cfe-commits@lists.llvm.org</a><br>
<a href="http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits" rel="noreferrer" target="_blank">http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits</a><br>
</blockquote></div><br></div>
</div></div></blockquote></div><br></div>