[PATCH] D147263: Fix an assertion failure in unwrapSugar

Akira Hatanaka via Phabricator via cfe-commits cfe-commits at lists.llvm.org
Wed Apr 12 16:48:51 PDT 2023


This revision was landed with ongoing or failed builds.
This revision was automatically updated to reflect the committed changes.
Closed by commit rG2ba88443b31a: Fix an assertion failure in unwrapSugar (authored by ahatanak).

Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D147263/new/

https://reviews.llvm.org/D147263

Files:
  clang/lib/AST/ASTContext.cpp
  clang/test/SemaCXX/sugar-common-types.cpp


Index: clang/test/SemaCXX/sugar-common-types.cpp
===================================================================
--- clang/test/SemaCXX/sugar-common-types.cpp
+++ clang/test/SemaCXX/sugar-common-types.cpp
@@ -1,4 +1,4 @@
-// RUN: %clang_cc1 -fsyntax-only -verify %s -std=c++20 -fenable-matrix -triple i686-pc-win32
+// RUN: %clang_cc1 -fsyntax-only -verify %s -std=c++20 -x objective-c++ -fobjc-arc -fenable-matrix -triple i686-pc-win32
 
 enum class N {};
 
@@ -131,3 +131,14 @@
 auto t32 = 0 ? (UPX1){} : (UPY1){};
 N t33 = t32;  // expected-error {{lvalue of type 'C::type1' (aka 'int *')}}
 N t34 = *t32; // expected-error {{lvalue of type 'B1' (aka 'int')}}
+
+// See https://github.com/llvm/llvm-project/issues/61419
+namespace PR61419 {
+  template <class T0, class T1> struct pair {
+    T0 first;
+    T1 second;
+  };
+
+  extern const pair<id, id> p;
+  id t = false ? p.first : p.second;
+} // namespace PR61419
Index: clang/lib/AST/ASTContext.cpp
===================================================================
--- clang/lib/AST/ASTContext.cpp
+++ clang/lib/AST/ASTContext.cpp
@@ -13082,7 +13082,7 @@
 static auto unwrapSugar(SplitQualType &T, Qualifiers &QTotal) {
   SmallVector<SplitQualType, 8> R;
   while (true) {
-    QTotal += T.Quals;
+    QTotal.addConsistentQualifiers(T.Quals);
     QualType NT = T.Ty->getLocallyUnqualifiedSingleStepDesugaredType();
     if (NT == QualType(T.Ty, 0))
       break;


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D147263.513016.patch
Type: text/x-patch
Size: 1432 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20230412/d687ced1/attachment.bin>


More information about the cfe-commits mailing list