This is an archive of the discontinued LLVM Phabricator instance.

[Sema] Tweak error message for invalid vector/scalar combinations
Needs ReviewPublic

Authored by uweigand on Jul 13 2015, 9:16 AM.

Details

Reviewers
rsmith
Summary

Before the patch:

typedef unsigned int v4si attribute((ext_vector_type(4)));
void foo(v4si *ptr) { *ptr += 1.0f; }

would generate:

error: can't convert between vector values of different size ('v4si' (vector of 4 'unsigned int' values) and 'float')
void foo(v4si *ptr) { *ptr += 1.0f; }

~~~~ ^  ~~~~

This is a bit misleading, since the problem is a type mismatch between
the type of the scalar and the type of the vector elements, not a problem
with vectors of different size. (E.g. the code is correct with "1.0f"
replaced by the like-sized "1".) The patch changes the error to the more
generic:

error: invalid operands to binary expression ('v4si' (vector of 4 'unsigned int' values) and 'float')
void foo(v4si *ptr) { *ptr += 1.0f; }

~~~~ ^  ~~~~

Original patch by Richard Sandiford.

Diff Detail

Event Timeline

uweigand updated this revision to Diff 29584.Jul 13 2015, 9:16 AM
uweigand retitled this revision from to [Sema] Tweak error message for invalid vector/scalar combinations.
uweigand updated this object.
uweigand added a reviewer: rsmith.
uweigand added a subscriber: cfe-commits.