[ C++ ] [ PATCH ] [ RFC ] p1301 - [[nodiscard("should have a reason")]]

Jason Merrill jason@redhat.com
Fri Nov 1 20:12:00 GMT 2019


On Sat, Oct 19, 2019 at 6:35 PM Jakub Jelinek <jakub@redhat.com> wrote:
>
> Hi!
>
> On Sat, Oct 19, 2019 at 12:46:56AM -0400, Jason Merrill wrote:
> >     gcc/testsuite/g++.dg/cpp2a
> >             * nodiscard-construct.C: New test.
> >             * nodiscard-once.C: New test.
> >             * nodiscard-reason-nonstring.C: New test.
> >             * nodiscard-reason-only-one.C: New test.
> >             * nodiscard-reason.C: New test.
>
> Unfortunately, the tests break testing with check-c++-all,
> ERROR: tcl error sourcing /home/jakub/src/gcc/gcc/testsuite/g++.dg/dg.exp.
> ERROR: couldn't compile regular expression pattern: quantifier operand invalid
>     while executing
> "regsub -all "(^|\n)(\[^\n\]+$line\[^\n\]*($pattern)\[^\n\]*\n?)+" $comp_output "\n" comp_output"
>     (procedure "saved-dg-test" line 125)
>     invoked from within
> "saved-dg-test /home/jakub/src/gcc/gcc/testsuite/g++.dg/cpp2a/nodiscard-reason-only-one.C { -std=gnu++2a} { -pedantic-errors -Wno-long-long}"
>     ("eval" body line 1)
>     invoked from within
> "eval saved-dg-test $args "
>     (procedure "dg-test" line 4)
>     invoked from within
> "dg-test $test "$flags $flags_t" ${default-extra-flags}"
>     (procedure "g++-dg-runtest" line 40)
>     invoked from within
> "g++-dg-runtest $tests "" $DEFAULT_CXXFLAGS"
>     (file "/home/jakub/src/gcc/gcc/testsuite/g++.dg/dg.exp" line 46)
>     invoked from within
> "source /home/jakub/src/gcc/gcc/testsuite/g++.dg/dg.exp"
>     ("uplevel" body line 1)
>     invoked from within
> "uplevel #0 source /home/jakub/src/gcc/gcc/testsuite/g++.dg/dg.exp"
>     invoked from within
> "catch "uplevel #0 source $test_file_name""
> testcase /home/jakub/src/gcc/gcc/testsuite/g++.dg/dg.exp completed in 291 seconds
>
> The problem is that tcl allows (?n) only at the start of the regex string,
> but for e.g. dg-warning or dg-error, gcc_error_prefix etc. is added to the
> start of the regex, e.g. (fatal )?error:
> so
> { dg-error "(?n)wrong number of arguments..*nodiscard" }
> will result in regex
> "(fatal )?error:(?n)wrong number of arguments..*nodiscard"
> and tcl will complain.
>
> I've just committed as obvious a mechanical change to unbreak this.
>
> Even with this change there are some FAILs, but not tcl errors already:
> FAIL: g++.dg/cpp2a/nodiscard-once.C  -std=gnu++2a (test for excess errors)
> FAIL: g++.dg/cpp2a/nodiscard-reason.C  -std=gnu++2a  (test for warnings, line 16)
> FAIL: g++.dg/cpp2a/nodiscard-reason.C  -std=gnu++2a  (test for warnings, line 17)
> FAIL: g++.dg/cpp2a/nodiscard-reason.C  -std=gnu++2a  (test for warnings, line 176)
> FAIL: g++.dg/cpp2a/nodiscard-reason.C  -std=gnu++2a  (test for warnings, line 178)
> FAIL: g++.dg/cpp2a/nodiscard-reason.C  -std=gnu++2a  (test for warnings, line 183)
> FAIL: g++.dg/cpp2a/nodiscard-reason.C  -std=gnu++2a  (test for warnings, line 185)
> FAIL: g++.dg/cpp2a/nodiscard-reason.C  -std=gnu++2a  (test for warnings, line 190)
> FAIL: g++.dg/cpp2a/nodiscard-reason.C  -std=gnu++2a  (test for warnings, line 192)
> FAIL: g++.dg/cpp2a/nodiscard-reason.C  -std=gnu++2a (test for excess errors)
>
> I'll defer to the patch author to resolve those, nodiscard-once is missing
> one dg-warning line, but in the other tests there are quite a few warning
> differences and the question is if it is desirable to change the testcase to
> match what the compiler is doing, or change what the compiler is doing.

What the compiler is doing seems reasonable to me, so I'm going to
adjust the tests.
-------------- next part --------------
A non-text attachment was scrubbed...
Name: nodiscard-test.diff
Type: text/x-patch
Size: 2880 bytes
Desc: not available
URL: <http://gcc.gnu.org/pipermail/gcc-patches/attachments/20191101/2c0df58b/attachment.bin>


More information about the Gcc-patches mailing list