[cfe-commits] r49199 - /cfe/trunk/lib/Sema/SemaExpr.cpp

Nate Begeman natebegeman at mac.com
Thu Apr 3 18:30:26 PDT 2008


Author: sampo
Date: Thu Apr  3 20:30:25 2008
New Revision: 49199

URL: http://llvm.org/viewvc/llvm-project?rev=49199&view=rev
Log:
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)

Modified:
    cfe/trunk/lib/Sema/SemaExpr.cpp

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

==============================================================================
--- cfe/trunk/lib/Sema/SemaExpr.cpp (original)
+++ cfe/trunk/lib/Sema/SemaExpr.cpp Thu Apr  3 20:30:25 2008
@@ -1286,10 +1286,13 @@
 
 inline QualType Sema::CheckVectorOperands(SourceLocation loc, Expr *&lex, 
                                                               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. 
-  if (lhsType.getCanonicalType() == rhsType.getCanonicalType())
+  if (lhsType == rhsType)
     return lhsType;
 
   // if the lhs is an ocu vector and the rhs is a scalar of the same type,





More information about the cfe-commits mailing list