arcbbb created this revision. arcbbb added reviewers: rsandifo-arm, efriedma, sdesmalen, rovka, rjmccall, rengolin, HsiangKai, craig.topper. Herald added subscribers: vkmr, frasercrmck, evandro, luismarques, apazos, sameer.abuasal, s.egerton, Jim, benna, psnobl, jocewei, PkmX, the_o, brucehoult, MartinMosbeck, rogfer01, edward-jones, zzheng, jrtc27, shiva0217, kito-cheng, niosHD, sabuasal, simoncook, johnrusso, rbar, asb. arcbbb requested review of this revision. Herald added a project: clang. Herald added a subscriber: cfe-commits.
This patch solves an error such as: incompatible operand types ('vbool4_t' (aka '__rvv_bool4_t') and '__rvv_bool4_t') when one of the value is a TypedefType of the other value in ?:. Repository: rG LLVM Github Monorepo https://reviews.llvm.org/D103603 Files: clang/lib/Sema/SemaExpr.cpp clang/test/Sema/riscv-types.c Index: clang/test/Sema/riscv-types.c =================================================================== --- clang/test/Sema/riscv-types.c +++ clang/test/Sema/riscv-types.c @@ -134,3 +134,12 @@ // CHECK: __rvv_int8mf2_t x43; __rvv_int8mf2_t x43; } + +typedef __rvv_bool4_t vbool4_t; +__rvv_bool4_t get_rvv_bool4(); +vbool4_t get_vbool4_t(); + +void func1(int sel) { + // CHECK: vbool4_t t0 = sel ? get_rvv_bool4() : get_vbool4_t(); + vbool4_t t0 = sel ? get_rvv_bool4() : get_vbool4_t(); +} Index: clang/lib/Sema/SemaExpr.cpp =================================================================== --- clang/lib/Sema/SemaExpr.cpp +++ clang/lib/Sema/SemaExpr.cpp @@ -8393,8 +8393,10 @@ // Allow ?: operations in which both operands have the same // built-in sizeless type. - if (LHSTy->isSizelessBuiltinType() && LHSTy == RHSTy) + if (LHSTy->isSizelessBuiltinType() && + (Context.getCanonicalType(LHSTy) == Context.getCanonicalType(RHSTy))) { return LHSTy; + } // Emit a better diagnostic if one of the expressions is a null pointer // constant and the other is not a pointer type. In this case, the user most
Index: clang/test/Sema/riscv-types.c =================================================================== --- clang/test/Sema/riscv-types.c +++ clang/test/Sema/riscv-types.c @@ -134,3 +134,12 @@ // CHECK: __rvv_int8mf2_t x43; __rvv_int8mf2_t x43; } + +typedef __rvv_bool4_t vbool4_t; +__rvv_bool4_t get_rvv_bool4(); +vbool4_t get_vbool4_t(); + +void func1(int sel) { + // CHECK: vbool4_t t0 = sel ? get_rvv_bool4() : get_vbool4_t(); + vbool4_t t0 = sel ? get_rvv_bool4() : get_vbool4_t(); +} Index: clang/lib/Sema/SemaExpr.cpp =================================================================== --- clang/lib/Sema/SemaExpr.cpp +++ clang/lib/Sema/SemaExpr.cpp @@ -8393,8 +8393,10 @@ // Allow ?: operations in which both operands have the same // built-in sizeless type. - if (LHSTy->isSizelessBuiltinType() && LHSTy == RHSTy) + if (LHSTy->isSizelessBuiltinType() && + (Context.getCanonicalType(LHSTy) == Context.getCanonicalType(RHSTy))) { return LHSTy; + } // Emit a better diagnostic if one of the expressions is a null pointer // constant and the other is not a pointer type. In this case, the user most
_______________________________________________ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits