diff options
author | Bill Wendling <isanbard@gmail.com> | 2012-05-12 00:26:39 +0000 |
---|---|---|
committer | Bill Wendling <isanbard@gmail.com> | 2012-05-12 00:26:39 +0000 |
commit | dd80f8b54cb5b5f19213d503f79ce37f57973a3e (patch) | |
tree | a4b6f0e79baef6ca32dbfbb7179c1034c5ca0cad | |
parent | 1dfc8e93513359018271c290da85a62838230aa3 (diff) | |
download | llvm-dd80f8b54cb5b5f19213d503f79ce37f57973a3e.tar.gz |
Merging r155424:
------------------------------------------------------------------------
r155424 | rsmith | 2012-04-23 22:06:35 -0700 (Mon, 23 Apr 2012) | 3 lines
PR12629: Cope with parenthesized function types when attaching a delayed
exception specification to a function.
------------------------------------------------------------------------
llvm-svn: 156679
-rw-r--r-- | clang/lib/Sema/SemaDeclCXX.cpp | 12 | ||||
-rw-r--r-- | clang/test/CXX/class/class.mem/p2.cpp | 11 |
2 files changed, 18 insertions, 5 deletions
diff --git a/clang/lib/Sema/SemaDeclCXX.cpp b/clang/lib/Sema/SemaDeclCXX.cpp index 1d251b9eb74b..cec20af2d77e 100644 --- a/clang/lib/Sema/SemaDeclCXX.cpp +++ b/clang/lib/Sema/SemaDeclCXX.cpp @@ -11279,11 +11279,9 @@ void Sema::actOnDelayedExceptionSpecification(Decl *MethodD, if (!Method) return; - // Dig out the prototype. This should never fail. + // Dig out the prototype, looking through only parens. This should never fail. const FunctionProtoType *Proto - = dyn_cast<FunctionProtoType>(Method->getType()); - if (!Proto) - return; + = cast<FunctionProtoType>(Method->getType().IgnoreParens()); // Check the exception specification. llvm::SmallVector<QualType, 4> Exceptions; @@ -11296,6 +11294,12 @@ void Sema::actOnDelayedExceptionSpecification(Decl *MethodD, Proto->arg_type_begin(), Proto->getNumArgs(), EPI); + + // Rebuild any parens around the function type. + for (const ParenType *PT = dyn_cast<ParenType>(Method->getType()); PT; + PT = dyn_cast<ParenType>(PT->getInnerType())) + T = Context.getParenType(T); + if (TypeSourceInfo *TSInfo = Method->getTypeSourceInfo()) { // FIXME: When we get proper type location information for exceptions, // we'll also have to rebuild the TypeSourceInfo. For now, we just patch diff --git a/clang/test/CXX/class/class.mem/p2.cpp b/clang/test/CXX/class/class.mem/p2.cpp index 0a823f4c1f00..3e957df69d7a 100644 --- a/clang/test/CXX/class/class.mem/p2.cpp +++ b/clang/test/CXX/class/class.mem/p2.cpp @@ -1,4 +1,4 @@ -// RUN: %clang_cc1 -fsyntax-only -verify %s +// RUN: %clang_cc1 -fsyntax-only -verify -std=c++11 %s // C++11 [class.mem]p2: // A class is considered a completely-defined object type (or @@ -56,3 +56,12 @@ namespace test3 { template struct A2<int>; } + +namespace PR12629 { + struct S { + static int (f)() throw(); + static int ((((((g))))() throw(int))); + }; + static_assert(noexcept(S::f()), ""); + static_assert(!noexcept(S::g()), ""); +} |