From a6150b48cea00ab31e9335cc73770327acc4cb3a Mon Sep 17 00:00:00 2001 From: Akira Hatanaka Date: Fri, 22 Nov 2019 12:26:54 -0800 Subject: [PATCH] [Sema] Use the canonical type in function isVector This fixes an assertion in Sema::CreateBuiltinBinOp that fails when one of the vector operand's element type is a typedef of __fp16. rdar://problem/55983556 --- clang/lib/Sema/SemaExpr.cpp | 2 +- clang/test/Sema/fp16vec-sema.c | 7 +++++++ 2 files changed, 8 insertions(+), 1 deletion(-) diff --git a/clang/lib/Sema/SemaExpr.cpp b/clang/lib/Sema/SemaExpr.cpp index 3be8af1..63a189a 100644 --- a/clang/lib/Sema/SemaExpr.cpp +++ b/clang/lib/Sema/SemaExpr.cpp @@ -8155,7 +8155,7 @@ Sema::CheckAssignmentConstraints(SourceLocation Loc, /// type ElementType. static bool isVector(QualType QT, QualType ElementType) { if (const VectorType *VT = QT->getAs()) - return VT->getElementType() == ElementType; + return VT->getElementType().getCanonicalType() == ElementType; return false; } diff --git a/clang/test/Sema/fp16vec-sema.c b/clang/test/Sema/fp16vec-sema.c index aefb5f8..3d02822 100644 --- a/clang/test/Sema/fp16vec-sema.c +++ b/clang/test/Sema/fp16vec-sema.c @@ -4,6 +4,7 @@ typedef __fp16 half4 __attribute__ ((vector_size (8))); typedef float float4 __attribute__ ((vector_size (16))); typedef short short4 __attribute__ ((vector_size (8))); typedef int int4 __attribute__ ((vector_size (16))); +typedef __fp16 float16_t; half4 hv0, hv1; float4 fv0, fv1; @@ -49,3 +50,9 @@ void testFP16Vec(int c) { hv0++; // expected-error{{cannot increment value of type}} ++hv0; // expected-error{{cannot increment value of type}} } + +void testTypeDef() { + __fp16 t0 __attribute__((vector_size (8))); + float16_t t1 __attribute__((vector_size (8))); + t1 = t0; +} -- 2.7.4