[cfe-commits] r68913 - in /cfe/trunk: lib/Sema/SemaDecl.cpp test/Sema/decl-invalid.c

Chris Lattner sabre at nondot.org
Sun Apr 12 13:51:10 PDT 2009


Author: lattner
Date: Sun Apr 12 15:51:10 2009
New Revision: 68913

URL: http://llvm.org/viewvc/llvm-project?rev=68913&view=rev
Log:
fix a valgrind problem I noticed while developing another patch,
if a decl is invalid, it isn't added to the Decls array, so we
need to pass in Decls.size() to avoid reading uninit memory.

Modified:
    cfe/trunk/lib/Sema/SemaDecl.cpp
    cfe/trunk/test/Sema/decl-invalid.c

Modified: cfe/trunk/lib/Sema/SemaDecl.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaDecl.cpp?rev=68913&r1=68912&r2=68913&view=diff

==============================================================================
--- cfe/trunk/lib/Sema/SemaDecl.cpp (original)
+++ cfe/trunk/lib/Sema/SemaDecl.cpp Sun Apr 12 15:51:10 2009
@@ -2620,7 +2620,7 @@
     }
   }
   return DeclGroupPtrTy::make(DeclGroupRef::Create(Context,
-                                                   &Decls[0], NumDecls));
+                                                   &Decls[0], Decls.size()));
 }
 
 

Modified: cfe/trunk/test/Sema/decl-invalid.c
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Sema/decl-invalid.c?rev=68913&r1=68912&r2=68913&view=diff

==============================================================================
--- cfe/trunk/test/Sema/decl-invalid.c (original)
+++ cfe/trunk/test/Sema/decl-invalid.c Sun Apr 12 15:51:10 2009
@@ -8,6 +8,10 @@
 void x(); 
 int a() {
   int r[x()];  // expected-error {{size of array has non-integer type 'void'}}
+
+  static y ?; // expected-error{{unknown type name 'y'}} \
+                 expected-error{{expected identifier or '('}} \
+                 expected-error{{expected ';' at end of declaration}}
 }
 
 int; // expected-error {{declaration does not declare anything}}





More information about the cfe-commits mailing list