================
@@ -14171,6 +14171,15 @@ static QualType getCommonSugarTypeNode(ASTContext 
&Ctx, const Type *X,
 static auto unwrapSugar(SplitQualType &T, Qualifiers &QTotal) {
   SmallVector<SplitQualType, 8> R;
   while (true) {
+    if (const auto *ATy = dyn_cast<ArrayType>(T.Ty)) {
+      // C++ 9.3.3.4p3: Any type of the form "cv-qualifier-seq array of N U" is
+      // adjusted to "array of N cv-qualifier-seq U".
+      // C23 6.7.3p10: If the specification of an array type includes any type
+      // qualifiers, both the array and the element type are so-qualified.
+      //
+      // To simplify comparison remove the redundant qualifiers from the array.
+      T.Quals.removeCVRQualifiers(Qualifiers::Const | Qualifiers::Volatile);
----------------
efriedma-quic wrote:

Tossing the const qualifier is fine if the array element type is already 
const-qualified... but do we actually know it is at this point?  Or do we need 
something like `T.Ty = getAsArrayType(getQualifiedType(T))` to make sure the 
qualifiers get preserved?

https://github.com/llvm/llvm-project/pull/131649
_______________________________________________
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

Reply via email to