]> git.ipfire.org Git - thirdparty/gcc.git/blame - contrib/test_mklog.py
[Ada] Bump copyright year
[thirdparty/gcc.git] / contrib / test_mklog.py
CommitLineData
00243d9a
ML
1#!/usr/bin/env python3
2
3# Copyright (C) 2020 Free Software Foundation, Inc.
4#
5# This file is part of GCC.
6#
7# GCC is free software; you can redistribute it and/or modify
8# it under the terms of the GNU General Public License as published by
9# the Free Software Foundation; either version 3, or (at your option)
10# any later version.
11#
12# GCC is distributed in the hope that it will be useful,
13# but WITHOUT ANY WARRANTY; without even the implied warranty of
14# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15# GNU General Public License for more details.
16#
17# You should have received a copy of the GNU General Public License
18# along with GCC; see the file COPYING. If not, write to
19# the Free Software Foundation, 51 Franklin Street, Fifth Floor,
20# Boston, MA 02110-1301, USA.
21
22# This script parses a .diff file generated with 'diff -up' or 'diff -cp'
23# and adds a skeleton ChangeLog file to the file. It does not try to be
24# too smart when parsing function names, but it produces a reasonable
25# approximation.
26#
27# Author: Martin Liska <mliska@suse.cz>
28
29import unittest
30
31from mklog import generate_changelog
32
eb78da45
ML
33import unidiff
34
35unidiff_supports_renaming = hasattr(unidiff.PatchedFile(), 'is_rename')
36
37
00243d9a
ML
38PATCH1 = '''\
39diff --git a/gcc/config/riscv/riscv.h b/gcc/config/riscv/riscv.h
40index 567c23380fe..e6209ede9d6 100644
41--- a/gcc/config/riscv/riscv.h
42+++ b/gcc/config/riscv/riscv.h
43@@ -920,6 +920,7 @@ extern unsigned riscv_stack_boundary;
44 #define SHIFT_RS1 15
45 #define SHIFT_IMM 20
46 #define IMM_BITS 12
47+#define C_S_BITS 5
48 #define C_SxSP_BITS 6
49
50 #define IMM_REACH (1LL << IMM_BITS)
51@@ -929,6 +930,10 @@ extern unsigned riscv_stack_boundary;
52 #define SWSP_REACH (4LL << C_SxSP_BITS)
53 #define SDSP_REACH (8LL << C_SxSP_BITS)
54
55+/* This is the maximum value that can be represented in a compressed load/store
56+ offset (an unsigned 5-bit value scaled by 4). */
57+#define CSW_MAX_OFFSET ((4LL << C_S_BITS) - 1) & ~3
58+
59 /* Called from RISCV_REORG, this is defined in riscv-sr.c. */
60
61 extern void riscv_remove_unneeded_save_restore_calls (void);
62
63'''
64
65EXPECTED1 = '''\
66gcc/ChangeLog:
67
68 * config/riscv/riscv.h (C_S_BITS):
69 (CSW_MAX_OFFSET):
70
71'''
72
73PATCH2 = '''\
74diff --git a/gcc/targhooks.h b/gcc/targhooks.h
75index 9704d23f1db..b572a36e8cf 100644
76--- a/gcc/targhooks.h
77+++ b/gcc/targhooks.h
78@@ -120,7 +120,7 @@ extern bool default_empty_mask_is_expensive (unsigned);
79 extern void *default_init_cost (class loop *);
80 extern unsigned default_add_stmt_cost (class vec_info *, void *, int,
81 enum vect_cost_for_stmt,
82- class _stmt_vec_info *, int,
83+ class _stmt_vec_info *, tree, int,
84 enum vect_cost_model_location);
85 extern void default_finish_cost (void *, unsigned *, unsigned *, unsigned *);
86 extern void default_destroy_cost_data (void *);
87@@ -186,6 +186,7 @@ extern tree default_emutls_var_init (tree, tree, tree);
88 extern unsigned int default_hard_regno_nregs (unsigned int, machine_mode);
89 extern bool default_hard_regno_scratch_ok (unsigned int);
90 extern bool default_mode_dependent_address_p (const_rtx, addr_space_t);
91+extern bool default_new_address_profitable_p (rtx, rtx_insn *, rtx);
92 extern bool default_target_option_valid_attribute_p (tree, tree, tree, int);
93 extern bool default_target_option_pragma_parse (tree, tree);
94 extern bool default_target_can_inline_p (tree, tree);
95
96'''
97
98EXPECTED2 = '''\
99gcc/ChangeLog:
100
101 * targhooks.h (default_add_stmt_cost):
102 (default_new_address_profitable_p):
103
104'''
105
106PATCH3 = '''\
107diff --git a/libcpp/include/cpplib.h b/libcpp/include/cpplib.h
108index 2b1e33f94ae..7f47402f9b9 100644
109--- a/libcpp/include/cpplib.h
110+++ b/libcpp/include/cpplib.h
111@@ -173,7 +173,7 @@ enum c_lang {CLK_GNUC89 = 0, CLK_GNUC99, CLK_GNUC11, CLK_GNUC17, CLK_GNUC2X,
112 CLK_STDC2X,
113 CLK_GNUCXX, CLK_CXX98, CLK_GNUCXX11, CLK_CXX11,
114 CLK_GNUCXX14, CLK_CXX14, CLK_GNUCXX17, CLK_CXX17,
115- CLK_GNUCXX2A, CLK_CXX2A, CLK_ASM};
116+ CLK_GNUCXX20, CLK_CXX20, CLK_ASM};
117
118 /* Payload of a NUMBER, STRING, CHAR or COMMENT token. */
119 struct GTY(()) cpp_string {
120@@ -484,7 +484,7 @@ struct cpp_options
121 /* Nonzero for C2X decimal floating-point constants. */
122 unsigned char dfp_constants;
123
124- /* Nonzero for C++2a __VA_OPT__ feature. */
125+ /* Nonzero for C++20 __VA_OPT__ feature. */
126 unsigned char va_opt;
127
128 /* Nonzero for the '::' token. */
129
130'''
131
132EXPECTED3 = '''\
133libcpp/ChangeLog:
134
135 * include/cpplib.h (enum c_lang):
136 (struct cpp_options):
137
138'''
139
140EXPECTED3B = '''\
141libcpp/ChangeLog:
142
143 * include/cpplib.h:
144
145'''
146
147PATCH4 = '''\
148diff --git a/gcc/ipa-icf.c b/gcc/ipa-icf.c
149index aab79492357..f0df1002488 100644
150--- a/gcc/ipa-icf.c
151+++ b/gcc/ipa-icf.c
152@@ -1,5 +1,7 @@
153
154
155+
156+
157 /* Interprocedural Identical Code Folding pass
158 Copyright (C) 2014-2020 Free Software Foundation, Inc.
159
160diff --git a/gcc/testsuite/gcc.dg/pr32374.c b/gcc/testsuite/gcc.dg/pr32374.c
161deleted file mode 100644
162index de15d559f5b..00000000000
163--- a/gcc/testsuite/gcc.dg/pr32374.c
164+++ /dev/null
165@@ -1,20 +0,0 @@
166-/* { dg-do compile } */
167-/* { dg-options "-O2" } */
168-
169-extern int *stderr;
170-
171-void f (int *, const char *, ...);
172-
173-void g (const char *conf_name)
174-{
175- typedef struct
176- {
177- const char *label;
178- const int value;
179- } Section;
180-
181- const Section sections[2] = { {"", 0}, {"", 1} };
182-
183- f (stderr, "", "", conf_name, 0, sections[0]);
184- f (stderr, "", "", conf_name, 0, sections[0]);
185-}
186diff --git a/gcc/testsuite/gcc.dg/pr40209.c b/gcc/testsuite/gcc.dg/pr40209.c
187index 4e77df5c2e6..c23d69d1f1b 100644
188--- a/gcc/testsuite/gcc.dg/pr40209.c
189+++ b/gcc/testsuite/gcc.dg/pr40209.c
190@@ -1,6 +1,8 @@
191 /* { dg-do compile } */
192 /* { dg-options "-O2 -fprofile-use -fopt-info -Wno-missing-profile" } */
193
194+
195+
196 void process(const char *s);
197
198 struct BaseHolder {
199diff --git a/gcc/testsuite/gcc.dg/pr50209.c b/gcc/testsuite/gcc.dg/pr50209.c
200new file mode 100644
201index 00000000000..b28b04f6431
202--- /dev/null
203+++ b/gcc/testsuite/gcc.dg/pr50209.c
204@@ -0,0 +1,3 @@
205+
206+
207+
208diff --git a/gcc/testsuite/gcc.dg/pr63567-1.c b/gcc/testsuite/gcc.dg/pr63567-1.c
209index 97da171563e..00c5ecc11fa 100644
210--- a/gcc/testsuite/gcc.dg/pr63567-1.c
211+++ b/gcc/testsuite/gcc.dg/pr63567-1.c
212@@ -1,3 +1,4 @@
213+
214 /* PR c/63567 */
215 /* { dg-do compile } */
216 /* { dg-options "" } */
217diff --git a/gcc/varasm.c b/gcc/varasm.c
218index f062e48071f..fd3c7ca8cf3 100644
219--- a/gcc/varasm.c
220+++ b/gcc/varasm.c
221@@ -1,3 +1,5 @@
222+
223+
224 /* Output variables, constants and external declarations, for GNU compiler.
225 Copyright (C) 1987-2020 Free Software Foundation, Inc.
226
227diff --git a/libssp/gets-chk.c b/libssp/gets-chk.c
228index 4ad78c1f77b..6687b368038 100644
229--- a/libssp/gets-chk.c
230+++ b/libssp/gets-chk.c
231@@ -32,6 +32,8 @@ see the files COPYING3 and COPYING.RUNTIME respectively. If not, see
232 <http://www.gnu.org/licenses/>. */
233
234
235+
236+
237 #include "config.h"
238 #include <ssp/ssp.h>
239 #include <stdarg.h>
240'''
241
242EXPECTED4 = '''\
243gcc/ChangeLog:
244
245 * ipa-icf.c:
246 * varasm.c:
247
248libssp/ChangeLog:
249
250 * gets-chk.c:
251
252gcc/testsuite/ChangeLog:
253
254 * gcc.dg/pr40209.c:
255 * gcc.dg/pr63567-1.c:
256 * gcc.dg/pr32374.c: Removed.
257 * gcc.dg/pr50209.c: New test.
258
259'''
260
261PATCH5 = '''\
262diff --git a/gcc/testsuite/gcc.target/i386/pr95046-6.c b/gcc/testsuite/gcc.target/i386/pr95046-6.c
263new file mode 100644
264index 00000000000..dcc8999c446
265--- /dev/null
266+++ b/gcc/testsuite/gcc.target/i386/pr95046-6.c
267@@ -0,0 +1,44 @@
268+/* PR target/95046 */
269+/* { dg-do compile { target { ! ia32 } } } */
270+/* { dg-options "-O3 -mavx512vl" } */
271+
272+
273+double r[2];
274+int s[2];
275+unsigned int u[2];
276+
277+void
278+test_float (void)
279+{
280+ for (int i = 0; i < 2; i++)
281+ r[i] = s[i];
282+}
283+
284+/* { dg-final { scan-assembler "\tvcvtdq2pd" } } */
285+
286+void
287+test_ufloat (void)
288+{
289+ for (int i = 0; i < 2; i++)
290+ r[i] = u[i];
291+}
292+
293+/* { dg-final { scan-assembler "\tvcvtudq2pd" } } */
294+
295+void
296+test_fix (void)
297+{
298+ for (int i = 0; i < 2; i++)
299+ s[i] = r[i];
300+}
301+
302+/* { dg-final { scan-assembler "\tvcvttpd2dqx" } } */
303+
304+void
305+test_ufix (void)
306+{
307+ for (int i = 0; i < 2; i++)
308+ u[i] = r[i];
309+}
310+
311+/* { dg-final { scan-assembler "\tvcvttpd2udqx" } } */
312--
3132.26.2
314
315'''
316
317EXPECTED5 = '''\
318PR target/95046 - Vectorize V2SFmode operations
319
320gcc/testsuite/ChangeLog:
321
322 PR target/95046
323 * gcc.target/i386/pr95046-6.c: New test.
324
325'''
326
4f85a52c
ML
327PATCH6 = '''\
328diff --git a/gcc/cgraph.h b/gcc/cgraph.h
329index 5ddeb65269b..cfae6e91da9 100644
330--- a/gcc/cgraph.h
331+++ b/gcc/cgraph.h
332@@ -937,7 +937,8 @@ struct GTY((tag ("SYMTAB_FUNCTION"))) cgraph_node : public symtab_node
333 split_part (false), indirect_call_target (false), local (false),
334 versionable (false), can_change_signature (false),
335 redefined_extern_inline (false), tm_may_enter_irr (false),
336- ipcp_clone (false), m_uid (uid), m_summary_id (-1)
337+ ipcp_clone (false), declare_variant_alt (false),
338+ calls_declare_variant_alt (false), m_uid (uid), m_summary_id (-1)
339 {}
340
341 /* Remove the node from cgraph and all inline clones inlined into it.
342
343'''
344
345EXPECTED6 = '''\
346gcc/ChangeLog:
347
348 * cgraph.h (struct cgraph_node):
349
350'''
351
e7c7cdc5
ML
352PATCH7 = '''\
353diff --git a/gcc/testsuite/g++.dg/DRs/dr2237.C b/gcc/testsuite/g++.dg/DRs/dr2237.C
354new file mode 100644
355index 00000000000..f3d6d11e61e
356--- /dev/null
357+++ b/gcc/testsuite/g++.dg/DRs/dr2237.C
358@@ -0,0 +1,18 @@
359+// DR 2237 - Can a template-id name a constructor?
360+
361+template<class T>
362+struct X {
363+ X<T>(); // { dg-error "expected" "" { target c++20 } }
364+ X(int); // OK, injected-class-name used
365+ ~X<T>(); // { dg-error "template-id not allowed for destructor" "" { target c++20 } }
366+};
367+
368+// ill-formed since DR1435
369+template<typename T> X<T>::X<T>() {} // { dg-error "names the constructor|as no template constructors" }
370+template<typename T> X<T>::~X<T>() {} // { dg-error "template-id not allowed for destructor" "" { target c++20 } }
371+
372+struct Q {
373+ // ill-formed since DR1435
374+ template<typename T> friend X<T>::X<T>(); // { dg-error "names the constructor|as no template constructors" }
375+ template<typename T> friend X<T>::~X<T>(); // { dg-error "template-id not allowed for destructor" "" { target c++20 } }
376+};
377'''
378
379EXPECTED7 = '''\
380gcc/testsuite/ChangeLog:
381
382 DR 2237
383 * g++.dg/DRs/dr2237.C: New test.
384
385'''
386
eb78da45
ML
387PATCH8 = '''\
388diff --git a/gcc/ipa-icf.c b/gcc/ipa-icf2.c
389similarity index 100%
390rename from gcc/ipa-icf.c
391rename to gcc/ipa-icf2.c
392'''
393
394EXPECTED8 = '''\
395gcc/ChangeLog:
396
397 * ipa-icf.c: Moved to...
398 * ipa-icf2.c: ...here.
399
400'''
401
00243d9a
ML
402class TestMklog(unittest.TestCase):
403 def test_macro_definition(self):
404 changelog = generate_changelog(PATCH1)
405 assert changelog == EXPECTED1
406
407 def test_changed_argument(self):
408 changelog = generate_changelog(PATCH2)
409 assert changelog == EXPECTED2
410
411 def test_enum_and_struct(self):
412 changelog = generate_changelog(PATCH3)
413 assert changelog == EXPECTED3
414
415 def test_no_function(self):
416 changelog = generate_changelog(PATCH3, True)
417 assert changelog == EXPECTED3B
418
419 def test_sorting(self):
420 changelog = generate_changelog(PATCH4)
421 assert changelog == EXPECTED4
422
423 def test_pr_bugzilla_download(self):
424 changelog = generate_changelog(PATCH5, fill_pr_titles=True)
425 assert changelog == EXPECTED5
4f85a52c
ML
426
427 def test_gty_in_struct(self):
428 changelog = generate_changelog(PATCH6, fill_pr_titles=True)
429 assert changelog == EXPECTED6
e7c7cdc5
ML
430
431 def test_dr_detection_in_test_case(self):
432 changelog = generate_changelog(PATCH7)
433 assert changelog == EXPECTED7
eb78da45
ML
434
435 @unittest.skipIf(not unidiff_supports_renaming,
436 'Newer version of unidiff is needed (0.6.0+)')
437 def test_renaming(self):
438 changelog = generate_changelog(PATCH8)
439 assert changelog == EXPECTED8