[PATCH] D20103: PR27132: Proper mangling for __unaligned qualifier (now with both PR27367 and PR27666 fixed)

Andrey Bokhanko via cfe-commits cfe-commits at lists.llvm.org
Wed May 11 04:25:07 PDT 2016


andreybokhanko marked 3 inline comments as done.
andreybokhanko added a comment.

In http://reviews.llvm.org/D20103#425855, @majnemer wrote:

> Can we test pointers to data members? Is it possible to have `__unaligned int *S::*` or `int *S::* __unaligned` or even `__unaligned int *S::* __unaligned` ?


I added these three cases to MicrosoftExtensions.cpp. We behave exactly like MS compiler: allow all three usages, disallow assignment of an unaligned pointer to a non-unaligned one.


================
Comment at: include/clang/AST/Type.h:446
@@ -437,1 +445,3 @@
+           // U qualifier may superset.
+           (!other.hasUnaligned() || hasUnaligned());
   }
----------------
Fixed

================
Comment at: include/clang/AST/Type.h:5393-5399
@@ -5379,3 +5392,9 @@
 inline bool QualType::isAtLeastAsQualifiedAs(QualType other) const {
-  return getQualifiers().compatiblyIncludes(other.getQualifiers());
+  Qualifiers OtherQuals = other.getQualifiers();
+
+  // Ignore __unaligned qualifier if this type is a void.
+  if (getUnqualifiedType()->isVoidType())
+    OtherQuals.removeUnaligned();
+
+  return getQualifiers().compatiblyIncludes(OtherQuals);
 }
----------------
Fixed

================
Comment at: lib/Sema/SemaType.cpp:2680-2681
@@ -2674,4 +2679,4 @@
 
   // Build a string naming the redundant qualifiers.
-  for (unsigned I = 0; I != 4; ++I) {
-    if (Quals & QualKinds[I].Mask) {
+  for (auto &E : QualKinds) {
+    if (Quals & E.Mask) {
----------------
Fixed


http://reviews.llvm.org/D20103





More information about the cfe-commits mailing list