summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorChris Lattner <sabre@nondot.org>2009-04-12 20:51:10 +0000
committerChris Lattner <sabre@nondot.org>2009-04-12 20:51:10 +0000
commit14bdb7843057023b1847e37efbd7381a46bf6e5b (patch)
tree50fdd9247e1f1482d81465fb9d9e6644e58b1753
parent109af6232b5ec16aa9e8aa50d2f65b52efd08321 (diff)
downloadbcm5719-llvm-14bdb7843057023b1847e37efbd7381a46bf6e5b.tar.gz
bcm5719-llvm-14bdb7843057023b1847e37efbd7381a46bf6e5b.zip
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. llvm-svn: 68913
-rw-r--r--clang/lib/Sema/SemaDecl.cpp2
-rw-r--r--clang/test/Sema/decl-invalid.c4
2 files changed, 5 insertions, 1 deletions
diff --git a/clang/lib/Sema/SemaDecl.cpp b/clang/lib/Sema/SemaDecl.cpp
index 72611ef08b0..603b8b31a26 100644
--- a/clang/lib/Sema/SemaDecl.cpp
+++ b/clang/lib/Sema/SemaDecl.cpp
@@ -2620,7 +2620,7 @@ Sema::DeclGroupPtrTy Sema::FinalizeDeclaratorGroup(Scope *S, DeclPtrTy *Group,
}
}
return DeclGroupPtrTy::make(DeclGroupRef::Create(Context,
- &Decls[0], NumDecls));
+ &Decls[0], Decls.size()));
}
diff --git a/clang/test/Sema/decl-invalid.c b/clang/test/Sema/decl-invalid.c
index 0e10bdd8c12..e14bc9891a4 100644
--- a/clang/test/Sema/decl-invalid.c
+++ b/clang/test/Sema/decl-invalid.c
@@ -8,6 +8,10 @@ typedef union <anonymous> __mbstate_t; // expected-error {{declaration of anony
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}}
OpenPOWER on IntegriCloud