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

Karthik Bhat kv.bhat at samsung.com
Tue Oct 29 03:58:49 PDT 2013


Hi rsmith,

Hi,
Review request on phabricator for patch discussed at http://permalink.gmane.org/gmane.comp.compilers.clang.scm/84487
for easier review.

Implemented review comments from Richard.
Please let me know if it looks good to commit.
Thanks.

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

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

Index: test/CXX/drs/dr2xx.cpp
===================================================================
--- test/CXX/drs/dr2xx.cpp
+++ test/CXX/drs/dr2xx.cpp
@@ -0,0 +1,30 @@
+// RUN: %clang_cc1 -std=c++98 %s -verify -fexceptions -fcxx-exceptions
+// RUN: %clang_cc1 -std=c++11 %s -verify -fexceptions -fcxx-exceptions
+// expected-no-diagnostics
+
+// Test that a specialization can have a different size.
+
+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>()
+}
Index: lib/AST/Expr.cpp
===================================================================
--- lib/AST/Expr.cpp
+++ lib/AST/Expr.cpp
@@ -314,6 +314,9 @@
         Var->getDeclContext()->isDependentContext()) {
       ValueDependent = true;
       InstantiationDependent = true;
+      TypeSourceInfo *TInfo = Var->getTypeSourceInfo();
+      if (TInfo->getType()->isIncompleteArrayType())
+        TypeDependent = true;
     }
     
     return;
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D2049.1.patch
Type: text/x-patch
Size: 1218 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20131029/8e32ebff/attachment.bin>


More information about the cfe-commits mailing list