diff options
-rw-r--r-- | gcc/cp/parser.c | 5 | ||||
-rw-r--r-- | gcc/testsuite/g++.dg/cpp0x/noexcept60.C | 13 |
2 files changed, 18 insertions, 0 deletions
diff --git a/gcc/cp/parser.c b/gcc/cp/parser.c index b0b31d2..bc66e6e5 100644 --- a/gcc/cp/parser.c +++ b/gcc/cp/parser.c @@ -21283,6 +21283,11 @@ cp_parser_direct_declarator (cp_parser* parser, /* DR 1207: 'this' is in scope after the cv-quals. */ inject_this_parameter (current_class_type, cv_quals); + /* If it turned out that this is e.g. a pointer to a + function, we don't want to delay noexcept parsing. */ + if (declarator == NULL || declarator->kind != cdk_id) + flags &= ~CP_PARSER_FLAGS_DELAY_NOEXCEPT; + /* Parse the exception-specification. */ exception_specification = cp_parser_exception_specification_opt (parser, diff --git a/gcc/testsuite/g++.dg/cpp0x/noexcept60.C b/gcc/testsuite/g++.dg/cpp0x/noexcept60.C new file mode 100644 index 0000000..d8efe1a --- /dev/null +++ b/gcc/testsuite/g++.dg/cpp0x/noexcept60.C @@ -0,0 +1,13 @@ +// PR c++/95562 +// { dg-do compile { target c++11 } } + +template <bool Nothrow> +struct Functions +{ + void (*func)(void*) noexcept(Nothrow); +}; + +void test() +{ + Functions<true> f{}; +} |