c++: designated init with anonymous union [PR100489]
[official-gcc.git] / contrib / test_mklog.py
bloba0670dac119f919b87efcdacae904897f1e65cd3
1 #!/usr/bin/env python3
3 # Copyright (C) 2020 Free Software Foundation, Inc.
5 # This file is part of GCC.
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.
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.
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.
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.
27 # Author: Martin Liska <mliska@suse.cz>
29 import unittest
31 from mklog import generate_changelog
33 import unidiff
35 unidiff_supports_renaming = hasattr(unidiff.PatchedFile(), 'is_rename')
38 PATCH1 = '''\
39 diff --git a/gcc/config/riscv/riscv.h b/gcc/config/riscv/riscv.h
40 index 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
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)
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
59 /* Called from RISCV_REORG, this is defined in riscv-sr.c. */
61 extern void riscv_remove_unneeded_save_restore_calls (void);
63 '''
65 EXPECTED1 = '''\
66 gcc/ChangeLog:
68 * config/riscv/riscv.h (C_S_BITS):
69 (CSW_MAX_OFFSET):
71 '''
73 PATCH2 = '''\
74 diff --git a/gcc/targhooks.h b/gcc/targhooks.h
75 index 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);
96 '''
98 EXPECTED2 = '''\
99 gcc/ChangeLog:
101 * targhooks.h (default_add_stmt_cost):
102 (default_new_address_profitable_p):
106 PATCH3 = '''\
107 diff --git a/libcpp/include/cpplib.h b/libcpp/include/cpplib.h
108 index 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};
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;
124 - /* Nonzero for C++2a __VA_OPT__ feature. */
125 + /* Nonzero for C++20 __VA_OPT__ feature. */
126 unsigned char va_opt;
128 /* Nonzero for the '::' token. */
132 EXPECTED3 = '''\
133 libcpp/ChangeLog:
135 * include/cpplib.h (enum c_lang):
136 (struct cpp_options):
140 EXPECTED3B = '''\
141 libcpp/ChangeLog:
143 * include/cpplib.h:
147 PATCH4 = '''\
148 diff --git a/gcc/ipa-icf.c b/gcc/ipa-icf.c
149 index aab79492357..f0df1002488 100644
150 --- a/gcc/ipa-icf.c
151 +++ b/gcc/ipa-icf.c
152 @@ -1,5 +1,7 @@
157 /* Interprocedural Identical Code Folding pass
158 Copyright (C) 2014-2020 Free Software Foundation, Inc.
160 diff --git a/gcc/testsuite/gcc.dg/pr32374.c b/gcc/testsuite/gcc.dg/pr32374.c
161 deleted file mode 100644
162 index 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" } */
169 -extern int *stderr;
171 -void f (int *, const char *, ...);
173 -void g (const char *conf_name)
175 - typedef struct
177 - const char *label;
178 - const int value;
179 - } Section;
181 - const Section sections[2] = { {"", 0}, {"", 1} };
183 - f (stderr, "", "", conf_name, 0, sections[0]);
184 - f (stderr, "", "", conf_name, 0, sections[0]);
186 diff --git a/gcc/testsuite/gcc.dg/pr40209.c b/gcc/testsuite/gcc.dg/pr40209.c
187 index 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" } */
196 void process(const char *s);
198 struct BaseHolder {
199 diff --git a/gcc/testsuite/gcc.dg/pr50209.c b/gcc/testsuite/gcc.dg/pr50209.c
200 new file mode 100644
201 index 00000000000..b28b04f6431
202 --- /dev/null
203 +++ b/gcc/testsuite/gcc.dg/pr50209.c
204 @@ -0,0 +1,3 @@
208 diff --git a/gcc/testsuite/gcc.dg/pr63567-1.c b/gcc/testsuite/gcc.dg/pr63567-1.c
209 index 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 @@
214 /* PR c/63567 */
215 /* { dg-do compile } */
216 /* { dg-options "" } */
217 diff --git a/gcc/varasm.c b/gcc/varasm.c
218 index f062e48071f..fd3c7ca8cf3 100644
219 --- a/gcc/varasm.c
220 +++ b/gcc/varasm.c
221 @@ -1,3 +1,5 @@
224 /* Output variables, constants and external declarations, for GNU compiler.
225 Copyright (C) 1987-2020 Free Software Foundation, Inc.
227 diff --git a/libssp/gets-chk.c b/libssp/gets-chk.c
228 index 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/>. */
237 #include "config.h"
238 #include <ssp/ssp.h>
239 #include <stdarg.h>
242 EXPECTED4 = '''\
243 gcc/ChangeLog:
245 * ipa-icf.c:
246 * varasm.c:
248 libssp/ChangeLog:
250 * gets-chk.c:
252 gcc/testsuite/ChangeLog:
254 * gcc.dg/pr40209.c:
255 * gcc.dg/pr63567-1.c:
256 * gcc.dg/pr32374.c: Removed.
257 * gcc.dg/pr50209.c: New test.
261 PATCH5 = '''\
262 diff --git a/gcc/testsuite/gcc.target/i386/pr95046-6.c b/gcc/testsuite/gcc.target/i386/pr95046-6.c
263 new file mode 100644
264 index 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" } */
273 +double r[2];
274 +int s[2];
275 +unsigned int u[2];
277 +void
278 +test_float (void)
280 + for (int i = 0; i < 2; i++)
281 + r[i] = s[i];
284 +/* { dg-final { scan-assembler "\tvcvtdq2pd" } } */
286 +void
287 +test_ufloat (void)
289 + for (int i = 0; i < 2; i++)
290 + r[i] = u[i];
293 +/* { dg-final { scan-assembler "\tvcvtudq2pd" } } */
295 +void
296 +test_fix (void)
298 + for (int i = 0; i < 2; i++)
299 + s[i] = r[i];
302 +/* { dg-final { scan-assembler "\tvcvttpd2dqx" } } */
304 +void
305 +test_ufix (void)
307 + for (int i = 0; i < 2; i++)
308 + u[i] = r[i];
311 +/* { dg-final { scan-assembler "\tvcvttpd2udqx" } } */
313 2.26.2
317 EXPECTED5 = '''\
318 PR target/95046 - Vectorize V2SFmode operations
320 PR target/95046
322 gcc/testsuite/ChangeLog:
324 * gcc.target/i386/pr95046-6.c: New test.
328 PATCH6 = '''\
329 diff --git a/gcc/cgraph.h b/gcc/cgraph.h
330 index 5ddeb65269b..cfae6e91da9 100644
331 --- a/gcc/cgraph.h
332 +++ b/gcc/cgraph.h
333 @@ -937,7 +937,8 @@ struct GTY((tag ("SYMTAB_FUNCTION"))) cgraph_node : public symtab_node
334 split_part (false), indirect_call_target (false), local (false),
335 versionable (false), can_change_signature (false),
336 redefined_extern_inline (false), tm_may_enter_irr (false),
337 - ipcp_clone (false), m_uid (uid), m_summary_id (-1)
338 + ipcp_clone (false), declare_variant_alt (false),
339 + calls_declare_variant_alt (false), m_uid (uid), m_summary_id (-1)
342 /* Remove the node from cgraph and all inline clones inlined into it.
346 EXPECTED6 = '''\
347 gcc/ChangeLog:
349 * cgraph.h (struct cgraph_node):
353 PATCH7 = '''\
354 diff --git a/gcc/testsuite/g++.dg/DRs/dr2237.C b/gcc/testsuite/g++.dg/DRs/dr2237.C
355 new file mode 100644
356 index 00000000000..f3d6d11e61e
357 --- /dev/null
358 +++ b/gcc/testsuite/g++.dg/DRs/dr2237.C
359 @@ -0,0 +1,18 @@
360 +// DR 2237 - Can a template-id name a constructor?
362 +template<class T>
363 +struct X {
364 + X<T>(); // { dg-error "expected" "" { target c++20 } }
365 + X(int); // OK, injected-class-name used
366 + ~X<T>(); // { dg-error "template-id not allowed for destructor" "" { target c++20 } }
369 +// ill-formed since DR1435
370 +template<typename T> X<T>::X<T>() {} // { dg-error "names the constructor|as no template constructors" }
371 +template<typename T> X<T>::~X<T>() {} // { dg-error "template-id not allowed for destructor" "" { target c++20 } }
373 +struct Q {
374 + // ill-formed since DR1435
375 + template<typename T> friend X<T>::X<T>(); // { dg-error "names the constructor|as no template constructors" }
376 + template<typename T> friend X<T>::~X<T>(); // { dg-error "template-id not allowed for destructor" "" { target c++20 } }
380 EXPECTED7 = '''\
382 DR 2237
384 gcc/testsuite/ChangeLog:
386 * g++.dg/DRs/dr2237.C: New test.
390 PATCH8 = '''\
391 diff --git a/gcc/ipa-icf.c b/gcc/ipa-icf2.c
392 similarity index 100%
393 rename from gcc/ipa-icf.c
394 rename to gcc/ipa-icf2.c
397 EXPECTED8 = '''\
398 gcc/ChangeLog:
400 * ipa-icf.c: Moved to...
401 * ipa-icf2.c: ...here.
405 PATCH9 = '''\
406 diff --git a/gcc/config/i386/sse.md b/gcc/config/i386/sse.md
407 index 2a260c1cfbd..7f03fc491c3 100644
408 --- a/gcc/config/i386/sse.md
409 +++ b/gcc/config/i386/sse.md
410 @@ -17611,6 +17611,23 @@ (define_insn "avx2_<code>v16qiv16hi2<mask_name>"
411 (set_attr "prefix" "maybe_evex")
412 (set_attr "mode" "OI")])
414 +(define_insn_and_split "*avx2_zero_extendv16qiv16hi2_1"
415 + [(set (match_operand:V32QI 0 "register_operand" "=v")
416 + (vec_select:V32QI
417 + (vec_concat:V64QI
418 + (match_operand:V32QI 1 "nonimmediate_operand" "vm")
419 + (match_operand:V32QI 2 "const0_operand" "C"))
420 + (match_parallel 3 "pmovzx_parallel"
421 + [(match_operand 4 "const_int_operand" "n")])))]
422 + "TARGET_AVX2"
423 + "#"
424 + "&& reload_completed"
425 + [(set (match_dup 0) (zero_extend:V16HI (match_dup 1)))]
427 + operands[0] = lowpart_subreg (V16HImode, operands[0], V32QImode);
428 + operands[1] = lowpart_subreg (V16QImode, operands[1], V32QImode);
431 (define_expand "<insn>v16qiv16hi2"
432 [(set (match_operand:V16HI 0 "register_operand")
433 (any_extend:V16HI
436 EXPECTED9 = '''\
437 gcc/ChangeLog:
439 * config/i386/sse.md (*avx2_zero_extendv16qiv16hi2_1):
443 class TestMklog(unittest.TestCase):
444 def test_macro_definition(self):
445 changelog = generate_changelog(PATCH1)
446 assert changelog == EXPECTED1
448 def test_changed_argument(self):
449 changelog = generate_changelog(PATCH2)
450 assert changelog == EXPECTED2
452 def test_enum_and_struct(self):
453 changelog = generate_changelog(PATCH3)
454 assert changelog == EXPECTED3
456 def test_no_function(self):
457 changelog = generate_changelog(PATCH3, True)
458 assert changelog == EXPECTED3B
460 def test_sorting(self):
461 changelog = generate_changelog(PATCH4)
462 assert changelog == EXPECTED4
464 def test_pr_bugzilla_download(self):
465 changelog = generate_changelog(PATCH5, fill_pr_titles=True)
466 assert changelog == EXPECTED5
468 def test_gty_in_struct(self):
469 changelog = generate_changelog(PATCH6, fill_pr_titles=True)
470 assert changelog == EXPECTED6
472 def test_dr_detection_in_test_case(self):
473 changelog = generate_changelog(PATCH7)
474 assert changelog == EXPECTED7
476 @unittest.skipIf(not unidiff_supports_renaming,
477 'Newer version of unidiff is needed (0.6.0+)')
478 def test_renaming(self):
479 changelog = generate_changelog(PATCH8)
480 assert changelog == EXPECTED8
482 def test_define_macro_parsing(self):
483 changelog = generate_changelog(PATCH9)
484 assert changelog == EXPECTED9