This is the mail archive of the gcc-patches@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

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


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.
commit ce706422720f55841b1a5d37c4ef5fbff2182464
Author: Jason Merrill <jason@redhat.com>
Date:   Fri Nov 1 11:16:34 2019 -0400

    Fix nodiscard test failures.
    
            * g++.dg/cpp2a/nodiscard-once.C: Expect nodiscard warning.
            * g++.dg/cpp2a/nodiscard-reason.C: Adjust expected warnings.

diff --git a/gcc/testsuite/g++.dg/cpp2a/nodiscard-once.C b/gcc/testsuite/g++.dg/cpp2a/nodiscard-once.C
index b9dde5cfb57..78349715aae 100644
--- a/gcc/testsuite/g++.dg/cpp2a/nodiscard-once.C
+++ b/gcc/testsuite/g++.dg/cpp2a/nodiscard-once.C
@@ -7,6 +7,6 @@
 void
 test (void)
 {
-  check1 ();
+  check1 ();			// { dg-warning "nodiscard" }
   (void) check1 ();
 }
diff --git a/gcc/testsuite/g++.dg/cpp2a/nodiscard-reason.C b/gcc/testsuite/g++.dg/cpp2a/nodiscard-reason.C
index e0230b1d519..5fda058c9ee 100644
--- a/gcc/testsuite/g++.dg/cpp2a/nodiscard-reason.C
+++ b/gcc/testsuite/g++.dg/cpp2a/nodiscard-reason.C
@@ -13,8 +13,8 @@ typedef struct { char big[1024]; fnt fn; } C;
 struct [[nodiscard("exact_D_message")]] D { int i; D(); ~D(); };
 
 NODIS E check1 (void);
-NODIS void check2 (void); /* { dg-warning "10:.nodiscard\[^\n\r]*exact_message" } */
-NODIS int foo;         /* { dg-warning "9:.nodiscard\[^\n\r]*exact_message" } */
+NODIS void check2 (void); /* { dg-warning "12:.nodiscard\[^\n\r]*void" } */
+NODIS int foo;         /* { dg-warning "11:.nodiscard\[^\n\r]*class" } */
 int bar (void);
 NODISAI E check3 (void) { return (E)bar (); }
 NODIS A check4 (void);
@@ -173,23 +173,23 @@ test (void)
     return;
   i += (k ? check3 : check11) ();
   i += ({ (k ? check3 : check11) (); });
-  (k ? check3 : check11) (); /* { dg-warning "nodiscard\[^\n\r]*exact_inline_message" } */
+  (k ? check3 : check11) (); /* { dg-warning "nodiscard\[^\n\r]*exact_E_message" } */
   (void) (k ? check3 : check11) ();
-  (k ? check3 : check11) (), bar (); /* { dg-warning "nodiscard\[^\n\r]*exact_inline_message" } */
+  (k ? check3 : check11) (), bar (); /* { dg-warning "nodiscard\[^\n\r]*exact_E_message" } */
   if (pcheck1 ())
     return;
   i += pcheck1 ();
   i += ({ pcheck1 (); });
-  pcheck1 ();          /* { dg-warning "nodiscard\[^\n\r]*exact_E_message" } */
+  pcheck1 ();          /* { dg-warning "nodiscard\[^\n\r]*exact_" } */
   (void) pcheck1 ();
-  pcheck1 (), bar ();  /* { dg-warning "nodiscard\[^\n\r]*exact_E_message" } */
+  pcheck1 (), bar ();  /* { dg-warning "nodiscard\[^\n\r]*exact_" } */
   if (pcheck3 ())
     return;
   i += pcheck3 ();
   i += ({ pcheck3 (); });
-  pcheck3 ();          /* { dg-warning "nodiscard\[^\n\r]*exact_E_message" } */
+  pcheck3 ();          /* { dg-warning "nodiscard\[^\n\r]*exact_" } */
   (void) pcheck3 ();
-  pcheck3 (), bar ();  /* { dg-warning "nodiscard\[^\n\r]*exact_E_message" } */
+  pcheck3 (), bar ();  /* { dg-warning "nodiscard\[^\n\r]*exact_" } */
   d = check12 ();
   if (d.i)
     return;

Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]