PR38141: check whether noexcept-specifications are equivalent in redeclarations
llvm-svn: 336946
diff --git a/clang/lib/Sema/SemaExceptionSpec.cpp b/clang/lib/Sema/SemaExceptionSpec.cpp
index 8dce6d5..df5bc9b 100644
--- a/clang/lib/Sema/SemaExceptionSpec.cpp
+++ b/clang/lib/Sema/SemaExceptionSpec.cpp
@@ -530,10 +530,16 @@
}
}
- // FIXME: We treat dependent noexcept specifications as compatible even if
- // their expressions are not equivalent.
- if (OldEST == EST_DependentNoexcept && NewEST == EST_DependentNoexcept)
- return false;
+ // C++14 [except.spec]p3:
+ // Two exception-specifications are compatible if [...] both have the form
+ // noexcept(constant-expression) and the constant-expressions are equivalent
+ if (OldEST == EST_DependentNoexcept && NewEST == EST_DependentNoexcept) {
+ llvm::FoldingSetNodeID OldFSN, NewFSN;
+ Old->getNoexceptExpr()->Profile(OldFSN, S.Context, true);
+ New->getNoexceptExpr()->Profile(NewFSN, S.Context, true);
+ if (OldFSN == NewFSN)
+ return false;
+ }
// Dynamic exception specifications with the same set of adjusted types
// are compatible.