Template instantiation for GNU array-range designators.


git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@72234 91177308-0d34-0410-b5e6-96231b3b80d8
diff --git a/lib/Sema/SemaInit.cpp b/lib/Sema/SemaInit.cpp
index 126b386..d880c23 100644
--- a/lib/Sema/SemaInit.cpp
+++ b/lib/Sema/SemaInit.cpp
@@ -1672,7 +1672,7 @@
         else if (StartValue.getBitWidth() < EndValue.getBitWidth())
           StartValue.extend(EndValue.getBitWidth());
 
-        if (EndValue < StartValue) {
+        if (!StartDependent && !EndDependent && EndValue < StartValue) {
           Diag(D.getEllipsisLoc(), diag::err_array_designator_empty_range)
             << StartValue.toString(10) << EndValue.toString(10) 
             << StartIndex->getSourceRange() << EndIndex->getSourceRange();
diff --git a/lib/Sema/SemaTemplateInstantiateExpr.cpp b/lib/Sema/SemaTemplateInstantiateExpr.cpp
index 38f9245..14eef13 100644
--- a/lib/Sema/SemaTemplateInstantiateExpr.cpp
+++ b/lib/Sema/SemaTemplateInstantiateExpr.cpp
@@ -628,7 +628,22 @@
       continue;
     }
 
-    assert(false && "No array range designators, yet");
+    assert(D->isArrayRangeDesignator() && "New kind of designator?");
+    OwningExprResult Start = Visit(E->getArrayRangeStart(*D));
+    if (Start.isInvalid())
+      return SemaRef.ExprError();
+
+    OwningExprResult End = Visit(E->getArrayRangeEnd(*D));
+    if (End.isInvalid())
+      return SemaRef.ExprError();
+
+    Desig.AddDesignator(Designator::getArrayRange(Start.get(), 
+                                                  End.get(),
+                                                  D->getLBracketLoc(),
+                                                  D->getEllipsisLoc()));
+    
+    ArrayExprs.push_back(Start.release());
+    ArrayExprs.push_back(End.release());
   }
 
   OwningExprResult Result = 
diff --git a/test/SemaTemplate/instantiate-c99.cpp b/test/SemaTemplate/instantiate-c99.cpp
index a6d4dc9..a617594 100644
--- a/test/SemaTemplate/instantiate-c99.cpp
+++ b/test/SemaTemplate/instantiate-c99.cpp
@@ -54,3 +54,16 @@
 
 template struct DesigArrayInit0<int[8], 5, 3, float, int>;
 template struct DesigArrayInit0<int[8], 5, 13, float, int>; // expected-note{{instantiation}}
+
+template<typename T, int Subscript1, int Subscript2,
+         typename Val1>
+struct DesigArrayRangeInit0 {
+  void f(Val1 val1) {
+    T array = {
+      [Subscript1...Subscript2] = val1 // expected-error{{exceeds}}
+    };
+  }
+};
+
+template struct DesigArrayRangeInit0<int[8], 3, 5, float>;
+template struct DesigArrayRangeInit0<int[8], 5, 13, float>; // expected-note{{instantiation}}