[PATCH] D155572: [clang][Interp] Start implementing binary operators for complex types
Aaron Ballman via Phabricator via cfe-commits
cfe-commits at lists.llvm.org
Thu Sep 28 09:30:47 PDT 2023
aaron.ballman accepted this revision.
aaron.ballman added a comment.
This revision is now accepted and ready to land.
In D155572#4646353 <https://reviews.llvm.org/D155572#4646353>, @tbaeder wrote:
> In D155572#4645997 <https://reviews.llvm.org/D155572#4645997>, @aaron.ballman wrote:
>
>> Hmmm, I think the answer is "no"... and "maybe." `_Complex` can only be followed by `float`, `double`, or `long double` specifically per the C standard. However, we also support `_Complex int` (and others) as an extension, which starts to make `_Complex` look more like `_Atomic` in that it augments an existing type, and so typedefs seem quite reasonable.
>
> I know that much, I guess I was confused by the diagnostics:
>
> ../clang/test/AST/Interp/complex.cpp:121:18: warning: plain '_Complex' requires a type specifier; assuming '_Complex double'
> 121 | using Gobble = _Complex Frobble;
> | ^
> | double
Yeah, that diagnostic could stand to be improved; but is orthogonal to your patch.
LGTM though there's a comment on the test cases you should peek at.
================
Comment at: clang/test/AST/Interp/complex.cpp:119-124
+ using Bobble = _Complex float;
+ constexpr _Complex float A = { 13.0, 2.0 };
+ constexpr Bobble B = { 2.0, 1.0 };
+ constexpr _Complex float D = A - B;
+ static_assert(__real(D) == 11.0, "");
+ static_assert(__imag(D) == 1.0, "");
----------------
Should this be under the `Sub` namespace instead of hanging out by itself?
CHANGES SINCE LAST ACTION
https://reviews.llvm.org/D155572/new/
https://reviews.llvm.org/D155572
More information about the cfe-commits
mailing list