From ffe79825902c65abf908d8376329f4a85269af60 Mon Sep 17 00:00:00 2001 From: Paolo Carlini Date: Thu, 28 Aug 2008 23:37:41 +0000 Subject: [PATCH] re PR c++/37260 (infinite loop in init) /cp 2008-08-28 Paolo Carlini PR c++/37260 * decl.c (reshape_init_r): Check init for error_mark_node. /testsuite 2008-08-28 Paolo Carlini PR c++/37260 * g++.dg/parse/crash44.C: New. From-SVN: r139740 --- gcc/cp/ChangeLog | 5 +++++ gcc/cp/decl.c | 3 +++ gcc/testsuite/ChangeLog | 5 +++++ gcc/testsuite/g++.dg/parse/crash44.C | 15 +++++++++++++++ 4 files changed, 28 insertions(+) create mode 100644 gcc/testsuite/g++.dg/parse/crash44.C diff --git a/gcc/cp/ChangeLog b/gcc/cp/ChangeLog index 7d2266c65eb..b462401c654 100644 --- a/gcc/cp/ChangeLog +++ b/gcc/cp/ChangeLog @@ -1,3 +1,8 @@ +2008-08-28 Paolo Carlini + + PR c++/37260 + * decl.c (reshape_init_r): Check init for error_mark_node. + 2008-08-27 Manuel Lopez-Ibanez PR c++/17880 diff --git a/gcc/cp/decl.c b/gcc/cp/decl.c index 2f5d6ebd13f..c3d63bbeaad 100644 --- a/gcc/cp/decl.c +++ b/gcc/cp/decl.c @@ -4772,6 +4772,9 @@ reshape_init_r (tree type, reshape_iter *d, bool first_initializer_p) { tree init = d->cur->value; + if (error_operand_p (init)) + return error_mark_node; + /* A non-aggregate type is always initialized with a single initializer. */ if (!CP_AGGREGATE_TYPE_P (type)) diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog index f65db77f24b..19816c0bf4a 100644 --- a/gcc/testsuite/ChangeLog +++ b/gcc/testsuite/ChangeLog @@ -1,3 +1,8 @@ +2008-08-28 Paolo Carlini + + PR c++/37260 + * g++.dg/parse/crash44.C: New. + 2008-08-28 Adam Nemet * gcc.target/mips/octeon-dmul-1.c: New test. diff --git a/gcc/testsuite/g++.dg/parse/crash44.C b/gcc/testsuite/g++.dg/parse/crash44.C new file mode 100644 index 00000000000..abdf827cd4d --- /dev/null +++ b/gcc/testsuite/g++.dg/parse/crash44.C @@ -0,0 +1,15 @@ +// PR c++/37260 +// { dg-options "" } + +struct pthread_once_t { }; +struct test { + pthread_once_t once; +}; + +int main(void) { + struct test foo = { + once: PTHREAD_ONCE_INITIALIZER // { dg-error "error: 'PTHREAD_ONCE_INITIALIZER' was not declared in this scope" } + }; + + return 0; +}