]> granicus.if.org Git - clang/commitdiff
Ignore qualifiers when checking vector operands, just like scalar operands.
authorNate Begeman <natebegeman@mac.com>
Fri, 4 Apr 2008 01:30:25 +0000 (01:30 +0000)
committerNate Begeman <natebegeman@mac.com>
Fri, 4 Apr 2008 01:30:25 +0000 (01:30 +0000)
This prevents things like
a += b[0]; where a is a float4 and b is a float4 * (address_space 1)

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@49199 91177308-0d34-0410-b5e6-96231b3b80d8

lib/Sema/SemaExpr.cpp

index d4a97c1f8c9558b95096a0a712a48b6472199354..1c6044a744ae516b9bc34c7cdf36b2be4869a19e 100644 (file)
@@ -1286,10 +1286,13 @@ QualType Sema::InvalidOperands(SourceLocation loc, Expr *&lex, Expr *&rex) {
 
 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,