This is the mail archive of the
gcc-patches@gcc.gnu.org
mailing list for the GCC project.
C++ PATCH to catch array of array of unknown bound in template
- From: Jason Merrill <jason at redhat dot com>
- To: gcc-patches List <gcc-patches at gcc dot gnu dot org>
- Date: Wed, 28 May 2014 12:31:30 -0400
- Subject: C++ PATCH to catch array of array of unknown bound in template
- Authentication-results: sourceware.org; auth=none
Daveed from EDG pointed out this bug to me.
Tested x86_64-pc-linux-gnu, applying to trunk.
commit 912eae71d30adf6c07dbdf1b4741fd7ffd5a05ff
Author: Jason Merrill <jason@redhat.com>
Date: Wed May 28 11:50:50 2014 -0400
* pt.c (tsubst) [ARRAY_TYPE]: Check for array of array of unknown
bound.
diff --git a/gcc/cp/pt.c b/gcc/cp/pt.c
index 2ebe015..0b3cd7f 100644
--- a/gcc/cp/pt.c
+++ b/gcc/cp/pt.c
@@ -12084,7 +12084,7 @@ tsubst (tree t, tree args, tsubst_flags_t complain, tree in_decl)
if (type == TREE_TYPE (t) && domain == TYPE_DOMAIN (t))
return t;
- /* These checks should match the ones in grokdeclarator.
+ /* These checks should match the ones in create_array_type_for_decl.
[temp.deduct]
@@ -12095,6 +12095,8 @@ tsubst (tree t, tree args, tsubst_flags_t complain, tree in_decl)
an abstract class type. */
if (VOID_TYPE_P (type)
|| TREE_CODE (type) == FUNCTION_TYPE
+ || (TREE_CODE (type) == ARRAY_TYPE
+ && TYPE_DOMAIN (type) == NULL_TREE)
|| TREE_CODE (type) == REFERENCE_TYPE)
{
if (complain & tf_error)
diff --git a/gcc/testsuite/g++.dg/template/array28.C b/gcc/testsuite/g++.dg/template/array28.C
new file mode 100644
index 0000000..18b629d
--- /dev/null
+++ b/gcc/testsuite/g++.dg/template/array28.C
@@ -0,0 +1,7 @@
+typedef int (A)[];
+
+template<class T> void f(T (*)[1]); // { dg-error "array" }
+
+int main() {
+ f<int[]>(0); // { dg-error "no match" }
+}