From: Nico Weber Date: Sun, 11 May 2014 00:28:16 +0000 (+0000) Subject: Follow-up to r208481: Free all default arguments, not just the first one. X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=b70f4ce01ab3d57365b83751e739867168ae817e;p=clang Follow-up to r208481: Free all default arguments, not just the first one. Also add test coverage for this case. Found by Richard Smith! git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@208484 91177308-0d34-0410-b5e6-96231b3b80d8 --- diff --git a/include/clang/Sema/DeclSpec.h b/include/clang/Sema/DeclSpec.h index 493f68708a..99941b2e32 100644 --- a/include/clang/Sema/DeclSpec.h +++ b/include/clang/Sema/DeclSpec.h @@ -1231,9 +1231,9 @@ struct DeclaratorChunk { /// /// This is used in various places for error recovery. void freeParams() { - if (Params) { - delete Params->DefaultArgTokens; - Params->DefaultArgTokens = nullptr; + for (unsigned I = 0; I < NumParams; ++I) { + delete Params[I].DefaultArgTokens; + Params[I].DefaultArgTokens = nullptr; } if (DeleteParams) { delete[] Params; diff --git a/test/SemaCXX/conversion-function.cpp b/test/SemaCXX/conversion-function.cpp index dcc0609b58..40ac33b8eb 100644 --- a/test/SemaCXX/conversion-function.cpp +++ b/test/SemaCXX/conversion-function.cpp @@ -27,7 +27,7 @@ public: void operator bool(int, ...) const; // expected-error{{conversion function cannot have a return type}} \ // expected-error{{conversion function cannot have any parameters}} - operator bool(int a = 4) const; // expected-error{{conversion function cannot have any parameters}} + operator bool(int a = 4, int b = 6) const; // expected-error{{conversion function cannot have any parameters}} operator float(...) const; // expected-error{{conversion function cannot be variadic}}