public inbox for gcc-cvs@sourceware.org
help / color / mirror / Atom feed
* [gcc(refs/vendors/ibm/heads/gcc-9)] c++: Fix array of char typedef in template (PR90966).
@ 2020-02-04 21:17 Peter Bergner
  0 siblings, 0 replies; only message in thread
From: Peter Bergner @ 2020-02-04 21:17 UTC (permalink / raw)
  To: gcc-cvs

https://gcc.gnu.org/g:dcb23017b1a9f65a81dbbe0f2b1a42999f7b2ac7

commit dcb23017b1a9f65a81dbbe0f2b1a42999f7b2ac7
Author: Jason Merrill <jason@redhat.com>
Date:   Sun Jan 26 22:19:47 2020 -0500

    c++: Fix array of char typedef in template (PR90966).
    
    Since Martin Sebor's patch for PR 71625 to change braced array initializers
    to STRING_CST in some cases, we need to be ready for STRING_CST with types
    that are changed by tsubst.  fold_convert doesn't know how to deal with
    STRING_CST, which is reasonable; we really shouldn't expect it to here.  So
    let's handle STRING_CST separately.
    
    	PR c++/90966
    	* pt.c (tsubst_copy) [STRING_CST]: Don't use fold_convert.

Diff:
---
 gcc/cp/ChangeLog                              |  3 +++
 gcc/cp/pt.c                                   | 13 ++++++++++++-
 gcc/testsuite/g++.dg/cpp0x/initlist-array10.C | 14 ++++++++++++++
 3 files changed, 29 insertions(+), 1 deletion(-)

diff --git a/gcc/cp/ChangeLog b/gcc/cp/ChangeLog
index d8fc647..9b1e506 100644
--- a/gcc/cp/ChangeLog
+++ b/gcc/cp/ChangeLog
@@ -1,5 +1,8 @@
 2020-01-28  Jason Merrill  <jason@redhat.com>
 
+	PR c++/90966
+	* pt.c (tsubst_copy) [STRING_CST]: Don't use fold_convert.
+
 	PR c++/93279 - ICE with lambda in member operator.
 	* name-lookup.c (maybe_save_operator_binding): Don't remember
 	class-scope bindings.
diff --git a/gcc/cp/pt.c b/gcc/cp/pt.c
index 692005b..c7245ef 100644
--- a/gcc/cp/pt.c
+++ b/gcc/cp/pt.c
@@ -16187,7 +16187,6 @@ tsubst_copy (tree t, tree args, tsubst_flags_t complain, tree in_decl)
 
     case INTEGER_CST:
     case REAL_CST:
-    case STRING_CST:
     case COMPLEX_CST:
       {
 	/* Instantiate any typedefs in the type.  */
@@ -16197,6 +16196,18 @@ tsubst_copy (tree t, tree args, tsubst_flags_t complain, tree in_decl)
 	return r;
       }
 
+    case STRING_CST:
+      {
+	tree type = tsubst (TREE_TYPE (t), args, complain, in_decl);
+	r = t;
+	if (type != TREE_TYPE (t))
+	  {
+	    r = copy_node (t);
+	    TREE_TYPE (r) = type;
+	  }
+	return r;
+      }
+
     case PTRMEM_CST:
       /* These can sometimes show up in a partial instantiation, but never
 	 involve template parms.  */
diff --git a/gcc/testsuite/g++.dg/cpp0x/initlist-array10.C b/gcc/testsuite/g++.dg/cpp0x/initlist-array10.C
new file mode 100644
index 0000000..fb9e136
--- /dev/null
+++ b/gcc/testsuite/g++.dg/cpp0x/initlist-array10.C
@@ -0,0 +1,14 @@
+// PR c++/90966
+// { dg-do compile { target c++11 } }
+
+template<typename I>
+void f()
+{
+  using S = signed char;
+  constexpr const S v[]{0};
+}
+
+int main()
+{
+  f<int>();
+}


^ permalink raw reply	[flat|nested] only message in thread

only message in thread, other threads:[~2020-02-04 21:17 UTC | newest]

Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-02-04 21:17 [gcc(refs/vendors/ibm/heads/gcc-9)] c++: Fix array of char typedef in template (PR90966) Peter Bergner

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).