Index: lib/Sema/SemaDecl.cpp
===================================================================
--- lib/Sema/SemaDecl.cpp	(revision 167161)
+++ lib/Sema/SemaDecl.cpp	(working copy)
@@ -7170,8 +7170,10 @@
   // All the following checks are C++ only.
   if (!getLangOpts().CPlusPlus) return;
 
-  QualType baseType = Context.getBaseElementType(var->getType());
-  if (baseType->isDependentType()) return;
+  QualType type = var->getType();
+  QualType baseType = Context.getBaseElementType(type);
+  if (type->isDependentType() || baseType->isDependentType())
+    return;
 
   // __block variables might require us to capture a copy-initializer.
   if (var->hasAttr<BlocksAttr>()) {
@@ -7180,8 +7182,6 @@
 
     // Regardless, we don't want to ignore array nesting when
     // constructing this copy.
-    QualType type = var->getType();
-
     if (type->isStructureOrClassType()) {
       SourceLocation poi = var->getLocation();
       Expr *varRef =new (Context) DeclRefExpr(var, false, type, VK_LValue, poi);
Index: test/SemaCXX/PR13788.cpp
===================================================================
--- test/SemaCXX/PR13788.cpp	(revision 0)
+++ test/SemaCXX/PR13788.cpp	(revision 0)
@@ -0,0 +1,11 @@
+// RUN: %clang_cc1 -fsyntax-only -verify %s -std=c++11
+// expected-no-diagnostics
+
+template <unsigned __N>
+struct S {
+  int V;
+};
+template <int N>
+void foo() {
+  S<0> arr[N] = {{4}};
+}
