diff options
| author | Richard Smith <richard-llvm@metafoo.co.uk> | 2013-04-30 21:23:01 +0000 |
|---|---|---|
| committer | Richard Smith <richard-llvm@metafoo.co.uk> | 2013-04-30 21:23:01 +0000 |
| commit | 061f1e21bee0c8fec2dda677958c3c27c5a538e5 (patch) | |
| tree | 093a5f85b95dc4692e4e90b08ec2c96305ab7072 /clang/lib/Sema/SemaDecl.cpp | |
| parent | 9da442f5068839dbc049cee3556855a17a85802e (diff) | |
| download | bcm5719-llvm-061f1e21bee0c8fec2dda677958c3c27c5a538e5.tar.gz bcm5719-llvm-061f1e21bee0c8fec2dda677958c3c27c5a538e5.zip | |
When deducing an 'auto' type, don't modify the type-as-written.
llvm-svn: 180808
Diffstat (limited to 'clang/lib/Sema/SemaDecl.cpp')
| -rw-r--r-- | clang/lib/Sema/SemaDecl.cpp | 14 |
1 files changed, 7 insertions, 7 deletions
diff --git a/clang/lib/Sema/SemaDecl.cpp b/clang/lib/Sema/SemaDecl.cpp index 1e5e5bb259b..1aab5c669f9 100644 --- a/clang/lib/Sema/SemaDecl.cpp +++ b/clang/lib/Sema/SemaDecl.cpp @@ -7334,17 +7334,16 @@ void Sema::AddInitializerToDecl(Decl *RealDecl, Expr *Init, Init = Result.take(); DefaultedToAuto = true; } - - TypeSourceInfo *DeducedType = 0; + + QualType DeducedType; if (DeduceAutoType(VDecl->getTypeSourceInfo(), DeduceInit, DeducedType) == DAR_Failed) DiagnoseAutoDeductionFailure(VDecl, DeduceInit); - if (!DeducedType) { + if (DeducedType.isNull()) { RealDecl->setInvalidDecl(); return; } - VDecl->setTypeSourceInfo(DeducedType); - VDecl->setType(DeducedType->getType()); + VDecl->setType(DeducedType); assert(VDecl->isLinkageValid()); // In ARC, infer lifetime. @@ -7356,8 +7355,9 @@ void Sema::AddInitializerToDecl(Decl *RealDecl, Expr *Init, // We only want to warn outside of template instantiations, though: // inside a template, the 'id' could have come from a parameter. if (ActiveTemplateInstantiations.empty() && !DefaultedToAuto && - DeducedType->getType()->isObjCIdType()) { - SourceLocation Loc = DeducedType->getTypeLoc().getBeginLoc(); + DeducedType->isObjCIdType()) { + SourceLocation Loc = + VDecl->getTypeSourceInfo()->getTypeLoc().getBeginLoc(); Diag(Loc, diag::warn_auto_var_is_id) << VDecl->getDeclName() << DeduceInit->getSourceRange(); } |

