r310435 - Allow operator delete to be an invalid Decl.

Richard Trieu via cfe-commits cfe-commits at lists.llvm.org
Tue Aug 8 19:03:59 PDT 2017


Author: rtrieu
Date: Tue Aug  8 19:03:59 2017
New Revision: 310435

URL: http://llvm.org/viewvc/llvm-project?rev=310435&view=rev
Log:
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.

Modified:
    cfe/trunk/lib/Sema/SemaExprCXX.cpp
    cfe/trunk/test/SemaCXX/MicrosoftExtensions.cpp

Modified: cfe/trunk/lib/Sema/SemaExprCXX.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaExprCXX.cpp?rev=310435&r1=310434&r2=310435&view=diff
==============================================================================
--- cfe/trunk/lib/Sema/SemaExprCXX.cpp (original)
+++ cfe/trunk/lib/Sema/SemaExprCXX.cpp Tue Aug  8 19:03:59 2017
@@ -1378,9 +1378,6 @@ Sema::BuildCXXTypeConstructExpr(TypeSour
 /// \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<CXXMethodDecl>(FD))
     return Method->isUsualDeallocationFunction();
 

Modified: cfe/trunk/test/SemaCXX/MicrosoftExtensions.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/SemaCXX/MicrosoftExtensions.cpp?rev=310435&r1=310434&r2=310435&view=diff
==============================================================================
--- cfe/trunk/test/SemaCXX/MicrosoftExtensions.cpp (original)
+++ cfe/trunk/test/SemaCXX/MicrosoftExtensions.cpp Tue Aug  8 19:03:59 2017
@@ -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 at -1 {{previous declaration is here}}
+__declspec(dllexport) void operator delete(void *) throw();
+// expected-error at -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




More information about the cfe-commits mailing list