From 0a1c6c2ee5cf889dcbd4f8f1657955bb9fc8a7c7 Mon Sep 17 00:00:00 2001 From: Xiuli Pan Date: Wed, 30 Mar 2016 04:46:32 +0000 Subject: [OpenCL] Fix pipe builtin bugs Summary: 1. Diag should be output if types are not the same. 2. Should compare using canonical type. 3. Refine the diag to be more clear. Reviewers: yaxunl, Anastasia Subscribers: MatsPetersson, pekka.jaaskelainen, cfe-commits Differential Revision: http://reviews.llvm.org/D17955 llvm-svn: 264825 --- clang/lib/Sema/SemaChecking.cpp | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-) (limited to 'clang/lib/Sema') diff --git a/clang/lib/Sema/SemaChecking.cpp b/clang/lib/Sema/SemaChecking.cpp index 062041e3771..6f9060be84c 100644 --- a/clang/lib/Sema/SemaChecking.cpp +++ b/clang/lib/Sema/SemaChecking.cpp @@ -325,10 +325,12 @@ static bool checkOpenCLPipePacketType(Sema &S, CallExpr *Call, unsigned Idx) { const PointerType *ArgTy = ArgIdx->getType()->getAs(); // The Idx argument should be a pointer and the type of the pointer and // the type of pipe element should also be the same. - if (!ArgTy || S.Context.hasSameType(EltTy, ArgTy->getPointeeType())) { + if (!ArgTy || + !S.Context.hasSameType( + EltTy, ArgTy->getPointeeType()->getCanonicalTypeInternal())) { S.Diag(Call->getLocStart(), diag::err_opencl_builtin_pipe_invalid_arg) << Call->getDirectCallee() << S.Context.getPointerType(EltTy) - << ArgIdx->getSourceRange(); + << ArgIdx->getType() << ArgIdx->getSourceRange(); return true; } return false; @@ -361,7 +363,7 @@ static bool SemaBuiltinRWPipe(Sema &S, CallExpr *Call) { if (!Call->getArg(1)->getType()->isReserveIDT()) { S.Diag(Call->getLocStart(), diag::err_opencl_builtin_pipe_invalid_arg) << Call->getDirectCallee() << S.Context.OCLReserveIDTy - << Call->getArg(1)->getSourceRange(); + << Call->getArg(1)->getType() << Call->getArg(1)->getSourceRange(); return true; } @@ -371,7 +373,7 @@ static bool SemaBuiltinRWPipe(Sema &S, CallExpr *Call) { !Arg2->getType()->isUnsignedIntegerType()) { S.Diag(Call->getLocStart(), diag::err_opencl_builtin_pipe_invalid_arg) << Call->getDirectCallee() << S.Context.UnsignedIntTy - << Arg2->getSourceRange(); + << Arg2->getType() << Arg2->getSourceRange(); return true; } @@ -405,7 +407,7 @@ static bool SemaBuiltinReserveRWPipe(Sema &S, CallExpr *Call) { !Call->getArg(1)->getType()->isUnsignedIntegerType()) { S.Diag(Call->getLocStart(), diag::err_opencl_builtin_pipe_invalid_arg) << Call->getDirectCallee() << S.Context.UnsignedIntTy - << Call->getArg(1)->getSourceRange(); + << Call->getArg(1)->getType() << Call->getArg(1)->getSourceRange(); return true; } @@ -428,7 +430,7 @@ static bool SemaBuiltinCommitRWPipe(Sema &S, CallExpr *Call) { if (!Call->getArg(1)->getType()->isReserveIDT()) { S.Diag(Call->getLocStart(), diag::err_opencl_builtin_pipe_invalid_arg) << Call->getDirectCallee() << S.Context.OCLReserveIDTy - << Call->getArg(1)->getSourceRange(); + << Call->getArg(1)->getType() << Call->getArg(1)->getSourceRange(); return true; } -- cgit v1.2.3