[PATCH] Unknown-bound array static data member of template should be type dependent

Karthik Bhat kv.bhat at samsung.com
Wed Nov 13 02:11:56 PST 2013


  Thanks Richard for the valuable inputs. I have made the required modifications in code and test case.
  Does this look good to commit?
  Thanks.

Hi rsmith,

http://llvm-reviews.chandlerc.com/D2049

CHANGE SINCE LAST DIFF
  http://llvm-reviews.chandlerc.com/D2049?vs=5224&id=5501#toc

Files:
  lib/AST/Expr.cpp
  test/CXX/drs/dr4xx.cpp

Index: lib/AST/Expr.cpp
===================================================================
--- lib/AST/Expr.cpp
+++ lib/AST/Expr.cpp
@@ -315,6 +315,9 @@
         Var->getDeclContext()->isDependentContext()) {
       ValueDependent = true;
       InstantiationDependent = true;
+      TypeSourceInfo *TInfo = Var->getFirstDecl()->getTypeSourceInfo();
+      if (TInfo->getType()->isIncompleteArrayType())
+        TypeDependent = true;
     }
     
     return;
Index: test/CXX/drs/dr4xx.cpp
===================================================================
--- test/CXX/drs/dr4xx.cpp
+++ test/CXX/drs/dr4xx.cpp
@@ -0,0 +1,45 @@
+// RUN: %clang_cc1 -std=c++98 %s -verify -fexceptions -fcxx-exceptions -pedantic-errors
+// RUN: %clang_cc1 -std=c++11 %s -verify -fexceptions -fcxx-exceptions -pedantic-errors
+// expected-no-diagnostics
+
+// Test that a specialization can have a different size.
+
+namespace dr408 { // dr408: yes
+  template <int> void g();
+  template <> void g<2>() { }
+
+  template <typename T>
+  struct S {
+    static int i[];
+    void f();
+  };
+
+  template <typename T>
+  int S<T>::i[] = { 1 };
+
+  template <typename T>
+  void S<T>::f() {
+    g<sizeof (i) / sizeof (int)>();
+  }
+
+  template <>
+  int S<int>::i[] = { 1, 2 };
+
+  void test() {
+    S<int> s;
+    s.f(); // Triggers void g<2>()
+  }
+
+#if __cplusplus >= 201103L
+  template<typename T> struct R {
+  static int arr[];
+  void f();
+  };
+  template<typename T> int R<T>::arr[1];
+  template<typename T> void R<T>::f() {
+    static_assert(sizeof(arr) != sizeof(int), "");
+  }
+  template<> int R<int>::arr[2];
+  template void R<int>::f();
+#endif
+}
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D2049.2.patch
Type: text/x-patch
Size: 1659 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20131113/e8b629ac/attachment.bin>


More information about the cfe-commits mailing list