Page MenuHomePhabricator

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

Authored by arcbbb on Jun 3 2021, 3:01 AM.

Details

Summary

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 ?:.

Diff Detail

Event Timeline

arcbbb created this revision.Jun 3 2021, 3:01 AM
arcbbb requested review of this revision.Jun 3 2021, 3:01 AM
Herald added a project: Restricted Project. · View Herald TranscriptJun 3 2021, 3:01 AM
Herald added a subscriber: cfe-commits. · View Herald Transcript

Testcase for AArch64/SVE:

#include <arm_sve.h>

svint8_t a();
__SVInt8_t b();

svint8_t foo(int cond){
  return cond ? a(): b();
}

The testcase I provided in last comment could be compile successfully with aarch64-gcc, but failed on clang.

Thanks for the fix. I agree this is the right behaviour FWIW. I held off approving it in case there's another idiom that's preferred when comparing canonical types.

Testcase for AArch64/SVE:

#include <arm_sve.h>

svint8_t a();
__SVInt8_t b();

svint8_t foo(int cond){
  return cond ? a(): b();
}

Could that AArch64 test also be part of this patch?

jrtc27 requested changes to this revision.Jun 3 2021, 4:21 AM
jrtc27 added inline comments.
clang/lib/Sema/SemaExpr.cpp
8397

This is Context.hasSameType, and the braces are unnecessary.

This revision now requires changes to proceed.Jun 3 2021, 4:21 AM
Matt added a subscriber: Matt.Jun 3 2021, 8:40 AM
arcbbb updated this revision to Diff 349600.Jun 3 2021, 10:26 AM
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.

Add a case in AArch64 test and address review comments.

rjmccall accepted this revision.Jun 3 2021, 6:46 PM

LGTM

This revision was not accepted when it landed; it landed in state Needs Review.Jun 4 2021, 12:33 AM
This revision was automatically updated to reflect the committed changes.