Ignore qualifiers when checking vector operands, just like scalar operands.

This prevents things like 
a += b[0]; where a is a float4 and b is a float4 * (address_space 1)

llvm-svn: 49199
This commit is contained in:
Nate Begeman 2008-04-04 01:30:25 +00:00
parent 14bee50e06
commit 002e4bd158
1 changed files with 5 additions and 2 deletions

View File

@ -1286,10 +1286,13 @@ QualType Sema::InvalidOperands(SourceLocation loc, Expr *&lex, Expr *&rex) {
inline QualType Sema::CheckVectorOperands(SourceLocation loc, Expr *&lex, inline QualType Sema::CheckVectorOperands(SourceLocation loc, Expr *&lex,
Expr *&rex) { Expr *&rex) {
QualType lhsType = lex->getType(), rhsType = rex->getType(); // For conversion purposes, we ignore any qualifiers.
// For example, "const float" and "float" are equivalent.
QualType lhsType = lex->getType().getCanonicalType().getUnqualifiedType();
QualType rhsType = rex->getType().getCanonicalType().getUnqualifiedType();
// make sure the vector types are identical. // make sure the vector types are identical.
if (lhsType.getCanonicalType() == rhsType.getCanonicalType()) if (lhsType == rhsType)
return lhsType; return lhsType;
// if the lhs is an ocu vector and the rhs is a scalar of the same type, // if the lhs is an ocu vector and the rhs is a scalar of the same type,