[cfe-commits] r155424 - in /cfe/trunk: lib/Sema/SemaDeclCXX.cpp test/CXX/class/class.mem/p2.cpp

Richard Smith richard-llvm at metafoo.co.uk
Mon Apr 23 22:06:35 PDT 2012


Author: rsmith
Date: Tue Apr 24 00:06:35 2012
New Revision: 155424

URL: http://llvm.org/viewvc/llvm-project?rev=155424&view=rev
Log:
PR12629: Cope with parenthesized function types when attaching a delayed
exception specification to a function.

Modified:
    cfe/trunk/lib/Sema/SemaDeclCXX.cpp
    cfe/trunk/test/CXX/class/class.mem/p2.cpp

Modified: cfe/trunk/lib/Sema/SemaDeclCXX.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaDeclCXX.cpp?rev=155424&r1=155423&r2=155424&view=diff
==============================================================================
--- cfe/trunk/lib/Sema/SemaDeclCXX.cpp (original)
+++ cfe/trunk/lib/Sema/SemaDeclCXX.cpp Tue Apr 24 00:06:35 2012
@@ -11315,11 +11315,9 @@
   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 @@
                                        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

Modified: cfe/trunk/test/CXX/class/class.mem/p2.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/CXX/class/class.mem/p2.cpp?rev=155424&r1=155423&r2=155424&view=diff
==============================================================================
--- cfe/trunk/test/CXX/class/class.mem/p2.cpp (original)
+++ cfe/trunk/test/CXX/class/class.mem/p2.cpp Tue Apr 24 00:06:35 2012
@@ -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 @@
 
   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()), "");
+}





More information about the cfe-commits mailing list