<div dir="ltr">This is now fixed in rL270834.<div><br></div><div>Yours,</div><div>Andrey</div><div><br></div></div><div class="gmail_extra"><br><div class="gmail_quote">On Thu, May 19, 2016 at 6:34 PM, Andrey Bokhanko <span dir="ltr"><<a href="mailto:andreybokhanko@gmail.com" target="_blank">andreybokhanko@gmail.com</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">David,<div><br></div><div>All these cases are handled properly now.</div><div><br></div><div>Could you, please, review?</div><div><br></div><div><a href="http://reviews.llvm.org/D20437" target="_blank">http://reviews.llvm.org/D20437</a><br></div><div><br></div><div>Yours,</div><div>Andrey</div><div><br></div></div><div class="HOEnZb"><div class="h5"><div class="gmail_extra"><br><div class="gmail_quote">On Sat, May 14, 2016 at 6:11 AM, David Majnemer <span dir="ltr"><<a href="mailto:david.majnemer@gmail.com" target="_blank">david.majnemer@gmail.com</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">FYI, the following is a little shorter:<div>using Ty = int () __unaligned;<br></div><div><br></div><div>Also, this case (in C mode) is interesting:</div><div>void f(int x[__unaligned 4]);<br></div><div><br></div><div>DeclaratorChunk::getArray will truncate the TypeQuals because ArrayTypeInfo's TypeQuals doesn't have enough bits.</div><div><br></div><div>similar issues arise with:</div><div><div>struct A;</div><div><br></div><div>void (A::*__unaligned vpa)();</div></div></div><div><div><div class="gmail_extra"><br><div class="gmail_quote">On Fri, May 13, 2016 at 4:03 PM, <span dir="ltr"><<a href="mailto:andreybokhanko@gmail.com" target="_blank">andreybokhanko@gmail.com</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div dir="auto"><div>Hi David,</div><div><br></div><div>Thanks for letting me know -- will investigate after the weekend.</div><div><br></div><div>Yours,</div><div>Andrey<br><br>Отправлено с iPad</div><div><br>13 мая 2016 г., в 20:33, David Majnemer <<a href="mailto:david.majnemer@gmail.com" target="_blank">david.majnemer@gmail.com</a>> написал(а):<br><br></div><div><div><blockquote type="cite"><div><div dir="ltr">This seems to crash clang:<div><div>struct S {</div><div> void f() __unaligned;</div><div>};</div><div>void S::f() __unaligned {</div><div>}</div></div><div><br></div><div>clang/lib/Sema/DeclSpec.cpp:214: static clang::DeclaratorChunk clang::DeclaratorChunk::getFunction(bool, bool, clang::SourceLocation, clang::DeclaratorChunk::ParamInfo *, unsigned int, clang::SourceLocation, clang::SourceLocation, unsigned int, bool, clang::SourceLocation, clang::SourceLocation, clang::SourceLocation, clang::SourceLocation, clang::SourceLocation, clang::ExceptionSpecificationType, clang::SourceRange, ParsedType *, clang::SourceRange *, unsigned int, clang::Expr *, CachedTokens *, clang::SourceLocation, clang::SourceLocation, clang::Declarator &, TypeResult): Assertion `I.Fun.TypeQuals == TypeQuals && "bitfield overflow"' failed.<br></div><div><br></div></div><div class="gmail_extra"><br><div class="gmail_quote">On Wed, May 11, 2016 at 11:38 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: Wed May 11 13:38:21 2016<br>
New Revision: 269220<br>
<br>
URL: <a href="http://llvm.org/viewvc/llvm-project?rev=269220&view=rev" rel="noreferrer" target="_blank">http://llvm.org/viewvc/llvm-project?rev=269220&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 and PR27666.<br>
<br>
Differential Revision: <a href="http://reviews.llvm.org/D20103" rel="noreferrer" target="_blank">http://reviews.llvm.org/D20103</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/Basic/DiagnosticSemaKinds.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=269220&r1=269219&r2=269220&view=diff" rel="noreferrer" target="_blank">http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/AST/Type.h?rev=269220&r1=269219&r2=269220&view=diff</a><br>
==============================================================================<br>
--- cfe/trunk/include/clang/AST/Type.h (original)<br>
+++ cfe/trunk/include/clang/AST/Type.h Wed May 11 13:38:21 2016<br>
@@ -111,6 +111,7 @@ namespace clang {<br>
/// The collection of all-type qualifiers we support.<br>
/// Clang supports five independent qualifiers:<br>
/// * C99: const, volatile, and restrict<br>
+/// * MS: __unaligned<br>
/// * Embedded C (TR18037): address spaces<br>
/// * Objective C: the GC attributes (none, weak, or strong)<br>
class Qualifiers {<br>
@@ -152,8 +153,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 +266,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 +441,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.hasUnaligned() || hasUnaligned());<br>
}<br>
<br>
/// \brief Determines if these qualifiers compatibly include another set of<br>
@@ -501,16 +511,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>
@@ -5367,9 +5380,9 @@ inline FunctionType::ExtInfo getFunction<br>
/// "int". However, it is not more qualified than "const volatile<br>
/// int".<br>
inline bool QualType::isMoreQualifiedThan(QualType other) const {<br>
- Qualifiers myQuals = getQualifiers();<br>
- Qualifiers otherQuals = other.getQualifiers();<br>
- return (myQuals != otherQuals && myQuals.compatiblyIncludes(otherQuals));<br>
+ Qualifiers MyQuals = getQualifiers();<br>
+ Qualifiers OtherQuals = other.getQualifiers();<br>
+ return (MyQuals != OtherQuals && MyQuals.compatiblyIncludes(OtherQuals));<br>
}<br>
<br>
/// Determine whether this type is at last<br>
@@ -5377,7 +5390,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=269220&r1=269219&r2=269220&view=diff" rel="noreferrer" target="_blank">http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Basic/AddressSpaces.h?rev=269220&r1=269219&r2=269220&view=diff</a><br>
==============================================================================<br>
--- cfe/trunk/include/clang/Basic/AddressSpaces.h (original)<br>
+++ cfe/trunk/include/clang/Basic/AddressSpaces.h Wed May 11 13:38:21 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=269220&r1=269219&r2=269220&view=diff" rel="noreferrer" target="_blank">http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Basic/Attr.td?rev=269220&r1=269219&r2=269220&view=diff</a><br>
==============================================================================<br>
--- cfe/trunk/include/clang/Basic/Attr.td (original)<br>
+++ cfe/trunk/include/clang/Basic/Attr.td Wed May 11 13:38:21 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/Basic/DiagnosticSemaKinds.td<br>
URL: <a href="http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td?rev=269220&r1=269219&r2=269220&view=diff" rel="noreferrer" target="_blank">http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td?rev=269220&r1=269219&r2=269220&view=diff</a><br>
==============================================================================<br>
--- cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td (original)<br>
+++ cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td Wed May 11 13:38:21 2016<br>
@@ -3374,6 +3374,16 @@ def note_ovl_candidate_bad_cvr : Note<"c<br>
"%select{const|restrict|const and restrict|volatile|const and volatile|"<br>
"volatile and restrict|const, volatile, and restrict}3 qualifier"<br>
"%select{||s||s|s|s}3">;<br>
+def note_ovl_candidate_bad_unaligned : Note<"candidate "<br>
+ "%select{function|function|constructor|"<br>
+ "function |function |constructor |"<br>
+ "constructor (the implicit default constructor)|"<br>
+ "constructor (the implicit copy constructor)|"<br>
+ "constructor (the implicit move constructor)|"<br>
+ "function (the implicit copy assignment operator)|"<br>
+ "function (the implicit move assignment operator)|"<br>
+ "constructor (inherited)}0%1 not viable: "<br>
+ "%ordinal4 argument (%2) would lose __unaligned qualifier">;<br>
def note_ovl_candidate_bad_base_to_derived_conv : Note<"candidate "<br>
"%select{function|function|constructor|"<br>
"function |function |constructor |"<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=269220&r1=269219&r2=269220&view=diff" rel="noreferrer" target="_blank">http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Sema/DeclSpec.h?rev=269220&r1=269219&r2=269220&view=diff</a><br>
==============================================================================<br>
--- cfe/trunk/include/clang/Sema/DeclSpec.h (original)<br>
+++ cfe/trunk/include/clang/Sema/DeclSpec.h Wed May 11 13:38:21 2016<br>
@@ -313,7 +313,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>
@@ -344,7 +347,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>
@@ -386,7 +389,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>
@@ -540,6 +544,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>
@@ -549,6 +554,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>
@@ -1114,8 +1120,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>
@@ -1129,6 +1135,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>
@@ -1469,7 +1478,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>
@@ -1478,6 +1488,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=269220&r1=269219&r2=269220&view=diff" rel="noreferrer" target="_blank">http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Sema/Sema.h?rev=269220&r1=269219&r2=269220&view=diff</a><br>
==============================================================================<br>
--- cfe/trunk/include/clang/Sema/Sema.h (original)<br>
+++ cfe/trunk/include/clang/Sema/Sema.h Wed May 11 13:38:21 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=269220&r1=269219&r2=269220&view=diff" rel="noreferrer" target="_blank">http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/AST/MicrosoftMangle.cpp?rev=269220&r1=269219&r2=269220&view=diff</a><br>
==============================================================================<br>
--- cfe/trunk/lib/AST/MicrosoftMangle.cpp (original)<br>
+++ cfe/trunk/lib/AST/MicrosoftMangle.cpp Wed May 11 13:38:21 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=269220&r1=269219&r2=269220&view=diff" rel="noreferrer" target="_blank">http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/AST/TypePrinter.cpp?rev=269220&r1=269219&r2=269220&view=diff</a><br>
==============================================================================<br>
--- cfe/trunk/lib/AST/TypePrinter.cpp (original)<br>
+++ cfe/trunk/lib/AST/TypePrinter.cpp Wed May 11 13:38:21 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=269220&r1=269219&r2=269220&view=diff" rel="noreferrer" target="_blank">http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Parse/ParseDecl.cpp?rev=269220&r1=269219&r2=269220&view=diff</a><br>
==============================================================================<br>
--- cfe/trunk/lib/Parse/ParseDecl.cpp (original)<br>
+++ cfe/trunk/lib/Parse/ParseDecl.cpp Wed May 11 13:38:21 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>
@@ -4798,6 +4801,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>
@@ -4815,7 +4822,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>
@@ -5038,7 +5044,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=269220&r1=269219&r2=269220&view=diff" rel="noreferrer" target="_blank">http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Parse/ParseTentative.cpp?rev=269220&r1=269219&r2=269220&view=diff</a><br>
==============================================================================<br>
--- cfe/trunk/lib/Parse/ParseTentative.cpp (original)<br>
+++ cfe/trunk/lib/Parse/ParseTentative.cpp Wed May 11 13:38:21 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=269220&r1=269219&r2=269220&view=diff" rel="noreferrer" target="_blank">http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/DeclSpec.cpp?rev=269220&r1=269219&r2=269220&view=diff</a><br>
==============================================================================<br>
--- cfe/trunk/lib/Sema/DeclSpec.cpp (original)<br>
+++ cfe/trunk/lib/Sema/DeclSpec.cpp Wed May 11 13:38:21 2016<br>
@@ -494,6 +494,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>
@@ -796,6 +797,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>
@@ -961,10 +963,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=269220&r1=269219&r2=269220&view=diff" rel="noreferrer" target="_blank">http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaCodeComplete.cpp?rev=269220&r1=269219&r2=269220&view=diff</a><br>
==============================================================================<br>
--- cfe/trunk/lib/Sema/SemaCodeComplete.cpp (original)<br>
+++ cfe/trunk/lib/Sema/SemaCodeComplete.cpp Wed May 11 13:38:21 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=269220&r1=269219&r2=269220&view=diff" rel="noreferrer" target="_blank">http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaDecl.cpp?rev=269220&r1=269219&r2=269220&view=diff</a><br>
==============================================================================<br>
--- cfe/trunk/lib/Sema/SemaDecl.cpp (original)<br>
+++ cfe/trunk/lib/Sema/SemaDecl.cpp Wed May 11 13:38:21 2016<br>
@@ -3985,6 +3985,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>
@@ -4242,6 +4244,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=269220&r1=269219&r2=269220&view=diff" rel="noreferrer" target="_blank">http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaDeclObjC.cpp?rev=269220&r1=269219&r2=269220&view=diff</a><br>
==============================================================================<br>
--- cfe/trunk/lib/Sema/SemaDeclObjC.cpp (original)<br>
+++ cfe/trunk/lib/Sema/SemaDeclObjC.cpp Wed May 11 13:38:21 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=269220&r1=269219&r2=269220&view=diff" rel="noreferrer" target="_blank">http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaExpr.cpp?rev=269220&r1=269219&r2=269220&view=diff</a><br>
==============================================================================<br>
--- cfe/trunk/lib/Sema/SemaExpr.cpp (original)<br>
+++ cfe/trunk/lib/Sema/SemaExpr.cpp Wed May 11 13:38:21 2016<br>
@@ -7140,7 +7140,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=269220&r1=269219&r2=269220&view=diff" rel="noreferrer" target="_blank">http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaOverload.cpp?rev=269220&r1=269219&r2=269220&view=diff</a><br>
==============================================================================<br>
--- cfe/trunk/lib/Sema/SemaOverload.cpp (original)<br>
+++ cfe/trunk/lib/Sema/SemaOverload.cpp Wed May 11 13:38:21 2016<br>
@@ -2951,6 +2951,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>
@@ -4159,6 +4163,10 @@ Sema::CompareReferenceRelationship(Sourc<br>
T2Quals.removeObjCLifetime();<br>
}<br>
<br>
+ // MS compiler ignores __unaligned qualifier for references; do the same.<br>
+ T1Quals.removeUnaligned();<br>
+ T2Quals.removeUnaligned();<br>
+<br>
if (T1Quals == T2Quals)<br>
return Ref_Compatible;<br>
else if (T1Quals.compatiblyIncludes(T2Quals))<br>
@@ -4480,13 +4488,16 @@ TryReferenceInit(Sema &S, Expr *Init, Qu<br>
// initialization fails.<br>
//<br>
// Note that we only want to check address spaces and cvr-qualifiers here.<br>
- // ObjC GC and lifetime qualifiers aren't important.<br>
+ // ObjC GC, lifetime and unaligned qualifiers aren't important.<br>
Qualifiers T1Quals = T1.getQualifiers();<br>
Qualifiers T2Quals = T2.getQualifiers();<br>
T1Quals.removeObjCGCAttr();<br>
T1Quals.removeObjCLifetime();<br>
T2Quals.removeObjCGCAttr();<br>
T2Quals.removeObjCLifetime();<br>
+ // MS compiler ignores __unaligned qualifier for references; do the same.<br>
+ T1Quals.removeUnaligned();<br>
+ T2Quals.removeUnaligned();<br>
if (!T1Quals.compatiblyIncludes(T2Quals))<br>
return ICS;<br>
}<br>
@@ -9134,6 +9145,15 @@ static void DiagnoseBadConversion(Sema &<br>
MaybeEmitInheritedConstructorNote(S, Fn);<br>
return;<br>
}<br>
+<br>
+ if (FromQs.hasUnaligned() != ToQs.hasUnaligned()) {<br>
+ S.Diag(Fn->getLocation(), diag::note_ovl_candidate_bad_unaligned)<br>
+ << (unsigned) FnKind << FnDesc<br>
+ << (FromExpr ? FromExpr->getSourceRange() : SourceRange())<br>
+ << FromTy << FromQs.hasUnaligned() << I+1;<br>
+ MaybeEmitInheritedConstructorNote(S, Fn);<br>
+ return;<br>
+ }<br>
<br>
unsigned CVR = FromQs.getCVRQualifiers() & ~ToQs.getCVRQualifiers();<br>
assert(CVR && "unexpected qualifiers mismatch");<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=269220&r1=269219&r2=269220&view=diff" rel="noreferrer" target="_blank">http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaType.cpp?rev=269220&r1=269219&r2=269220&view=diff</a><br>
==============================================================================<br>
--- cfe/trunk/lib/Sema/SemaType.cpp (original)<br>
+++ cfe/trunk/lib/Sema/SemaType.cpp Wed May 11 13:38:21 2016<br>
@@ -1785,12 +1785,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>
@@ -1800,7 +1801,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>
@@ -1817,7 +1818,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>
@@ -2652,7 +2655,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>
@@ -2660,26 +2664,27 @@ 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>
- if (Quals & QualKinds[I].Mask) {<br>
+ for (auto &E : QualKinds) {<br>
+ if (Quals & E.Mask) {<br>
if (!QualStr.empty()) QualStr += ' ';<br>
- QualStr += QualKinds[I].Name;<br>
+ QualStr += E.Name;<br>
<br>
// If we have a location for the qualifier, offer a fixit.<br>
- SourceLocation QualLoc = QualKinds[I].Loc;<br>
+ SourceLocation QualLoc = E.Loc;<br>
if (QualLoc.isValid()) {<br>
FixIts[NumQuals] = FixItHint::CreateRemoval(QualLoc);<br>
if (Loc.isInvalid() ||<br>
@@ -2725,7 +2730,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>
@@ -2761,7 +2767,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=269220&r1=269219&r2=269220&view=diff" rel="noreferrer" target="_blank">http://llvm.org/viewvc/llvm-project/cfe/trunk/test/CodeGenCXX/mangle-ms-cxx11.cpp?rev=269220&r1=269219&r2=269220&view=diff</a><br>
==============================================================================<br>
--- cfe/trunk/test/CodeGenCXX/mangle-ms-cxx11.cpp (original)<br>
+++ cfe/trunk/test/CodeGenCXX/mangle-ms-cxx11.cpp Wed May 11 13:38:21 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=269220&r1=269219&r2=269220&view=diff" rel="noreferrer" target="_blank">http://llvm.org/viewvc/llvm-project/cfe/trunk/test/CodeGenCXX/mangle-ms-cxx14.cpp?rev=269220&r1=269219&r2=269220&view=diff</a><br>
==============================================================================<br>
--- cfe/trunk/test/CodeGenCXX/mangle-ms-cxx14.cpp (original)<br>
+++ cfe/trunk/test/CodeGenCXX/mangle-ms-cxx14.cpp Wed May 11 13:38:21 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=269220&r1=269219&r2=269220&view=diff" rel="noreferrer" target="_blank">http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Sema/MicrosoftExtensions.c?rev=269220&r1=269219&r2=269220&view=diff</a><br>
==============================================================================<br>
--- cfe/trunk/test/Sema/MicrosoftExtensions.c (original)<br>
+++ cfe/trunk/test/Sema/MicrosoftExtensions.c Wed May 11 13:38:21 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=269220&r1=269219&r2=269220&view=diff" rel="noreferrer" target="_blank">http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Sema/address_spaces.c?rev=269220&r1=269219&r2=269220&view=diff</a><br>
==============================================================================<br>
--- cfe/trunk/test/Sema/address_spaces.c (original)<br>
+++ cfe/trunk/test/Sema/address_spaces.c Wed May 11 13:38:21 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=269220&r1=269219&r2=269220&view=diff" rel="noreferrer" target="_blank">http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Sema/invalid-assignment-constant-address-space.c?rev=269220&r1=269219&r2=269220&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 Wed May 11 13:38:21 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=269220&r1=269219&r2=269220&view=diff" rel="noreferrer" target="_blank">http://llvm.org/viewvc/llvm-project/cfe/trunk/test/SemaCXX/MicrosoftExtensions.cpp?rev=269220&r1=269219&r2=269220&view=diff</a><br>
==============================================================================<br>
--- cfe/trunk/test/SemaCXX/MicrosoftExtensions.cpp (original)<br>
+++ cfe/trunk/test/SemaCXX/MicrosoftExtensions.cpp Wed May 11 13:38:21 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,69 @@ 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>
+struct aligned_type4 {<br>
+ int i;<br>
+};<br>
+<br>
+__unaligned int aligned_type4::*p1_aligned_type4 = &aligned_type4::i;<br>
+int aligned_type4::* __unaligned p2_aligned_type4 = &aligned_type4::i;<br>
+__unaligned int aligned_type4::* __unaligned p3_aligned_type4 = &aligned_type4::i;<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>
+ p1_aligned_type4 = p2_aligned_type4;<br>
+ p2_aligned_type4 = p1_aligned_type4; // expected-error {{assigning to 'int aligned_type4::*' from incompatible type '__unaligned int aligned_type4::*'}}<br>
+ p3_aligned_type4 = p1_aligned_type4;<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>
+// Test from PR27666<br>
+// We should accept type conversion of __unaligned to non-__unaligned references<br>
+typedef struct in_addr {<br>
+public:<br>
+ in_addr(in_addr &a) {} // expected-note {{candidate constructor not viable: no known conversion from '__unaligned IN_ADDR *' (aka '__unaligned in_addr *') to 'in_addr &' for 1st argument; dereference the argument with *}}<br>
+ in_addr(in_addr *a) {} // expected-note {{candidate constructor not viable: 1st argument ('__unaligned IN_ADDR *' (aka '__unaligned in_addr *')) would lose __unaligned qualifier}}<br>
+} IN_ADDR;<br>
+<br>
+void f(IN_ADDR __unaligned *a) {<br>
+ IN_ADDR local_addr = *a;<br>
+ IN_ADDR local_addr2 = a; // expected-error {{no viable conversion from '__unaligned IN_ADDR *' (aka '__unaligned in_addr *') to 'IN_ADDR' (aka 'in_addr')}}<br>
+}<br>
<br>
template<typename T> void h1(T (__stdcall M::* const )()) { }<br>
<br>
@@ -420,3 +484,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></blockquote></div></div></div></blockquote></div><br></div>
</div></div></blockquote></div><br></div>
</div></div></blockquote></div><br></div>