r362243 - Suppress nothrow/Exception spec conflict warning when we dont know the ES.

Erich Keane via cfe-commits cfe-commits at lists.llvm.org
Fri May 31 09:46:38 PDT 2019


Author: erichkeane
Date: Fri May 31 09:46:38 2019
New Revision: 362243

URL: http://llvm.org/viewvc/llvm-project?rev=362243&view=rev
Log:
Suppress nothrow/Exception spec conflict warning when we dont know the ES.

In any situation where the Exception Spec isn't clear, suppress the
warning to avoid false positives.

Modified:
    cfe/trunk/lib/Sema/SemaType.cpp
    cfe/trunk/test/SemaCXX/nothrow-vs-exception-specs.cpp

Modified: cfe/trunk/lib/Sema/SemaType.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaType.cpp?rev=362243&r1=362242&r2=362243&view=diff
==============================================================================
--- cfe/trunk/lib/Sema/SemaType.cpp (original)
+++ cfe/trunk/lib/Sema/SemaType.cpp Fri May 31 09:46:38 2019
@@ -6976,18 +6976,18 @@ static bool handleFunctionTypeAttr(TypeP
       case EST_BasicNoexcept:
       case EST_NoexceptTrue:
       case EST_NoThrow:
-      case EST_Unparsed:
         // Exception spec doesn't conflict with nothrow, so don't warn.
-        // Unparsed is included in this, since method signatures aren't parsed
-        // until after the fact.
+        LLVM_FALLTHROUGH;
+      case EST_Unparsed:
+      case EST_Uninstantiated:
+      case EST_DependentNoexcept:
+      case EST_Unevaluated:
+        // We don't have enough information to properly determine if there is a
+        // conflict, so suppress the warning.
         break;
-
       case EST_Dynamic:
       case EST_MSAny:
       case EST_NoexceptFalse:
-      case EST_DependentNoexcept:
-      case EST_Unevaluated:
-      case EST_Uninstantiated:
         S.Diag(attr.getLoc(), diag::warn_nothrow_attribute_ignored);
         break;
       }

Modified: cfe/trunk/test/SemaCXX/nothrow-vs-exception-specs.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/SemaCXX/nothrow-vs-exception-specs.cpp?rev=362243&r1=362242&r2=362243&view=diff
==============================================================================
--- cfe/trunk/test/SemaCXX/nothrow-vs-exception-specs.cpp (original)
+++ cfe/trunk/test/SemaCXX/nothrow-vs-exception-specs.cpp Fri May 31 09:46:38 2019
@@ -54,6 +54,9 @@ __declspec(nothrow) void foo5() noexcept
 // expected-warning at +1{{'nothrow' attribute conflicts with exception specification; attribute ignored}}
 __declspec(nothrow) void foo6() noexcept(noexcept(foo3()));
 
+template<typename F>
+__declspec(nothrow) void foo7() noexcept(noexcept(F()));
+
 // FIXME: It would be nice to be able to warn on these, however at the time we
 // evaluate the nothrow, these have yet to be parsed, so the data is not yet
 // there.




More information about the cfe-commits mailing list