* C++ PATCH for c++/88741 - wrong error with initializer-string
@ 2019-01-07 19:09 Marek Polacek
2019-01-07 19:22 ` Jason Merrill
0 siblings, 1 reply; 2+ messages in thread
From: Marek Polacek @ 2019-01-07 19:09 UTC (permalink / raw)
To: GCC Patches, Jason Merrill, David Malcolm
This fixes c++/88741, a bogus error with using [] in a template.
Starting with the "more location wrapper nodes" patch, cp_complete_array_type
can now receive a V_C_E in a CONSTRUCTOR, instead of just {"test"}, so we need
to strip any location wrappers as elsewhere for this code to work.
Bootstrapped/regtested on x86_64-linux, ok for trunk?
2019-01-07 Marek Polacek <polacek@redhat.com>
PR c++/88741 - wrong error with initializer-string.
* decl.c (cp_complete_array_type): Strip any location wrappers.
* g++.dg/init/array50.C: New test.
diff --git gcc/cp/decl.c gcc/cp/decl.c
index 15bc4887a59..1fc7a1acf56 100644
--- gcc/cp/decl.c
+++ gcc/cp/decl.c
@@ -8433,6 +8433,7 @@ cp_complete_array_type (tree *ptype, tree initial_value, bool do_default)
{
vec<constructor_elt, va_gc> *v = CONSTRUCTOR_ELTS (initial_value);
tree value = (*v)[0].value;
+ STRIP_ANY_LOCATION_WRAPPER (value);
if (TREE_CODE (value) == STRING_CST
&& v->length () == 1)
diff --git gcc/testsuite/g++.dg/init/array50.C gcc/testsuite/g++.dg/init/array50.C
new file mode 100644
index 00000000000..a5c129d0eb5
--- /dev/null
+++ gcc/testsuite/g++.dg/init/array50.C
@@ -0,0 +1,12 @@
+// PR c++/88741
+
+template <class T>
+void foo()
+{
+ char row[] = {"test"};
+}
+
+void bar()
+{
+ foo<int>();
+}
^ permalink raw reply [flat|nested] 2+ messages in thread
* Re: C++ PATCH for c++/88741 - wrong error with initializer-string
2019-01-07 19:09 C++ PATCH for c++/88741 - wrong error with initializer-string Marek Polacek
@ 2019-01-07 19:22 ` Jason Merrill
0 siblings, 0 replies; 2+ messages in thread
From: Jason Merrill @ 2019-01-07 19:22 UTC (permalink / raw)
To: Marek Polacek, GCC Patches, David Malcolm
On 1/7/19 2:09 PM, Marek Polacek wrote:
> This fixes c++/88741, a bogus error with using [] in a template.
> Starting with the "more location wrapper nodes" patch, cp_complete_array_type
> can now receive a V_C_E in a CONSTRUCTOR, instead of just {"test"}, so we need
> to strip any location wrappers as elsewhere for this code to work.
>
> Bootstrapped/regtested on x86_64-linux, ok for trunk?
OK.
Jason
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2019-01-07 19:22 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2019-01-07 19:09 C++ PATCH for c++/88741 - wrong error with initializer-string Marek Polacek
2019-01-07 19:22 ` 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).