]> granicus.if.org Git - clang/commitdiff
PR12629: Cope with parenthesized function types when attaching a delayed
authorRichard Smith <richard-llvm@metafoo.co.uk>
Tue, 24 Apr 2012 05:06:35 +0000 (05:06 +0000)
committerRichard Smith <richard-llvm@metafoo.co.uk>
Tue, 24 Apr 2012 05:06:35 +0000 (05:06 +0000)
exception specification to a function.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@155424 91177308-0d34-0410-b5e6-96231b3b80d8

lib/Sema/SemaDeclCXX.cpp
test/CXX/class/class.mem/p2.cpp

index b6395f5dcbf521f486191204dd9859c4546557d9..8645de1fcd62e3ec1bad55109df1f355e1f668e4 100644 (file)
@@ -11315,11 +11315,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;
@@ -11332,6 +11330,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
index 0a823f4c1f00c1732c0abf46312028bf0482f0f2..3e957df69d7a7bd058970282782cc1512347f45d 100644 (file)
@@ -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()), "");
+}