DeducedDecl = D;
} else if (!Context.hasSameType(DT->getDeducedType(), Deduced)) {
auto *AT = dyn_cast<AutoType>(DT);
- Diag(D->getTypeSourceInfo()->getTypeLoc().getBeginLoc(),
- diag::err_auto_different_deductions)
- << (AT ? (unsigned)AT->getKeyword() : 3)
- << Deduced << DeducedDecl->getDeclName()
- << DT->getDeducedType() << D->getDeclName()
- << DeducedDecl->getInit()->getSourceRange()
- << D->getInit()->getSourceRange();
+ auto Dia = Diag(D->getTypeSourceInfo()->getTypeLoc().getBeginLoc(),
+ diag::err_auto_different_deductions)
+ << (AT ? (unsigned)AT->getKeyword() : 3) << Deduced
+ << DeducedDecl->getDeclName() << DT->getDeducedType()
+ << D->getDeclName();
+ if (DeducedDecl->hasInit())
+ Dia << DeducedDecl->getInit()->getSourceRange();
+ if (D->getInit())
+ Dia << D->getInit()->getSourceRange();
D->setInvalidDecl();
break;
}
--- /dev/null
+// RUN: %clang_cc1 -std=c++11 -fsyntax-only -fno-recovery-ast -verify %s
+
+namespace std {
+template <typename>
+class initializer_list{};
+int a;
+auto c = a, &d = {a}; // expected-error {{'auto' deduced as 'int'}} \
+ expected-error {{non-const lvalue reference to type}}
+} // namespace std