From: Marek Polacek Date: Mon, 7 Jan 2019 19:25:41 +0000 (+0000) Subject: PR c++/88741 - wrong error with initializer-string. X-Git-Url: https://git.libre-soc.org/?a=commitdiff_plain;h=25a34b0236ffcf23e9bc29826475729ccfef7c38;p=gcc.git 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. From-SVN: r267656 --- diff --git a/gcc/cp/ChangeLog b/gcc/cp/ChangeLog index 60c8ae1934e..5267b9d24f7 100644 --- a/gcc/cp/ChangeLog +++ b/gcc/cp/ChangeLog @@ -1,3 +1,8 @@ +2019-01-07 Marek Polacek + + PR c++/88741 - wrong error with initializer-string. + * decl.c (cp_complete_array_type): Strip any location wrappers. + 2019-01-07 Bernd Edlinger PR c++/88261 diff --git a/gcc/cp/decl.c b/gcc/cp/decl.c index 15bc4887a59..1fc7a1acf56 100644 --- a/gcc/cp/decl.c +++ b/gcc/cp/decl.c @@ -8433,6 +8433,7 @@ cp_complete_array_type (tree *ptype, tree initial_value, bool do_default) { vec *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 a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog index 4bb56349adf..c79593d7f0e 100644 --- a/gcc/testsuite/ChangeLog +++ b/gcc/testsuite/ChangeLog @@ -1,3 +1,8 @@ +2019-01-07 Marek Polacek + + PR c++/88741 - wrong error with initializer-string. + * g++.dg/init/array50.C: New test. + 2019-01-07 Bernd Edlinger 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 index 00000000000..a5c129d0eb5 --- /dev/null +++ b/gcc/testsuite/g++.dg/init/array50.C @@ -0,0 +1,12 @@ +// PR c++/88741 + +template +void foo() +{ + char row[] = {"test"}; +} + +void bar() +{ + foo(); +}