rnk updated this revision to Diff 220376.
rnk added a comment.

- move test


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D67590

Files:
  clang/lib/Sema/SemaDecl.cpp
  clang/test/SemaCXX/ms-exception-spec.cpp


Index: clang/test/SemaCXX/ms-exception-spec.cpp
===================================================================
--- clang/test/SemaCXX/ms-exception-spec.cpp
+++ clang/test/SemaCXX/ms-exception-spec.cpp
@@ -1,4 +1,5 @@
-// RUN: %clang_cc1 %s -fsyntax-only -verify -fms-compatibility -fexceptions 
-fcxx-exceptions
+// RUN: %clang_cc1 -std=c++11 %s -fsyntax-only -verify -fms-compatibility 
-fexceptions -fcxx-exceptions
+// RUN: %clang_cc1 -std=c++17 %s -fsyntax-only -verify -fms-compatibility 
-fexceptions -fcxx-exceptions
 
 void f() throw(...) { }
 
@@ -7,3 +8,11 @@
 void fn() throw(S); // expected-warning {{incomplete type}} 
expected-note{{previous declaration}}
 void fn() throw();  // expected-warning {{does not match previous declaration}}
 }
+
+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: clang/lib/Sema/SemaDecl.cpp
===================================================================
--- clang/lib/Sema/SemaDecl.cpp
+++ clang/lib/Sema/SemaDecl.cpp
@@ -3562,7 +3562,14 @@
       }
     }
 
-    if (OldQTypeForComparison == NewQType)
+    if (OldQTypeForComparison == NewQType ||
+        // In Microsoft compatibility mode, the intent is to only warn on
+        // mismatched exception specifiers.  By this point, that warning has
+        // already been issued, so we should treat mismatches only in exception
+        // specifier as equivalent.
+        (getLangOpts().MSVCCompat &&
+         
Context.hasSameFunctionTypeIgnoringExceptionSpec(OldQTypeForComparison,
+                                                          NewQType)))
       return MergeCompatibleFunctionDecls(New, Old, S, MergeTypeWithOld);
 
     // If the types are imprecise (due to dependent constructs in friends or


Index: clang/test/SemaCXX/ms-exception-spec.cpp
===================================================================
--- clang/test/SemaCXX/ms-exception-spec.cpp
+++ clang/test/SemaCXX/ms-exception-spec.cpp
@@ -1,4 +1,5 @@
-// RUN: %clang_cc1 %s -fsyntax-only -verify -fms-compatibility -fexceptions -fcxx-exceptions
+// RUN: %clang_cc1 -std=c++11 %s -fsyntax-only -verify -fms-compatibility -fexceptions -fcxx-exceptions
+// RUN: %clang_cc1 -std=c++17 %s -fsyntax-only -verify -fms-compatibility -fexceptions -fcxx-exceptions
 
 void f() throw(...) { }
 
@@ -7,3 +8,11 @@
 void fn() throw(S); // expected-warning {{incomplete type}} expected-note{{previous declaration}}
 void fn() throw();  // expected-warning {{does not match previous declaration}}
 }
+
+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: clang/lib/Sema/SemaDecl.cpp
===================================================================
--- clang/lib/Sema/SemaDecl.cpp
+++ clang/lib/Sema/SemaDecl.cpp
@@ -3562,7 +3562,14 @@
       }
     }
 
-    if (OldQTypeForComparison == NewQType)
+    if (OldQTypeForComparison == NewQType ||
+        // In Microsoft compatibility mode, the intent is to only warn on
+        // mismatched exception specifiers.  By this point, that warning has
+        // already been issued, so we should treat mismatches only in exception
+        // specifier as equivalent.
+        (getLangOpts().MSVCCompat &&
+         Context.hasSameFunctionTypeIgnoringExceptionSpec(OldQTypeForComparison,
+                                                          NewQType)))
       return MergeCompatibleFunctionDecls(New, Old, S, MergeTypeWithOld);
 
     // If the types are imprecise (due to dependent constructs in friends or
_______________________________________________
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

Reply via email to