Index: include/clang/AST/Decl.h
===================================================================
--- include/clang/AST/Decl.h	(revision 158223)
+++ include/clang/AST/Decl.h	(working copy)
@@ -768,16 +768,19 @@
     /// variable;  see isARCPseudoStrong() for details.
     unsigned ARCPseudoStrong : 1;
 
+    /// \brief Whether this variable has its address taken or is referenced.
+    unsigned HasReference : 1;
+
     /// \brief Whether this variable is (C++0x) constexpr.
     unsigned IsConstexpr : 1;
   };
-  enum { NumVarDeclBits = 14 };
+  enum { NumVarDeclBits = 15 };
 
   friend class ASTDeclReader;
   friend class StmtIteratorBase;
 
 protected:
-  enum { NumParameterIndexBits = 8 };
+  enum { NumParameterIndexBits = 7 };
 
   class ParmVarDeclBitfields {
     friend class ParmVarDecl;
@@ -1187,6 +1190,10 @@
   bool isConstexpr() const { return VarDeclBits.IsConstexpr; }
   void setConstexpr(bool IC) { VarDeclBits.IsConstexpr = IC; }
 
+  /// Whether this variable has its address taken or is referenced.
+  bool hasReference() const { return VarDeclBits.HasReference; }
+  void setReference(bool ref) { VarDeclBits.HasReference = ref; }
+
   /// \brief If this variable is an instantiated static data member of a
   /// class template specialization, returns the templated static data member
   /// from which it was instantiated.
Index: lib/Sema/SemaInit.cpp
===================================================================
--- lib/Sema/SemaInit.cpp	(revision 158223)
+++ lib/Sema/SemaInit.cpp	(working copy)
@@ -6211,6 +6211,12 @@
   Expr *InitE = Init.get();
   assert(InitE && "No initialization expression?");
 
+  QualType QT = Entity.getType();
+  if (QT->isReferenceType() && !QT.getNonReferenceType().isConstQualified())
+    if (DeclRefExpr *DRE = dyn_cast<DeclRefExpr>(InitE->IgnoreParens()))
+      if (VarDecl *VD = dyn_cast<VarDecl>(DRE->getDecl()))
+        VD->setReference(true);
+
   if (EqualLoc.isInvalid())
     EqualLoc = InitE->getLocStart();
 
Index: lib/Sema/SemaExpr.cpp
===================================================================
--- lib/Sema/SemaExpr.cpp	(revision 158223)
+++ lib/Sema/SemaExpr.cpp	(working copy)
@@ -7744,6 +7744,10 @@
     S.Diag(OpLoc, diag::ext_typecheck_addrof_void) << op->getSourceRange();
   }
 
+  if (DeclRefExpr *DRE = dyn_cast<DeclRefExpr>(op))
+    if (VarDecl *VD = dyn_cast<VarDecl>(DRE->getDecl()))
+      VD->setReference(true);
+
   // If the operand has type "type", the result has type "pointer to type".
   if (op->getType()->isObjCObjectType())
     return S.Context.getObjCObjectPointerType(op->getType());
