On 09/07/2011 06:41 PM, Jason Merrill wrote:
On 09/07/2011 06:37 AM, Paolo Carlini wrote:
I have the below simple patch to avoid the ICE after error. Tested
x86_64-linux. Is it Ok? In case, if it applies as-is, 4_6-branch too?
I think this is a recoverable error; if the exception-specification is
ill-formed, let's pretend there wasn't one rather than discard the
whole declaration.
Agreed. I'm finishing testing the below. Ok if it passes?
Paolo.
///////////////////
Index: testsuite/g++.dg/cpp0x/noexcept14.C
===================================================================
--- testsuite/g++.dg/cpp0x/noexcept14.C (revision 0)
+++ testsuite/g++.dg/cpp0x/noexcept14.C (revision 0)
@@ -0,0 +1,4 @@
+// PR c++/50309
+// { dg-options -std=c++0x }
+
+void foo () noexcept () { } // { dg-error "expected" }
Index: cp/decl.c
===================================================================
--- cp/decl.c (revision 178631)
+++ cp/decl.c (working copy)
@@ -9049,6 +9049,10 @@ grokdeclarator (const cp_declarator *declarator,
virt_specifiers = declarator->u.function.virt_specifiers;
/* Pick up the exception specifications. */
raises = declarator->u.function.exception_specification;
+ /* If the exception-specification is ill-formed, let's pretend
+ there wasn't one. */
+ if (raises == error_mark_node)
+ raises = NULL_TREE;
/* Say it's a definition only for the CALL_EXPR
closest to the identifier. */