* C++ PATCH for c++/70543 (wrong error with static const as array bound)
@ 2016-04-14 20:12 Jason Merrill
0 siblings, 0 replies; only message in thread
From: Jason Merrill @ 2016-04-14 20:12 UTC (permalink / raw)
To: gcc-patches List
[-- Attachment #1: Type: text/plain, Size: 202 bytes --]
When we consider whether the initializer for a constant variable makes
it value-dependent, we should check type-dependence as well as
value-dependence.
Tested x86_64-pc-linux-gnu, applying to trunk.
[-- Attachment #2: 70543.patch --]
[-- Type: text/x-patch, Size: 1330 bytes --]
commit 4af96532b224029a20b192be2e7cedc60b9d12d0
Author: Jason Merrill <jason@redhat.com>
Date: Thu Apr 14 13:23:44 2016 -0400
PR c++/70543
* pt.c (value_dependent_expression_p) [VAR_DECL]: A type-dependent
initializer also makes the variable value-dependent.
diff --git a/gcc/cp/pt.c b/gcc/cp/pt.c
index d066e55..4a00530 100644
--- a/gcc/cp/pt.c
+++ b/gcc/cp/pt.c
@@ -22670,6 +22670,7 @@ value_dependent_expression_p (tree expression)
&& (TREE_CODE (DECL_INITIAL (expression)) == TREE_LIST
/* cp_finish_decl doesn't fold reference initializers. */
|| TREE_CODE (TREE_TYPE (expression)) == REFERENCE_TYPE
+ || type_dependent_expression_p (DECL_INITIAL (expression))
|| value_dependent_expression_p (DECL_INITIAL (expression))))
return true;
return false;
diff --git a/gcc/testsuite/g++.dg/cpp0x/constexpr-template9.C b/gcc/testsuite/g++.dg/cpp0x/constexpr-template9.C
new file mode 100644
index 0000000..2ca641d
--- /dev/null
+++ b/gcc/testsuite/g++.dg/cpp0x/constexpr-template9.C
@@ -0,0 +1,17 @@
+// PR c++/70543
+// { dg-do compile { target c++11 } }
+
+template <typename>
+struct X
+{
+ template <unsigned int = 0>
+ static constexpr int
+ calc (void)
+ {
+ return 0;
+ }
+
+ static constexpr unsigned int value = calc ();
+
+ char foo[value];
+};
^ permalink raw reply [flat|nested] only message in thread
only message in thread, other threads:[~2016-04-14 20:12 UTC | newest]
Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2016-04-14 20:12 C++ PATCH for c++/70543 (wrong error with static const as array bound) Jason Merrill
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).