From 783faa4728c59b3ec494ebfc1a6a08597c085756 Mon Sep 17 00:00:00 2001 From: Jason Merrill Date: Mon, 13 May 2013 15:32:35 -0400 Subject: [PATCH] re PR c++/57041 (ICE in lookup_field_1, at cp/search.c:376 (with dot-prefixed structure initialisation)) PR c++/57041 * decl.c (reshape_init_class): Handle error_mark_node. From-SVN: r198844 --- gcc/cp/ChangeLog | 3 +++ gcc/cp/decl.c | 3 +++ gcc/testsuite/g++.dg/ext/desig6.C | 18 ++++++++++++++++++ 3 files changed, 24 insertions(+) create mode 100644 gcc/testsuite/g++.dg/ext/desig6.C diff --git a/gcc/cp/ChangeLog b/gcc/cp/ChangeLog index 6c5d210..33c66e3 100644 --- a/gcc/cp/ChangeLog +++ b/gcc/cp/ChangeLog @@ -1,5 +1,8 @@ 2013-05-13 Jason Merrill + PR c++/57041 + * decl.c (reshape_init_class): Handle error_mark_node. + PR c++/57254 * typeck.c (merge_types): Propagate ref-qualifier in METHOD_TYPE case. diff --git a/gcc/cp/decl.c b/gcc/cp/decl.c index 67e67e6..b16472f 100644 --- a/gcc/cp/decl.c +++ b/gcc/cp/decl.c @@ -5200,6 +5200,9 @@ reshape_init_class (tree type, reshape_iter *d, bool first_initializer_p, /* Handle designated initializers, as an extension. */ if (d->cur->index) { + if (d->cur->index == error_mark_node) + return error_mark_node; + if (TREE_CODE (d->cur->index) == INTEGER_CST) { if (complain & tf_error) diff --git a/gcc/testsuite/g++.dg/ext/desig6.C b/gcc/testsuite/g++.dg/ext/desig6.C new file mode 100644 index 0000000..30882a6 --- /dev/null +++ b/gcc/testsuite/g++.dg/ext/desig6.C @@ -0,0 +1,18 @@ +// PR c++/57041 +// { dg-options "-std=gnu++11" } +// { dg-prune-output "error:" } + +template +union u { + T a; + char b; +}; + +template +u make_u(T t) { + return { .a = t }; +} + +int main() { + return make_u(1).a; +} -- 2.7.4