From: Marek Polacek Date: Fri, 20 Mar 2015 14:56:53 +0000 (+0000) Subject: re PR c++/65072 (Segfault when parsing dectlype in trailing return type) X-Git-Url: https://git.libre-soc.org/?a=commitdiff_plain;h=b75cebc4a74ccc72541875d847bc11889568f127;p=gcc.git re PR c++/65072 (Segfault when parsing dectlype in trailing return type) PR c++/65072 * typeck.c (lookup_anon_field): Make sure we're dealing with the main variant. * g++.dg/cpp0x/pr65072.C: New test. From-SVN: r221535 --- diff --git a/gcc/cp/ChangeLog b/gcc/cp/ChangeLog index f90e447cc98..dadf6739ad1 100644 --- a/gcc/cp/ChangeLog +++ b/gcc/cp/ChangeLog @@ -1,3 +1,9 @@ +2015-03-20 Marek Polacek + + PR c++/65072 + * typeck.c (lookup_anon_field): Make sure we're dealing with the main + variant. + 2015-03-19 Jason Merrill PR c++/65046 diff --git a/gcc/cp/typeck.c b/gcc/cp/typeck.c index 4c128b7ebe4..e9d4cae5705 100644 --- a/gcc/cp/typeck.c +++ b/gcc/cp/typeck.c @@ -2213,6 +2213,8 @@ lookup_anon_field (tree t, tree type) { tree field; + t = TYPE_MAIN_VARIANT (t); + for (field = TYPE_FIELDS (t); field; field = DECL_CHAIN (field)) { if (TREE_STATIC (field)) diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog index 884fb627459..c489b28c3e4 100644 --- a/gcc/testsuite/ChangeLog +++ b/gcc/testsuite/ChangeLog @@ -1,3 +1,8 @@ +2015-03-20 Marek Polacek + + PR c++/65072 + * g++.dg/cpp0x/pr65072.C: New test. + 2015-03-20 Richard Biener PR middle-end/64715 diff --git a/gcc/testsuite/g++.dg/cpp0x/pr65072.C b/gcc/testsuite/g++.dg/cpp0x/pr65072.C new file mode 100644 index 00000000000..b8fa8885dcf --- /dev/null +++ b/gcc/testsuite/g++.dg/cpp0x/pr65072.C @@ -0,0 +1,14 @@ +// PR c++/65075 +// { dg-do compile { target c++11 } } +// { dg-options "-Wno-pedantic" } + +template class C +{ + struct + { + int i; + }; + auto operator*(const C m) -> decltype (m.i); +}; +void fn1 (const C); +C a;