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.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@68913 91177308-0d34-0410-b5e6-96231b3b80d8
diff --git a/lib/Sema/SemaDecl.cpp b/lib/Sema/SemaDecl.cpp
index 72611ef..603b8b3 100644
--- a/lib/Sema/SemaDecl.cpp
+++ b/lib/Sema/SemaDecl.cpp
@@ -2620,7 +2620,7 @@
}
}
return DeclGroupPtrTy::make(DeclGroupRef::Create(Context,
- &Decls[0], NumDecls));
+ &Decls[0], Decls.size()));
}
diff --git a/test/Sema/decl-invalid.c b/test/Sema/decl-invalid.c
index 0e10bdd..e14bc98 100644
--- a/test/Sema/decl-invalid.c
+++ b/test/Sema/decl-invalid.c
@@ -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}}