From 2b2a0876c9d3a92c5216a578373817974fe159a0 Mon Sep 17 00:00:00 2001 From: Richard Smith Date: Tue, 24 Apr 2012 05:48:42 +0000 Subject: [PATCH] Don't try to delay parsing the exception specification for a data member of a class; we would never actually parse it and attach it to the type. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@155426 91177308-0d34-0410-b5e6-96231b3b80d8 --- lib/Parse/ParseDecl.cpp | 2 ++ test/CXX/class/class.mem/p2.cpp | 10 +++++++++- 2 files changed, 11 insertions(+), 1 deletion(-) diff --git a/lib/Parse/ParseDecl.cpp b/lib/Parse/ParseDecl.cpp index 932ffb440f..4775798d62 100644 --- a/lib/Parse/ParseDecl.cpp +++ b/lib/Parse/ParseDecl.cpp @@ -4270,6 +4270,8 @@ void Parser::ParseFunctionDeclarator(Declarator &D, D.getDeclSpec().getStorageClassSpec() != DeclSpec::SCS_typedef && !D.getDeclSpec().isFriendSpecified()); + for (unsigned i = 0, e = D.getNumTypeObjects(); Delayed && i != e; ++i) + Delayed &= D.getTypeObject(i).Kind == DeclaratorChunk::Paren; ESpecType = tryParseExceptionSpecification(Delayed, ESpecRange, DynamicExceptions, diff --git a/test/CXX/class/class.mem/p2.cpp b/test/CXX/class/class.mem/p2.cpp index 3e957df69d..bf7b3d49c9 100644 --- a/test/CXX/class/class.mem/p2.cpp +++ b/test/CXX/class/class.mem/p2.cpp @@ -60,8 +60,16 @@ namespace test3 { namespace PR12629 { struct S { static int (f)() throw(); - static int ((((((g))))() throw(int))); + static int ((((((g))))() throw(U))); + int (*h)() noexcept(false); + static int (&i)() noexcept(true); + static int (*j)() throw(U); // expected-error {{type name}} \ + // expected-error {{expected ')'}} expected-note {{to match}} + + struct U {}; }; static_assert(noexcept(S::f()), ""); static_assert(!noexcept(S::g()), ""); + static_assert(!noexcept(S().h()), ""); + static_assert(noexcept(S::i()), ""); }