[PATCH] D98664: Fix crash on dumping AST containing constant initializer with ParenListExpr

Aaron Ballman via Phabricator via cfe-commits cfe-commits at lists.llvm.org
Tue Mar 16 06:09:53 PDT 2021


aaron.ballman accepted this revision.
aaron.ballman added a comment.
This revision is now accepted and ready to land.

In D98664#2628742 <https://reviews.llvm.org/D98664#2628742>, @aaronpuchert wrote:

> In D98664#2628591 <https://reviews.llvm.org/D98664#2628591>, @aaron.ballman wrote:
>
>> As far as the changes go, these seem reasonable to me, though I find it a bit odd that these are expressions without a type whereas a `ParenExpr` has a type of the underlying parenthesized expression. e.g.,
>>
>>   int x(0); // (0) has void type
>>   int y = (0); // (0) has int type
>>
>> I think my natural assumption is that the init expression would have the type of the thing that's being initialized.
>
> In this case the `int` type will be assigned when the initialization is carried out in Sema. The `void` will only remain if we are in a template and the variable being initialized has a dependent type, so we can't carry out the initialization. Also if there are errors. It's similar to `int y{0};` in that regard.
>
> If we don't know the type this syntax could be a constructor call, conversion operator call, but also regular value initialization. So we can't use `CXXUnresolvedConstructExpr` or something like that. That's my understanding.

Ah, thank you for the explanation, that makes sense.

>> Despite that, I think the changes LG, but I'd like to hear from @rsmith.
>
> So would I, also about whether to use the dependent type instead.

I'm giving my LG, but you should wait for a few days before landing to see if @rsmith has concerns.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D98664



More information about the cfe-commits mailing list