[cfe-commits] r86140 - in /cfe/trunk: lib/Sema/SemaOverload.cpp test/SemaCXX/overloaded-operator.cpp

Sebastian Redl sebastian.redl at getdesigned.at
Thu Nov 5 08:36:20 PST 2009


Author: cornedbee
Date: Thu Nov  5 10:36:20 2009
New Revision: 86140

URL: http://llvm.org/viewvc/llvm-project?rev=86140&view=rev
Log:
When collecting types for built-in candidates, make arrays decay to pointers. Otherwise, subscripting an array leads to no candidates at all. Fixes PR5360.

Modified:
    cfe/trunk/lib/Sema/SemaOverload.cpp
    cfe/trunk/test/SemaCXX/overloaded-operator.cpp

Modified: cfe/trunk/lib/Sema/SemaOverload.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaOverload.cpp?rev=86140&r1=86139&r2=86140&view=diff

==============================================================================
--- cfe/trunk/lib/Sema/SemaOverload.cpp (original)
+++ cfe/trunk/lib/Sema/SemaOverload.cpp Thu Nov  5 10:36:20 2009
@@ -3052,6 +3052,10 @@
   // We don't care about qualifiers on the type.
   Ty = Ty.getUnqualifiedType();
 
+  // If we're dealing with an array type, decay to the pointer.
+  if (Ty->isArrayType())
+    Ty = SemaRef.Context.getArrayDecayedType(Ty);
+
   if (const PointerType *PointerTy = Ty->getAs<PointerType>()) {
     QualType PointeeTy = PointerTy->getPointeeType();
 

Modified: cfe/trunk/test/SemaCXX/overloaded-operator.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/SemaCXX/overloaded-operator.cpp?rev=86140&r1=86139&r2=86140&view=diff

==============================================================================
--- cfe/trunk/test/SemaCXX/overloaded-operator.cpp (original)
+++ cfe/trunk/test/SemaCXX/overloaded-operator.cpp Thu Nov  5 10:36:20 2009
@@ -268,3 +268,14 @@
   CircA a;
   a->val = 0; // expected-error {{circular pointer delegation detected}}
 }
+
+// PR5360: Arrays should lead to built-in candidates for subscript.
+typedef enum {
+  LastReg = 23,
+} Register;
+class RegAlloc {
+  int getPriority(Register r) {
+    return usepri[r];
+  }
+  int usepri[LastReg + 1];
+};





More information about the cfe-commits mailing list