[Bug c++/53932] [10/11 Regression] C++ reference variable to member of anonymous union in global is error

2023-05-03 Thread jakub at gcc dot gnu.org via Gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=53932

--- Comment #16 from Jakub Jelinek  ---
Fixed for 11.4 as well.

[Bug c++/53932] [10/11 Regression] C++ reference variable to member of anonymous union in global is error

2023-05-02 Thread cvs-commit at gcc dot gnu.org via Gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=53932

--- Comment #15 from CVS Commits  ---
The releases/gcc-11 branch has been updated by Jakub Jelinek
:

https://gcc.gnu.org/g:bd34d694f4c060c92aee0e09edf4c7e1d83807e5

commit r11-10700-gbd34d694f4c060c92aee0e09edf4c7e1d83807e5
Author: Jakub Jelinek 
Date:   Thu Jan 19 23:27:34 2023 +0100

c++: Fix up handling of references to anon union members in initializers
[PR53932]

For anonymous union members we create artificial VAR_DECLs which
have DECL_VALUE_EXPR for the actual COMPONENT_REF.  That works
just fine inside of functions (including global dynamic constructors),
because during gimplification such VAR_DECLs are gimplified as
their DECL_VALUE_EXPR.  This is also done during regimplification.

But references to these artificial vars in DECL_INITIAL expressions
aren't ever replaced by the DECL_VALUE_EXPRs, so we end up either
with link failures like on the testcase below, or worse ICEs with
LTO.

The following patch fixes those during cp_fully_fold_init where we
already walk all the trees (!data->genericize means that
function rather than cp_fold_function).

2023-01-19  Jakub Jelinek  

PR c++/53932
* cp-gimplify.c (cp_fold_r): During cp_fully_fold_init replace
DECL_ANON_UNION_VAR_P VAR_DECLs with their corresponding
DECL_VALUE_EXPR.

* g++.dg/init/pr53932.C: New test.

(cherry picked from commit 9b9a989adc042b304572fd6d4ade46b47be6ccb8)

[Bug c++/53932] [10/11 Regression] C++ reference variable to member of anonymous union in global is error

2023-02-10 Thread jakub at gcc dot gnu.org via Gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=53932

Jakub Jelinek  changed:

   What|Removed |Added

Summary|[10/11/12 Regression] C++   |[10/11 Regression] C++
   |reference variable to   |reference variable to
   |member of anonymous union   |member of anonymous union
   |in global is error  |in global is error

--- Comment #14 from Jakub Jelinek  ---
Fixed for gcc 12.3 too.