forked from OSchip/llvm-project
Fix use-auto-check.
Summary: Fix a bug where use-auto check would crash when the definition of a type is in the same statement than its instantiation with new. Reviewers: alexfh Subscribers: cfe-commits, klimek Differential Revision: http://reviews.llvm.org/D12551 llvm-svn: 246638
This commit is contained in:
parent
1e583704f5
commit
e6035de11e
|
@ -298,7 +298,7 @@ void UseAutoCheck::replaceIterators(const DeclStmt *D, ASTContext *Context) {
|
|||
}
|
||||
|
||||
void UseAutoCheck::replaceNew(const DeclStmt *D, ASTContext *Context) {
|
||||
const auto *FirstDecl = cast<VarDecl>(*D->decl_begin());
|
||||
const auto *FirstDecl = dyn_cast<VarDecl>(*D->decl_begin());
|
||||
// Ensure that there is at least one VarDecl within the DeclStmt.
|
||||
if (!FirstDecl)
|
||||
return;
|
||||
|
|
|
@ -37,6 +37,8 @@ void auto_new() {
|
|||
// CHECK-MESSAGES: :[[@LINE-1]]:3: warning: use auto when initializing with new
|
||||
// CHECK-FIXES: auto volatile vol = new MyType();
|
||||
|
||||
struct SType {} *stype = new SType;
|
||||
|
||||
int (**func)(int, int) = new (int(*[5])(int,int));
|
||||
|
||||
int *array = new int[5];
|
||||
|
|
Loading…
Reference in New Issue