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
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
_______________________________________________ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits