]> granicus.if.org Git - clang/commitdiff
Don't generate superfluous and ambiguous built-in candidates for multi-level array...
authorSebastian Redl <sebastian.redl@getdesigned.at>
Wed, 18 Nov 2009 20:39:26 +0000 (20:39 +0000)
committerSebastian Redl <sebastian.redl@getdesigned.at>
Wed, 18 Nov 2009 20:39:26 +0000 (20:39 +0000)
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@89242 91177308-0d34-0410-b5e6-96231b3b80d8

lib/Sema/SemaOverload.cpp
test/SemaCXX/overloaded-operator.cpp

index c9c16aafc4122d01ffed13a364ea3761672e02dd..916fe571922091a49c67d54af432e35c2fc88784 100644 (file)
@@ -3022,6 +3022,12 @@ BuiltinCandidateTypeSet::AddPointerWithMoreQualifiedTypeVariants(QualType Ty,
   assert(PointerTy && "type was not a pointer type!");
 
   QualType PointeeTy = PointerTy->getPointeeType();
+  // Don't add qualified variants of arrays. For one, they're not allowed
+  // (the qualifier would sink to the element type), and for another, the
+  // only overload situation where it matters is subscript or pointer +- int,
+  // and those shouldn't have qualifier variants anyway.
+  if (PointeeTy->isArrayType())
+    return true;
   unsigned BaseCVR = PointeeTy.getCVRQualifiers();
   if (const ConstantArrayType *Array =Context.getAsConstantArrayType(PointeeTy))
     BaseCVR = Array->getElementType().getCVRQualifiers();
@@ -3062,6 +3068,12 @@ BuiltinCandidateTypeSet::AddMemberPointerWithMoreQualifiedTypeVariants(
   assert(PointerTy && "type was not a member pointer type!");
 
   QualType PointeeTy = PointerTy->getPointeeType();
+  // Don't add qualified variants of arrays. For one, they're not allowed
+  // (the qualifier would sink to the element type), and for another, the
+  // only overload situation where it matters is subscript or pointer +- int,
+  // and those shouldn't have qualifier variants anyway.
+  if (PointeeTy->isArrayType())
+    return true;
   const Type *ClassTy = PointerTy->getClass();
 
   // Iterate through all strict supersets of the pointee type's CVR
index 7762667d1aba3485d44ad4cec25d6d6ca7454a17..5fdbeebdfd1ffbd96abd029a7ff6b4759a6b85ea 100644 (file)
@@ -286,3 +286,13 @@ class RegAlloc {
   }
   int usepri[LastReg + 1];
 };
+
+// PR5546: Don't generate incorrect and ambiguous overloads for multi-level
+// arrays.
+namespace pr5546
+{
+  enum { X };
+  extern const char *const sMoveCommands[][2][2];
+  const char* a() { return sMoveCommands[X][0][0]; }
+  const char* b() { return (*(sMoveCommands+X))[0][0]; }
+}