r208484 - Follow-up to r208481: Free all default arguments, not just the first one.

Nico Weber nicolasweber at gmx.de
Sat May 10 17:28:16 PDT 2014


Author: nico
Date: Sat May 10 19:28:16 2014
New Revision: 208484

URL: http://llvm.org/viewvc/llvm-project?rev=208484&view=rev
Log:
Follow-up to r208481: Free all default arguments, not just the first one.

Also add test coverage for this case.  Found by Richard Smith!

Modified:
    cfe/trunk/include/clang/Sema/DeclSpec.h
    cfe/trunk/test/SemaCXX/conversion-function.cpp

Modified: cfe/trunk/include/clang/Sema/DeclSpec.h
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Sema/DeclSpec.h?rev=208484&r1=208483&r2=208484&view=diff
==============================================================================
--- cfe/trunk/include/clang/Sema/DeclSpec.h (original)
+++ cfe/trunk/include/clang/Sema/DeclSpec.h Sat May 10 19:28:16 2014
@@ -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;

Modified: cfe/trunk/test/SemaCXX/conversion-function.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/SemaCXX/conversion-function.cpp?rev=208484&r1=208483&r2=208484&view=diff
==============================================================================
--- cfe/trunk/test/SemaCXX/conversion-function.cpp (original)
+++ cfe/trunk/test/SemaCXX/conversion-function.cpp Sat May 10 19:28:16 2014
@@ -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}}





More information about the cfe-commits mailing list