]> granicus.if.org Git - clang/commitdiff
Follow-up to r208481: Free all default arguments, not just the first one.
authorNico Weber <nicolasweber@gmx.de>
Sun, 11 May 2014 00:28:16 +0000 (00:28 +0000)
committerNico Weber <nicolasweber@gmx.de>
Sun, 11 May 2014 00:28:16 +0000 (00:28 +0000)
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

include/clang/Sema/DeclSpec.h
test/SemaCXX/conversion-function.cpp

index 493f68708a4b5b9cf955b779c9cccf84d21942b2..99941b2e3263947cbf46c6fcd37883a22332ca6e 100644 (file)
@@ -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;
index dcc0609b587c93ede403b52ce79c997773e40e6c..40ac33b8eb0df8c991c273a48f9d2d2e7d66890f 100644 (file)
@@ -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}}