diff options
author | Reid Kleckner <rnk@google.com> | 2019-09-17 20:29:10 +0000 |
---|---|---|
committer | Reid Kleckner <rnk@google.com> | 2019-09-17 20:29:10 +0000 |
commit | 6f1f3cfc5ac2f3188370928668b8ca7d3f06d47f (patch) | |
tree | a3cfc26beab77a141c0ee5c5da5135d02f74e314 /clang/lib/Sema/SemaDecl.cpp | |
parent | 8a4d9f04b51afe079420cb65049ecc875418f72b (diff) | |
download | bcm5719-llvm-6f1f3cfc5ac2f3188370928668b8ca7d3f06d47f.tar.gz bcm5719-llvm-6f1f3cfc5ac2f3188370928668b8ca7d3f06d47f.zip |
Ignore exception specifier mismatch when merging redeclarations
Exception specifiers are now part of the function type in C++17.
Normally, it is illegal to redeclare the same function or specialize a
template with a different exception specifier, but under
-fms-compatibility, we accept it with a warning. Without this change,
the function types would not match due to the exception specifier, and
clang would claim that the types were "incompatible". Now we emit the
warning and merge the redeclaration as we would in C++14 and earlier.
Fixes PR42842, which is about compiling _com_ptr_t in C++17.
Based on a patch by Alex Fusco <alexfusco@google.com>!
Differential Revision: https://reviews.llvm.org/D67590
llvm-svn: 372178
Diffstat (limited to 'clang/lib/Sema/SemaDecl.cpp')
-rw-r--r-- | clang/lib/Sema/SemaDecl.cpp | 7 |
1 files changed, 6 insertions, 1 deletions
diff --git a/clang/lib/Sema/SemaDecl.cpp b/clang/lib/Sema/SemaDecl.cpp index dfa5647e9df..dead3b69bbd 100644 --- a/clang/lib/Sema/SemaDecl.cpp +++ b/clang/lib/Sema/SemaDecl.cpp @@ -3562,7 +3562,12 @@ bool Sema::MergeFunctionDecl(FunctionDecl *New, NamedDecl *&OldD, } } - if (OldQTypeForComparison == NewQType) + // If the function types are compatible, merge the declarations. Ignore the + // exception specifier because it was already checked above in + // CheckEquivalentExceptionSpec, and we don't want follow-on diagnostics + // about incompatible types under -fms-compatibility. + if (Context.hasSameFunctionTypeIgnoringExceptionSpec(OldQTypeForComparison, + NewQType)) return MergeCompatibleFunctionDecls(New, Old, S, MergeTypeWithOld); // If the types are imprecise (due to dependent constructs in friends or |