[PATCH] D103603: [Sema][RISCV][SVE] Allow ?: to select Typedef BuiltinType in C

ShihPo Hung via Phabricator via cfe-commits cfe-commits at lists.llvm.org
Thu Jun 3 10:26:53 PDT 2021


arcbbb updated this revision to Diff 349600.
arcbbb marked an inline comment as done.
arcbbb retitled this revision from "[Sema][RISCV] Allow ?: to select Typedef BuiltinType in C" to "[Sema][RISCV][SVE] Allow ?: to select Typedef BuiltinType in C".
arcbbb added a reviewer: frasercrmck.
arcbbb added a comment.
Herald added a subscriber: tschuett.

Add a case in AArch64 test and address review comments.


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D103603/new/

https://reviews.llvm.org/D103603

Files:
  clang/lib/Sema/SemaExpr.cpp
  clang/test/Sema/riscv-types.c
  clang/test/Sema/sizeless-1.c


Index: clang/test/Sema/sizeless-1.c
===================================================================
--- clang/test/Sema/sizeless-1.c
+++ clang/test/Sema/sizeless-1.c
@@ -57,6 +57,7 @@
   static svint8_t static_int8; // expected-error {{non-local variable with sizeless type 'svint8_t'}}
 
   svint8_t local_int8;
+  int8_typedef typedef_int8;
   svint16_t local_int16;
 
   svint8_t __attribute__((aligned)) aligned_int8_1;    // expected-error {{'aligned' attribute cannot be applied to sizeless type 'svint8_t'}}
@@ -137,6 +138,7 @@
   const_volatile_int8 = local_int8; // expected-error {{cannot assign to variable 'const_volatile_int8' with const-qualified type 'const volatile svint8_t'}}
 
   init_int8 = sel ? init_int8 : local_int8;
+  init_int8 = sel ? init_int8 : typedef_int8;
   init_int8 = sel ? init_int8 : const_int8;
   init_int8 = sel ? volatile_int8 : const_int8;
   init_int8 = sel ? volatile_int8 : const_volatile_int8;
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,7 +8393,7 @@
 
   // Allow ?: operations in which both operands have the same
   // built-in sizeless type.
-  if (LHSTy->isSizelessBuiltinType() && LHSTy == RHSTy)
+  if (LHSTy->isSizelessBuiltinType() && Context.hasSameType(LHSTy, RHSTy))
     return LHSTy;
 
   // Emit a better diagnostic if one of the expressions is a null pointer


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D103603.349600.patch
Type: text/x-patch
Size: 1957 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20210603/902dc33a/attachment.bin>


More information about the cfe-commits mailing list