]> granicus.if.org Git - clang/commitdiff
C++ destructors can have a single unnamed void parameter. Fixes <rdar://problem/6841210>.
authorAnders Carlsson <andersca@mac.com>
Thu, 30 Apr 2009 23:18:11 +0000 (23:18 +0000)
committerAnders Carlsson <andersca@mac.com>
Thu, 30 Apr 2009 23:18:11 +0000 (23:18 +0000)
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@70519 91177308-0d34-0410-b5e6-96231b3b80d8

lib/Sema/SemaDeclCXX.cpp
test/SemaCXX/destructor.cpp

index 6e00488c509f1d681c1fbc7235393e099753ccd8..54c887e303b566dc11017ad08e020ee021603922 100644 (file)
@@ -1351,6 +1351,13 @@ void Sema::CheckConstructor(CXXConstructorDecl *Constructor) {
   ClassDecl->addedConstructor(Context, Constructor);
 }
 
+static inline bool 
+FTIHasSingleVoidArgument(DeclaratorChunk::FunctionTypeInfo &FTI) {
+  return (FTI.NumArgs == 1 && !FTI.isVariadic && FTI.ArgInfo[0].Ident == 0 &&
+          FTI.ArgInfo[0].Param &&
+          FTI.ArgInfo[0].Param.getAs<ParmVarDecl>()->getType()->isVoidType());
+}
+
 /// CheckDestructorDeclarator - Called by ActOnDeclarator to check
 /// the well-formednes of the destructor declarator @p D with type @p
 /// R. If there are any errors in the declarator, this routine will
@@ -1416,7 +1423,7 @@ QualType Sema::CheckDestructorDeclarator(Declarator &D,
   }
 
   // Make sure we don't have any parameters.
-  if (FTI.NumArgs > 0) {
+  if (FTI.NumArgs > 0 && !FTIHasSingleVoidArgument(FTI)) {
     Diag(D.getIdentifierLoc(), diag::err_destructor_with_params);
 
     // Delete the parameters.
index f066993c269667a499cfbc01a8d7044a596ff0c5..f544db0b1b6e0d2a31c996dd24e2a58507663972 100644 (file)
@@ -50,3 +50,7 @@ struct G {
 
 G::~G() { }
 
+// <rdar://problem/6841210>
+struct H {
+  ~H(void) { } 
+};