Marek Polacek aabebf76e9 c-family: Honor -Wno-init-self for cv-qual vars [PR102633]
Since r11-5188-g32934a4f45a721, we drop qualifiers during l-to-r
conversion by creating a NOP_EXPR.  For e.g.

  const int i = i;

that means that the DECL_INITIAL is '(int) i' and not 'i' anymore.
Consequently, we don't suppress_warning here:

711     case DECL_EXPR:
715       if (VAR_P (DECL_EXPR_DECL (*expr_p))
716           && !DECL_EXTERNAL (DECL_EXPR_DECL (*expr_p))
717           && !TREE_STATIC (DECL_EXPR_DECL (*expr_p))
718           && (DECL_INITIAL (DECL_EXPR_DECL (*expr_p)) == DECL_EXPR_DECL (*expr_p))
719           && !warn_init_self)
720         suppress_warning (DECL_EXPR_DECL (*expr_p), OPT_Winit_self);

because of the check on line 718 -- (int) i is not i.  So -Wno-init-self
doesn't disable the warning as it's supposed to.

The following patch fixes it by moving the suppress_warning call from
c_gimplify_expr to the front ends, at points where we haven't created
the NOP_EXPR yet.

	PR middle-end/102633

gcc/c-family/ChangeLog:

	* c-gimplify.cc (c_gimplify_expr) <case DECL_EXPR>: Don't call
	suppress_warning here.

gcc/c/ChangeLog:

	* c-parser.cc (c_parser_initializer): Add new tree parameter.  Use it.
	Call suppress_warning.
	(c_parser_declaration_or_fndef): Pass d down to c_parser_initializer.
	(c_parser_omp_declare_reduction): Pass omp_priv down to
	c_parser_initializer.

gcc/cp/ChangeLog:

	* decl.cc (cp_finish_decl): Call suppress_warning.

gcc/testsuite/ChangeLog:

	* c-c++-common/Winit-self1.c: New test.
	* c-c++-common/Winit-self2.c: New test.

(cherry picked from commit 04ce2400b3)
2023-02-10 16:19:36 +01:00
2022-11-21 00:21:29 +00:00
2023-01-17 00:21:46 +00:00
2022-09-20 00:22:15 +00:00
2022-12-22 00:20:54 +00:00
2023-01-05 00:20:48 +00:00
2022-12-14 00:22:41 +00:00
2023-01-05 00:20:48 +00:00
2021-06-24 16:51:40 +05:30
2021-12-21 09:10:57 +01:00
2022-03-29 17:43:32 +08:00

This directory contains the GNU Compiler Collection (GCC).

The GNU Compiler Collection is free software.  See the files whose
names start with COPYING for copying permission.  The manuals, and
some of the runtime libraries, are under different terms; see the
individual source files for details.

The directory INSTALL contains copies of the installation information
as HTML and plain text.  The source of this information is
gcc/doc/install.texi.  The installation information includes details
of what is included in the GCC sources and what files GCC installs.

See the file gcc/doc/gcc.texi (together with other files that it
includes) for usage and porting information.  An online readable
version of the manual is in the files gcc/doc/gcc.info*.

See http://gcc.gnu.org/bugs/ for how to report bugs usefully.

Copyright years on GCC source files may be listed using range
notation, e.g., 1987-2012, indicating that every year in the range,
inclusive, is a copyrightable year that could otherwise be listed
individually.
Description
No description provided
Readme 1.5 GiB
Languages
C++ 30.7%
C 30%
Ada 14.5%
D 6.1%
Go 5.7%
Other 12.5%