From c06b35c97e65e673530293db1d6931a06cd98396 Mon Sep 17 00:00:00 2001 From: Richard Trieu Date: Wed, 9 Aug 2017 02:03:59 +0000 Subject: [PATCH] Allow operator delete to be an invalid Decl. Do not discard invalid Decl when searching for the operator delete function. The lookup for this function always expects to find a result, so sometimes the invalid Decl is the only choice possible. This fixes PR34109. llvm-svn: 310435 --- clang/lib/Sema/SemaExprCXX.cpp | 3 --- clang/test/SemaCXX/MicrosoftExtensions.cpp | 14 ++++++++++++++ 2 files changed, 14 insertions(+), 3 deletions(-) diff --git a/clang/lib/Sema/SemaExprCXX.cpp b/clang/lib/Sema/SemaExprCXX.cpp index 9c0bd6f..4ef6df7 100644 --- a/clang/lib/Sema/SemaExprCXX.cpp +++ b/clang/lib/Sema/SemaExprCXX.cpp @@ -1378,9 +1378,6 @@ Sema::BuildCXXTypeConstructExpr(TypeSourceInfo *TInfo, /// \brief Determine whether the given function is a non-placement /// deallocation function. static bool isNonPlacementDeallocationFunction(Sema &S, FunctionDecl *FD) { - if (FD->isInvalidDecl()) - return false; - if (CXXMethodDecl *Method = dyn_cast(FD)) return Method->isUsualDeallocationFunction(); diff --git a/clang/test/SemaCXX/MicrosoftExtensions.cpp b/clang/test/SemaCXX/MicrosoftExtensions.cpp index 38949e1..c605dcb 100644 --- a/clang/test/SemaCXX/MicrosoftExtensions.cpp +++ b/clang/test/SemaCXX/MicrosoftExtensions.cpp @@ -504,6 +504,20 @@ struct S { int S::fn() { return 0; } // expected-warning {{is missing exception specification}} } +class PR34109_class { + PR34109_class() {} + virtual ~PR34109_class() {} +}; + +void operator delete(void *) throw(); +// expected-note@-1 {{previous declaration is here}} +__declspec(dllexport) void operator delete(void *) throw(); +// expected-error@-1 {{redeclaration of 'operator delete' cannot add 'dllexport' attribute}} + +void PR34109(int* a) { + delete a; +} + #elif TEST2 // Check that __unaligned is not recognized if MS extensions are not enabled -- 2.7.4