[cfe-commits] r89242 - in /cfe/trunk: lib/Sema/SemaOverload.cpp test/SemaCXX/overloaded-operator.cpp
Sebastian Redl
sebastian.redl at getdesigned.at
Wed Nov 18 12:39:26 PST 2009
Author: cornedbee
Date: Wed Nov 18 14:39:26 2009
New Revision: 89242
URL: http://llvm.org/viewvc/llvm-project?rev=89242&view=rev
Log:
Don't generate superfluous and ambiguous built-in candidates for multi-level array subscript and arithmetic. Fixes PR5546.
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=89242&r1=89241&r2=89242&view=diff
==============================================================================
--- cfe/trunk/lib/Sema/SemaOverload.cpp (original)
+++ cfe/trunk/lib/Sema/SemaOverload.cpp Wed Nov 18 14:39:26 2009
@@ -3022,6 +3022,12 @@
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 @@
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
Modified: cfe/trunk/test/SemaCXX/overloaded-operator.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/SemaCXX/overloaded-operator.cpp?rev=89242&r1=89241&r2=89242&view=diff
==============================================================================
--- cfe/trunk/test/SemaCXX/overloaded-operator.cpp (original)
+++ cfe/trunk/test/SemaCXX/overloaded-operator.cpp Wed Nov 18 14:39:26 2009
@@ -286,3 +286,13 @@
}
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]; }
+}
More information about the cfe-commits
mailing list