]> granicus.if.org Git - clang/commitdiff
More forcibly resolve exception specifications when checking a function
authorRichard Smith <richard-llvm@metafoo.co.uk>
Wed, 2 Nov 2016 00:47:52 +0000 (00:47 +0000)
committerRichard Smith <richard-llvm@metafoo.co.uk>
Wed, 2 Nov 2016 00:47:52 +0000 (00:47 +0000)
redeclaration in C++1z mode. We need the exception specification in order for
the function's type to be complete.

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

lib/Sema/SemaDecl.cpp
test/SemaCXX/cxx1z-noexcept-function-type.cpp

index 319e63dbb18ec0d9630ab8319643e3201ccb2c87..1813aa0b64859a240375344e4b69a7e9d3e4875e 100644 (file)
@@ -2949,6 +2949,15 @@ bool Sema::MergeFunctionDecl(FunctionDecl *New, NamedDecl *&OldD,
     // but do not necessarily update the type of New.
     if (CheckEquivalentExceptionSpec(Old, New))
       return true;
+    // If exceptions are disabled, we might not have resolved the exception spec
+    // of one or both declarations. Do so now in C++1z, so that we can properly
+    // compare the types.
+    if (getLangOpts().CPlusPlus1z) {
+      for (QualType T : {Old->getType(), New->getType()})
+        if (auto *FPT = T->getAs<FunctionProtoType>())
+          if (isUnresolvedExceptionSpec(FPT->getExceptionSpecType()))
+            ResolveExceptionSpec(New->getLocation(), FPT);
+    }
     OldQType = Context.getCanonicalType(Old->getType());
     NewQType = Context.getCanonicalType(New->getType());
 
index 72b28432ef037a998c32a800f3c72db7dd7dc4f9..ae686d396ba5da6f69682342dbe66f19e203fbcc 100644 (file)
@@ -89,3 +89,11 @@ namespace CompatWarning {
   template<typename T> void h(...) = delete; // expected-note {{deleted}}
   void test_h() { h<void>(nullptr); } // expected-error {{deleted}}
 }
+
+namespace ImplicitExceptionSpec {
+  struct S {
+    ~S();
+    void f(const S &s = S());
+  };
+  S::~S() {}
+}