]> granicus.if.org Git - clang/commitdiff
Allow operator delete to be an invalid Decl.
authorRichard Trieu <rtrieu@google.com>
Wed, 9 Aug 2017 02:03:59 +0000 (02:03 +0000)
committerRichard Trieu <rtrieu@google.com>
Wed, 9 Aug 2017 02:03:59 +0000 (02:03 +0000)
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.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@310435 91177308-0d34-0410-b5e6-96231b3b80d8

lib/Sema/SemaExprCXX.cpp
test/SemaCXX/MicrosoftExtensions.cpp

index 9c0bd6fedd185389171cd36b56fbf3b145ef3c9b..4ef6df70b8e6c776918aafbcfe88ca548f992c99 100644 (file)
@@ -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<CXXMethodDecl>(FD))
     return Method->isUsualDeallocationFunction();
 
index 38949e11376d58ceadf886e255bb67ba0e267d59..c605dcb912f6cce3650d5669d271df31515877df 100644 (file)
@@ -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