This is the mail archive of the
gcc-patches@gcc.gnu.org
mailing list for the GCC project.
C++ PATCH for c++/63415 (value-dependent int(T{}))
- From: Jason Merrill <jason at redhat dot com>
- To: gcc-patches List <gcc-patches at gcc dot gnu dot org>
- Date: Thu, 09 Oct 2014 14:03:03 -0400
- Subject: C++ PATCH for c++/63415 (value-dependent int(T{}))
- Authentication-results: sourceware.org; auth=none
T{} is expressed as a CONSTRUCTOR with TREE_HAS_CONSTRUCTOR set, so we
need to consider the type and not just assume that all CONSTRUCTORs have
init-list type.
Tested x86_64-pc-linux-gnu, applying to trunk.
commit 81e370f51099c049313b9f6f1d8910e2475fbbcf
Author: Jason Merrill <jason@redhat.com>
Date: Wed Oct 8 17:15:07 2014 -0400
PR c++/63415
* pt.c (value_dependent_expression_p) [CONSTRUCTOR]: Check the type.
(iterative_hash_template_arg): Likewise.
diff --git a/gcc/cp/pt.c b/gcc/cp/pt.c
index 7d380e5..85af59d 100644
--- a/gcc/cp/pt.c
+++ b/gcc/cp/pt.c
@@ -1598,6 +1598,7 @@ iterative_hash_template_arg (tree arg, hashval_t val)
case CONSTRUCTOR:
{
tree field, value;
+ iterative_hash_template_arg (TREE_TYPE (arg), val);
FOR_EACH_CONSTRUCTOR_ELT (CONSTRUCTOR_ELTS (arg), i, field, value)
{
val = iterative_hash_template_arg (field, val);
@@ -21062,6 +21063,8 @@ value_dependent_expression_p (tree expression)
{
unsigned ix;
tree val;
+ if (dependent_type_p (TREE_TYPE (expression)))
+ return true;
FOR_EACH_CONSTRUCTOR_VALUE (CONSTRUCTOR_ELTS (expression), ix, val)
if (value_dependent_expression_p (val))
return true;
diff --git a/gcc/testsuite/g++.dg/cpp0x/constexpr-initlist8.C b/gcc/testsuite/g++.dg/cpp0x/constexpr-initlist8.C
new file mode 100644
index 0000000..3d859a8
--- /dev/null
+++ b/gcc/testsuite/g++.dg/cpp0x/constexpr-initlist8.C
@@ -0,0 +1,7 @@
+// PR c++/63415
+// { dg-do compile { target c++11 } }
+
+template <typename T>
+struct A {
+ static constexpr int value = int(T{});
+};