[PATCH] Unknown-bound array static data member of template should be type dependent
Karthik Bhat
kv.bhat at samsung.com
Wed Nov 13 20:14:16 PST 2013
Hi Richard,
Modified the test case as suggested. Could someone commit this patch for me as i do not have the required permissions yet.
Thanks!
Hi rsmith,
http://llvm-reviews.chandlerc.com/D2049
CHANGE SINCE LAST DIFF
http://llvm-reviews.chandlerc.com/D2049?vs=5501&id=5532#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,44 @@
+// 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 N> void g() { int arr[N != 1 ? 1 : -1]; }
+ 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>()
+ }
+
+ 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() {
+ int arr[sizeof(arr) != sizeof(int) ? 1 : -1];
+ }
+ template<> int R<int>::arr[2];
+ template void R<int>::f();
+
+}
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D2049.3.patch
Type: text/x-patch
Size: 1654 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20131113/f6adecd4/attachment.bin>
More information about the cfe-commits
mailing list