diff --git a/clang/lib/Sema/SemaExceptionSpec.cpp b/clang/lib/Sema/SemaExceptionSpec.cpp index 2387325be435..41abd49627b8 100644 --- a/clang/lib/Sema/SemaExceptionSpec.cpp +++ b/clang/lib/Sema/SemaExceptionSpec.cpp @@ -437,7 +437,7 @@ bool Sema::CheckEquivalentExceptionSpec(const PartialDiagnostic &DiagID, OldNR != FunctionProtoType::NR_NoNoexcept && NewNR != FunctionProtoType::NR_NoNoexcept) { Diag(NewLoc, DiagID); - if (NoteID.getDiagID() != 0) + if (NoteID.getDiagID() != 0 && OldLoc.isValid()) Diag(OldLoc, NoteID); return true; } @@ -518,7 +518,7 @@ bool Sema::CheckEquivalentExceptionSpec(const PartialDiagnostic &DiagID, } Diag(NewLoc, DiagID); - if (NoteID.getDiagID() != 0) + if (NoteID.getDiagID() != 0 && OldLoc.isValid()) Diag(OldLoc, NoteID); return true; } @@ -547,7 +547,7 @@ bool Sema::CheckEquivalentExceptionSpec(const PartialDiagnostic &DiagID, return false; } Diag(NewLoc, DiagID); - if (NoteID.getDiagID() != 0) + if (NoteID.getDiagID() != 0 && OldLoc.isValid()) Diag(OldLoc, NoteID); return true; } diff --git a/clang/test/CXX/drs/dr19xx.cpp b/clang/test/CXX/drs/dr19xx.cpp index 8087631067be..dd98aafb5119 100644 --- a/clang/test/CXX/drs/dr19xx.cpp +++ b/clang/test/CXX/drs/dr19xx.cpp @@ -39,6 +39,12 @@ namespace dr1902 { // dr1902: 3.7 #endif } +#if __cplusplus >= 201103L +// dr1948: yes +// FIXME: This diagnostic could be improved. +void *operator new(__SIZE_TYPE__) noexcept { return nullptr; } // expected-error{{exception specification in declaration does not match previous declaration}} +#endif + #if __cplusplus >= 201103L namespace dr1968 { // dr1968: yes static_assert(&typeid(int) == &typeid(int), ""); // expected-error{{not an integral constant expression}} diff --git a/clang/www/cxx_dr_status.html b/clang/www/cxx_dr_status.html index 5651a1c1dc27..fb9368708a22 100644 --- a/clang/www/cxx_dr_status.html +++ b/clang/www/cxx_dr_status.html @@ -11503,7 +11503,7 @@ and POD class 1948 NAD exception-specification of replacement global new - Unknown + Yes 1949