[PATCH] D67590: Properly ignore mismatched exception specifiers in MSVC Compat mode.

Alex Fusco via Phabricator via cfe-commits cfe-commits at lists.llvm.org
Mon Sep 16 12:10:26 PDT 2019


alexfusco updated this revision to Diff 220367.
alexfusco added a comment.

Updated to unconditionally ignore the exception spec here, since it has already been compared.


Repository:
  rC Clang

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D67590/new/

https://reviews.llvm.org/D67590

Files:
  lib/Sema/SemaDecl.cpp
  test/SemaCXX/ms-ignore-mismatched-except-specifier.cpp


Index: test/SemaCXX/ms-ignore-mismatched-except-specifier.cpp
===================================================================
--- /dev/null
+++ test/SemaCXX/ms-ignore-mismatched-except-specifier.cpp
@@ -0,0 +1,9 @@
+// RUN: %clang_cc1 %s -std=c++1z -fms-extensions -fms-compatibility
+
+template <typename T> struct FooPtr {
+  template <typename U> FooPtr(U *p) : m_pT(nullptr) {}
+  template <> FooPtr(T *pInterface) throw() : m_pT(pInterface) {}  // expected-warning {{exception specification in declaration does not match previous declaration}}
+  T *m_pT;
+};
+struct Bar{};
+template struct FooPtr<Bar>;
Index: lib/Sema/SemaDecl.cpp
===================================================================
--- lib/Sema/SemaDecl.cpp
+++ lib/Sema/SemaDecl.cpp
@@ -3562,7 +3562,12 @@
       }
     }
 
-    if (OldQTypeForComparison == NewQType)
+    // Exception specifiers have already been compared here so ignore them for
+    // the purposes of this comparison. Microsoft compatability mode explicitly
+    // downgrades such mismatches to a warning and we shouldn't make it an error
+    // here.
+    if (Context.hasSameFunctionTypeIgnoringExceptionSpec(OldQTypeForComparison,
+                                                         NewQType))
       return MergeCompatibleFunctionDecls(New, Old, S, MergeTypeWithOld);
 
     // If the types are imprecise (due to dependent constructs in friends or


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D67590.220367.patch
Type: text/x-patch
Size: 1410 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20190916/282da067/attachment.bin>


More information about the cfe-commits mailing list