aboutsummaryrefslogtreecommitdiff
path: root/gcc/omp-expand.c
diff options
context:
space:
mode:
authorMarek Polacek <polacek@redhat.com>2020-07-10 17:39:54 -0400
committerMarek Polacek <polacek@redhat.com>2020-08-12 20:53:35 -0400
commit2ec803e768a820c9208fea2e8b144ee359379139 (patch)
treec4b048520c0be28004ec167a05e26136311aa62d /gcc/omp-expand.c
parentafdd220a0ccf9d5a689b6aceccd8327213a51b9b (diff)
downloadgcc-2ec803e768a820c9208fea2e8b144ee359379139.zip
gcc-2ec803e768a820c9208fea2e8b144ee359379139.tar.gz
gcc-2ec803e768a820c9208fea2e8b144ee359379139.tar.bz2
c++: Fixing the wording of () aggregate-init [PR92812]
P1975R0 tweaks the static_cast wording: it says that "An expression e can be explicitly converted to a type T if [...] T is an aggregate type having a first element x and there is an implicit conversion sequence from e to the type of x." This already works for classes, e.g.: struct Aggr { int x; int y; }; Aggr a = static_cast<Aggr>(1); for which we create TARGET_EXPR <D.2111, {.x=1}>. The proposal also mentions "If T is ``array of unknown bound of U'', this direct-initialization defines the type of the expression as U[1]" which suggest that this should work for arrays (they're aggregates too, after all): int (&&r)[3] = static_cast<int[3]>(42); int (&&r2)[1] = static_cast<int[]>(42); So I handled that specifically in build_static_cast_1: wrap the expression in { } and initialize from that. For the 'r' case above this creates TARGET_EXPR <D.2083, {42}>. There are multiple things in play, as usual, so the tests test brace elision, narrowing, explicit constructors, and lifetime extension too. I think it's in line with what we discussed on the core reflector. gcc/cp/ChangeLog: PR c++/92812 * typeck.c (build_static_cast_1): Implement P1975R0 by allowing static_cast to aggregate type. gcc/testsuite/ChangeLog: PR c++/92812 * g++.dg/cpp2a/paren-init27.C: New test. * g++.dg/cpp2a/paren-init28.C: New test. * g++.dg/cpp2a/paren-init29.C: New test. * g++.dg/cpp2a/paren-init30.C: New test. * g++.dg/cpp2a/paren-init31.C: New test. * g++.dg/cpp2a/paren-init32.C: New test.
Diffstat (limited to 'gcc/omp-expand.c')
0 files changed, 0 insertions, 0 deletions