PR c++/88741 - wrong error with initializer-string.
authorMarek Polacek <polacek@redhat.com>
Mon, 7 Jan 2019 19:25:41 +0000 (19:25 +0000)
committerMarek Polacek <mpolacek@gcc.gnu.org>
Mon, 7 Jan 2019 19:25:41 +0000 (19:25 +0000)
* decl.c (cp_complete_array_type): Strip any location wrappers.

* g++.dg/init/array50.C: New test.

From-SVN: r267656

gcc/cp/ChangeLog
gcc/cp/decl.c
gcc/testsuite/ChangeLog
gcc/testsuite/g++.dg/init/array50.C [new file with mode: 0644]

index 60c8ae1..5267b9d 100644 (file)
@@ -1,3 +1,8 @@
+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.
+
 2019-01-07  Bernd Edlinger  <bernd.edlinger@hotmail.de>
 
        PR c++/88261
index 15bc488..1fc7a1a 100644 (file)
@@ -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)
index 4bb5634..c79593d 100644 (file)
@@ -1,3 +1,8 @@
+2019-01-07  Marek Polacek  <polacek@redhat.com>
+
+       PR c++/88741 - wrong error with initializer-string.
+       * g++.dg/init/array50.C: New test.
+
 2019-01-07  Bernd Edlinger  <bernd.edlinger@hotmail.de>
 
        PR c++/88261
diff --git a/gcc/testsuite/g++.dg/init/array50.C b/gcc/testsuite/g++.dg/init/array50.C
new file mode 100644 (file)
index 0000000..a5c129d
--- /dev/null
@@ -0,0 +1,12 @@
+// PR c++/88741
+
+template <class T>
+void foo()
+{
+  char row[] = {"test"};
+}
+  
+void bar()
+{
+  foo<int>();
+}