mklog: support parsing of DR.

Message ID 1519cc93-aff6-b3c7-6440-c1c8ee7a9dbf@suse.cz
State New
Headers show
Series
  • mklog: support parsing of DR.
Related show

Commit Message

Martin Liška May 21, 2020, 8:14 a.m.
Hi.

Let's support automatic detection of DRs from test-suite, similarly
what we do for PR entries.

Installed.
Martin

contrib/ChangeLog:

2020-05-21  Martin Liska  <mliska@suse.cz>

	* mklog.py: Support DR parsing.
	* test_mklog.py: New test for DR parsing.
---
  contrib/mklog.py      |  9 ++++++++-
  contrib/test_mklog.py | 39 +++++++++++++++++++++++++++++++++++++++
  2 files changed, 47 insertions(+), 1 deletion(-)

Patch

diff --git a/contrib/mklog.py b/contrib/mklog.py
index b27fad0ca2e..7a19b5d0949 100755
--- a/contrib/mklog.py
+++ b/contrib/mklog.py
@@ -36,6 +36,7 @@  import requests
 from unidiff import PatchSet
 
 pr_regex = re.compile(r'(\/(\/|\*)|[Cc*!])\s+(?P<pr>PR [a-z+-]+\/[0-9]+)')
+dr_regex = re.compile(r'(\/(\/|\*)|[Cc*!])\s+(?P<dr>DR [0-9]+)')
 identifier_regex = re.compile(r'^([a-zA-Z0-9_#].*)')
 comment_regex = re.compile(r'^\/\*')
 struct_regex = re.compile(r'^(class|struct|union|enum)\s+'
@@ -142,7 +143,13 @@  def generate_changelog(data, no_functions=False, fill_pr_titles=False):
                     if pr not in prs:
                         prs.append(pr)
                 else:
-                    break
+                    m = dr_regex.search(line.value)
+                    if m:
+                        dr = m.group('dr')
+                        if dr not in prs:
+                            prs.append(dr)
+                    else:
+                        break
 
     if fill_pr_titles:
         out += get_pr_titles(prs)
diff --git a/contrib/test_mklog.py b/contrib/test_mklog.py
index 774b6ea62d0..ef7f2b1a594 100755
--- a/contrib/test_mklog.py
+++ b/contrib/test_mklog.py
@@ -344,6 +344,41 @@  gcc/ChangeLog:
 
 '''
 
+PATCH7 = '''\
+diff --git a/gcc/testsuite/g++.dg/DRs/dr2237.C b/gcc/testsuite/g++.dg/DRs/dr2237.C
+new file mode 100644
+index 00000000000..f3d6d11e61e
+--- /dev/null
++++ b/gcc/testsuite/g++.dg/DRs/dr2237.C
+@@ -0,0 +1,18 @@
++// DR 2237 - Can a template-id name a constructor?
++
++template<class T>
++struct X {
++  X<T>(); // { dg-error "expected" "" { target c++20 } }
++  X(int); // OK, injected-class-name used
++  ~X<T>(); // { dg-error "template-id not allowed for destructor" "" { target c++20 } }
++};
++
++// ill-formed since DR1435
++template<typename T> X<T>::X<T>() {} // { dg-error "names the constructor|as no template constructors" }
++template<typename T> X<T>::~X<T>() {} // { dg-error "template-id not allowed for destructor" "" { target c++20 } }
++
++struct Q {
++  // ill-formed since DR1435
++  template<typename T> friend X<T>::X<T>(); // { dg-error "names the constructor|as no template constructors" }
++  template<typename T> friend X<T>::~X<T>(); // { dg-error "template-id not allowed for destructor" "" { target c++20 } }
++};
+'''
+
+EXPECTED7 = '''\
+gcc/testsuite/ChangeLog:
+
+	DR 2237
+	* g++.dg/DRs/dr2237.C: New test.
+
+'''
+
 class TestMklog(unittest.TestCase):
     def test_macro_definition(self):
         changelog = generate_changelog(PATCH1)
@@ -372,3 +407,7 @@  class TestMklog(unittest.TestCase):
     def test_gty_in_struct(self):
         changelog = generate_changelog(PATCH6, fill_pr_titles=True)
         assert changelog == EXPECTED6
+
+    def test_dr_detection_in_test_case(self):
+        changelog = generate_changelog(PATCH7)
+        assert changelog == EXPECTED7