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")]]


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.

2019-10-20  Jakub Jelinek  <jakub@redhat.com>

	* g++.dg/cpp2a/nodiscard-reason-only-one.C: In dg-error or dg-warning
	remove (?n) uses and replace .* with \[^\n\r]*.
	* g++.dg/cpp2a/nodiscard-reason.C: Likewise.
	* g++.dg/cpp2a/nodiscard-once.C: Likewise.
	* g++.dg/cpp2a/nodiscard-reason-nonstring.C: Likewise.

--- gcc/testsuite/g++.dg/cpp2a/nodiscard-reason-only-one.C.jj	2019-10-19 09:22:16.167872983 +0200
+++ gcc/testsuite/g++.dg/cpp2a/nodiscard-reason-only-one.C	2019-10-20 00:19:51.556357897 +0200
@@ -2,7 +2,7 @@
 /* { dg-do compile { target c++2a } } */
 /* { dg-options "-O -ftrack-macro-expansion=0" } */
 
-[[nodiscard("not", "allowed")]] int check1 (void); /* { dg-error "(?n)wrong number of arguments..*nodiscard" } */
+[[nodiscard("not", "allowed")]] int check1 (void); /* { dg-error "wrong number of arguments.\[^\n\r]*nodiscard" } */
 
 void
 test (void)
--- gcc/testsuite/g++.dg/cpp2a/nodiscard-reason.C.jj	2019-10-19 09:22:16.167872983 +0200
+++ gcc/testsuite/g++.dg/cpp2a/nodiscard-reason.C	2019-10-20 00:21:06.320234961 +0200
@@ -13,8 +13,8 @@ typedef struct { char big[1024]; fnt fn;
 struct [[nodiscard("exact_D_message")]] D { int i; D(); ~D(); };
 
 NODIS E check1 (void);
-NODIS void check2 (void); /* { dg-warning "(?n)10:.nodiscard.*exact_message" } */
-NODIS int foo;         /* { dg-warning "(?n)9:.nodiscard.*exact_message" } */
+NODIS void check2 (void); /* { dg-warning "10:.nodiscard\[^\n\r]*exact_message" } */
+NODIS int foo;         /* { dg-warning "9:.nodiscard\[^\n\r]*exact_message" } */
 int bar (void);
 NODISAI E check3 (void) { return (E)bar (); }
 NODIS A check4 (void);
@@ -52,9 +52,9 @@ test (void)
     return;
   i += check1 ();
   i += ({ check1 (); });
-  check1 ();           /* { dg-warning "(?n)nodiscard.*exact_message" } */
+  check1 ();           /* { dg-warning "nodiscard\[^\n\r]*exact_message" } */
   (void) check1 ();
-  check1 (), bar ();   /* { dg-warning "(?n)nodiscard.*exact_message" } */
+  check1 (), bar ();   /* { dg-warning "nodiscard\[^\n\r]*exact_message" } */
   check2 ();
   (void) check2 ();
   check2 (), bar ();
@@ -62,9 +62,9 @@ test (void)
     return;
   i += check3 ();
   i += ({ check3 (); });
-  check3 ();           /* { dg-warning "(?n)nodiscard.*exact_inline_message" } */
+  check3 ();           /* { dg-warning "nodiscard\[^\n\r]*exact_inline_message" } */
   (void) check3 ();
-  check3 (), bar ();   /* { dg-warning "(?n)nodiscard.*exact_inline_message" } */
+  check3 (), bar ();   /* { dg-warning "nodiscard\[^\n\r]*exact_inline_message" } */
   a = check4 ();
   if (a.i)
     return;
@@ -72,9 +72,9 @@ test (void)
     return;
   if (({ check4 (); }).i)
     return;
-  check4 ();           /* { dg-warning "(?n)nodiscard.*exact_message" } */
+  check4 ();           /* { dg-warning "nodiscard\[^\n\r]*exact_message" } */
   (void) check4 ();
-  check4 (), bar ();   /* { dg-warning "(?n)nodiscard.*exact_message" } */
+  check4 (), bar ();   /* { dg-warning "nodiscard\[^\n\r]*exact_message" } */
   b = check5 ();
   if (b.i + b.j)
     return;
@@ -82,9 +82,9 @@ test (void)
     return;
   if (({ check5 (); }).j)
     return;
-  check5 ();           /* { dg-warning "(?n)nodiscard.*exact_message" } */
+  check5 ();           /* { dg-warning "nodiscard\[^\n\r]*exact_message" } */
   (void) check5 ();
-  check5 (), bar ();   /* { dg-warning "(?n)nodiscard.*exact_message" } */
+  check5 (), bar ();   /* { dg-warning "nodiscard\[^\n\r]*exact_message" } */
   c = check6 ();
   if (c.big[12] + c.big[29])
     return;
@@ -92,9 +92,9 @@ test (void)
     return;
   if (({ check6 (); }).big[0])
     return;
-  check6 ();           /* { dg-warning "(?n)nodiscard.*exact_message" } */
+  check6 ();           /* { dg-warning "nodiscard\[^\n\r]*exact_message" } */
   (void) check6 ();
-  check6 (), bar ();   /* { dg-warning "(?n)nodiscard.*exact_message" } */
+  check6 (), bar ();   /* { dg-warning "nodiscard\[^\n\r]*exact_message" } */
   a = check7 ();
   if (a.i)
     return;
@@ -102,9 +102,9 @@ test (void)
     return;
   if (({ check7 (); }).i)
     return;
-  check7 ();           /* { dg-warning "(?n)nodiscard.*exact_inline_message" } */
+  check7 ();           /* { dg-warning "nodiscard\[^\n\r]*exact_inline_message" } */
   (void) check7 ();
-  check7 (), bar ();   /* { dg-warning "(?n)nodiscard.*exact_inline_message" } */
+  check7 (), bar ();   /* { dg-warning "nodiscard\[^\n\r]*exact_inline_message" } */
   b = check8 ();
   if (b.i + b.j)
     return;
@@ -112,9 +112,9 @@ test (void)
     return;
   if (({ check8 (); }).j)
     return;
-  check8 ();           /* { dg-warning "(?n)nodiscard.*exact_inline_message" } */
+  check8 ();           /* { dg-warning "nodiscard\[^\n\r]*exact_inline_message" } */
   (void) check8 ();
-  check8 (), bar ();   /* { dg-warning "(?n)nodiscard.*exact_inline_message" } */
+  check8 (), bar ();   /* { dg-warning "nodiscard\[^\n\r]*exact_inline_message" } */
   c = check9 ();
   if (c.big[12] + c.big[29])
     return;
@@ -122,74 +122,74 @@ test (void)
     return;
   if (({ check9 (); }).big[0])
     return;
-  check9 ();           /* { dg-warning "(?n)nodiscard.*exact_inline_message" } */
+  check9 ();           /* { dg-warning "nodiscard\[^\n\r]*exact_inline_message" } */
   (void) check9 ();
-  check9 (), bar ();   /* { dg-warning "(?n)nodiscard.*exact_inline_message" } */
+  check9 (), bar ();   /* { dg-warning "nodiscard\[^\n\r]*exact_inline_message" } */
   if (check_int_result (GU (j)))
     return;
   i += check_int_result (GU (j));
   i += ({ check_int_result (GU (j)); });
-  check_int_result (GU (j)); /* { dg-warning "(?n)nodiscard.*exact_inline_message" } */
+  check_int_result (GU (j)); /* { dg-warning "nodiscard\[^\n\r]*exact_inline_message" } */
   (void) check_int_result (GU (j));
-  check_int_result (GU (j)), bar (); /* { dg-warning "(?n)nodiscard.*exact_inline_message" } */
+  check_int_result (GU (j)), bar (); /* { dg-warning "nodiscard\[^\n\r]*exact_inline_message" } */
   if (fnptr ())
     return;
   i += fnptr ();
   i += ({ fnptr (); });
-  fnptr ();            /* { dg-warning "(?n)nodiscard.*exact_E_message" } */
+  fnptr ();            /* { dg-warning "nodiscard\[^\n\r]*exact_E_message" } */
   (void) fnptr ();
-  fnptr (), bar ();    /* { dg-warning "(?n)nodiscard.*exact_E_message" } */
+  fnptr (), bar ();    /* { dg-warning "nodiscard\[^\n\r]*exact_E_message" } */
   fnptr = check1;
   if (fnptr ())
     return;
   i += fnptr ();
   i += ({ fnptr (); });
-  fnptr ();            /* { dg-warning "(?n)nodiscard.*exact_E_message" } */
+  fnptr ();            /* { dg-warning "nodiscard\[^\n\r]*exact_E_message" } */
   (void) fnptr ();
-  fnptr (), bar ();    /* { dg-warning "(?n)nodiscard.*exact_E_message" } */
+  fnptr (), bar ();    /* { dg-warning "nodiscard\[^\n\r]*exact_E_message" } */
   fnptr = check3;
   if (fnptr ())
     return;
   i += fnptr ();
   i += ({ fnptr (); });
-  fnptr ();            /* { dg-warning "(?n)nodiscard.*exact_E_message" } */
+  fnptr ();            /* { dg-warning "nodiscard\[^\n\r]*exact_E_message" } */
   (void) fnptr ();
-  fnptr (), bar ();    /* { dg-warning "(?n)nodiscard.*exact_E_message" } */
+  fnptr (), bar ();    /* { dg-warning "nodiscard\[^\n\r]*exact_E_message" } */
   if (bar9 ().fn ())
     return;
   i += bar9 ().fn ();
   i += ({ bar9 ().fn (); });
-  bar9 ().fn ();       /* { dg-warning "(?n)nodiscard.*exact_E_message" } */
+  bar9 ().fn ();       /* { dg-warning "nodiscard\[^\n\r]*exact_E_message" } */
   (void) bar9 ().fn ();
-  bar9 ().fn (), bar (); /* { dg-warning "(?n)nodiscard.*exact_E_message" } */
+  bar9 ().fn (), bar (); /* { dg-warning "nodiscard\[^\n\r]*exact_E_message" } */
   if ((k ? check1 : check10) ())
     return;
   i += (k ? check1 : check10) ();
   i += ({ (k ? check1 : check10) (); });
-  (k ? check1 : check10) (); /* { dg-warning "(?n)nodiscard.*exact_E_message" } */
+  (k ? check1 : check10) (); /* { dg-warning "nodiscard\[^\n\r]*exact_E_message" } */
   (void) (k ? check1 : check10) ();
-  (k ? check1 : check10) (), bar (); /* { dg-warning "(?n)nodiscard.*exact_E_message" } */
+  (k ? check1 : check10) (), bar (); /* { dg-warning "nodiscard\[^\n\r]*exact_E_message" } */
   if ((k ? check3 : check11) ())
     return;
   i += (k ? check3 : check11) ();
   i += ({ (k ? check3 : check11) (); });
-  (k ? check3 : check11) (); /* { dg-warning "(?n)nodiscard.*exact_inline_message" } */
+  (k ? check3 : check11) (); /* { dg-warning "nodiscard\[^\n\r]*exact_inline_message" } */
   (void) (k ? check3 : check11) ();
-  (k ? check3 : check11) (), bar (); /* { dg-warning "(?n)nodiscard.*exact_inline_message" } */
+  (k ? check3 : check11) (), bar (); /* { dg-warning "nodiscard\[^\n\r]*exact_inline_message" } */
   if (pcheck1 ())
     return;
   i += pcheck1 ();
   i += ({ pcheck1 (); });
-  pcheck1 ();          /* { dg-warning "(?n)nodiscard.*exact_E_message" } */
+  pcheck1 ();          /* { dg-warning "nodiscard\[^\n\r]*exact_E_message" } */
   (void) pcheck1 ();
-  pcheck1 (), bar ();  /* { dg-warning "(?n)nodiscard.*exact_E_message" } */
+  pcheck1 (), bar ();  /* { dg-warning "nodiscard\[^\n\r]*exact_E_message" } */
   if (pcheck3 ())
     return;
   i += pcheck3 ();
   i += ({ pcheck3 (); });
-  pcheck3 ();          /* { dg-warning "(?n)nodiscard.*exact_E_message" } */
+  pcheck3 ();          /* { dg-warning "nodiscard\[^\n\r]*exact_E_message" } */
   (void) pcheck3 ();
-  pcheck3 (), bar ();  /* { dg-warning "(?n)nodiscard.*exact_E_message" } */
+  pcheck3 (), bar ();  /* { dg-warning "nodiscard\[^\n\r]*exact_E_message" } */
   d = check12 ();
   if (d.i)
     return;
@@ -197,7 +197,7 @@ test (void)
     return;
   if (({ check12 (); }).i)
     return;
-  check12 ();          /* { dg-warning "(?n)nodiscard.*exact_D_message" } */
+  check12 ();          /* { dg-warning "nodiscard\[^\n\r]*exact_D_message" } */
   (void) check12 ();
-  check12 (), bar ();  /* { dg-warning "(?n)nodiscard.*exact_D_message" } */
+  check12 (), bar ();  /* { dg-warning "nodiscard\[^\n\r]*exact_D_message" } */
 }
--- gcc/testsuite/g++.dg/cpp2a/nodiscard-once.C.jj	2019-10-19 09:22:16.193872587 +0200
+++ gcc/testsuite/g++.dg/cpp2a/nodiscard-once.C	2019-10-20 00:24:40.195022613 +0200
@@ -2,7 +2,7 @@
 /* { dg-do compile { target c++2a } } */
 /* { dg-options "-O -ftrack-macro-expansion=0" } */
 
-[[nodiscard, nodiscard]] int check1 (void); /* { dg-error "(?n)nodiscard.*can appear at most once" } */
+[[nodiscard, nodiscard]] int check1 (void); /* { dg-error "nodiscard\[^\n\r]*can appear at most once" } */
 
 void
 test (void)
--- gcc/testsuite/g++.dg/cpp2a/nodiscard-reason-nonstring.C.jj	2019-10-19 09:22:16.167872983 +0200
+++ gcc/testsuite/g++.dg/cpp2a/nodiscard-reason-nonstring.C	2019-10-20 00:16:36.114293388 +0200
@@ -2,7 +2,7 @@
 /* { dg-do compile { target c++2a } } */
 /* { dg-options "-O -ftrack-macro-expansion=0" } */
 
-[[nodiscard(123)]] int check1 (void); /* { dg-error "(?n)nodiscard.*must be a string constant" } */
+[[nodiscard(123)]] int check1 (void); /* { dg-error "nodiscard\[^\n\r]*must be a string constant" } */
 
 void
 test (void)


	Jakub


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