re PR c++/65390 (ICE in strip_typedefs, at cp/tree.c:1361)
authorMarek Polacek <polacek@redhat.com>
Tue, 31 Mar 2015 17:35:29 +0000 (17:35 +0000)
committerMarek Polacek <mpolacek@gcc.gnu.org>
Tue, 31 Mar 2015 17:35:29 +0000 (17:35 +0000)
PR c++/65390
* tree.c (build_cplus_array_type): Use dependent_type_p rather than
checking for constness.

* g++.dg/template/pr65390.C: New test.

From-SVN: r221799

gcc/cp/ChangeLog
gcc/cp/tree.c
gcc/testsuite/ChangeLog
gcc/testsuite/g++.dg/template/pr65390.C [new file with mode: 0644]

index ec35f22fe0444e670129196364c138acadc76b07..0d2456d6eb89cc7f57f4ee561056ef18cb5ec1c7 100644 (file)
@@ -1,3 +1,9 @@
+2015-03-31  Marek Polacek  <polacek@redhat.com>
+
+       PR c++/65390
+       * tree.c (build_cplus_array_type): Use dependent_type_p rather than
+       checking for constness.
+
 2015-03-30  Marek Polacek  <polacek@redhat.com>
 
        PR c++/65398
index ef53aff87f74cff4427b9aa5a8a8829166f90e43..97bccc034038c855ab0d48c541f4a78437c3b999 100644 (file)
@@ -822,10 +822,9 @@ build_cplus_array_type (tree elt_type, tree index_type)
   if (elt_type == error_mark_node || index_type == error_mark_node)
     return error_mark_node;
 
-  bool dependent
-    = (processing_template_decl
-       && (dependent_type_p (elt_type)
-          || (index_type && !TREE_CONSTANT (TYPE_MAX_VALUE (index_type)))));
+  bool dependent = (processing_template_decl
+                   && (dependent_type_p (elt_type)
+                       || (index_type && dependent_type_p (index_type))));
 
   if (elt_type != TYPE_MAIN_VARIANT (elt_type))
     /* Start with an array of the TYPE_MAIN_VARIANT.  */
index 5d0d3b4f73fc4acd139d813693b4428fad0ff905..e317b5e0011c3f3887983f2b16336e57bfe48c2e 100644 (file)
@@ -1,3 +1,8 @@
+2015-03-31  Marek Polacek  <polacek@redhat.com>
+
+       PR c++/65390
+       * g++.dg/template/pr65390.C: New test.
+
 2015-03-31  Martin Liska  <mliska@suse.cz>
 
        * g++.dg/ipa/pr65557.C: New test.
diff --git a/gcc/testsuite/g++.dg/template/pr65390.C b/gcc/testsuite/g++.dg/template/pr65390.C
new file mode 100644 (file)
index 0000000..299d22a
--- /dev/null
@@ -0,0 +1,12 @@
+// PR c++/65390
+// { dg-do compile }
+// { dg-options "" }
+
+template<typename T> struct shared_ptr { };
+
+template<typename T, typename Arg>
+shared_ptr<T> make_shared(Arg) { return shared_ptr<T>(); } // { dg-error "variably modified type|trying to instantiate" }
+
+void f(int n){
+  make_shared<int[n]>(1); // { dg-error "no matching function" }
+}