diff options
author | Jason Merrill <jason@redhat.com> | 2013-02-13 12:56:38 -0500 |
---|---|---|
committer | Jason Merrill <jason@gcc.gnu.org> | 2013-02-13 12:56:38 -0500 |
commit | 70fc7c6c3dff619348c917b619bf52ac78a6ced1 (patch) | |
tree | d79be11de6ade2402c07ed840b7ed9d02257a8c2 /gcc | |
parent | 58b922f813ea1b1eb87c0a6a050546ac27e78c1b (diff) | |
download | gcc-70fc7c6c3dff619348c917b619bf52ac78a6ced1.zip gcc-70fc7c6c3dff619348c917b619bf52ac78a6ced1.tar.gz gcc-70fc7c6c3dff619348c917b619bf52ac78a6ced1.tar.bz2 |
re PR c++/55879 ([C++11] nested constexpr Initialisation raises internal compiler error)
PR c++/55879
* semantics.c (cxx_bind_parameters_in_call): Undo DECL_BY_REFERENCE.
From-SVN: r196024
Diffstat (limited to 'gcc')
-rw-r--r-- | gcc/cp/ChangeLog | 3 | ||||
-rw-r--r-- | gcc/cp/semantics.c | 9 | ||||
-rw-r--r-- | gcc/testsuite/g++.dg/cpp0x/constexpr-invisiref1.C | 36 |
3 files changed, 48 insertions, 0 deletions
diff --git a/gcc/cp/ChangeLog b/gcc/cp/ChangeLog index 977d245..ec1e7f2 100644 --- a/gcc/cp/ChangeLog +++ b/gcc/cp/ChangeLog @@ -1,5 +1,8 @@ 2013-02-13 Jason Merrill <jason@redhat.com> + PR c++/55879 + * semantics.c (cxx_bind_parameters_in_call): Undo DECL_BY_REFERENCE. + PR c++/55993 * semantics.c (cxx_fold_indirect_ref): Handle empty bases at non-zero offsets, too. diff --git a/gcc/cp/semantics.c b/gcc/cp/semantics.c index 30c8c52..46c2e64 100644 --- a/gcc/cp/semantics.c +++ b/gcc/cp/semantics.c @@ -6520,6 +6520,15 @@ cxx_bind_parameters_in_call (const constexpr_call *old_call, tree t, if (i == 0 && DECL_CONSTRUCTOR_P (fun)) goto next; x = get_nth_callarg (t, i); + if (parms && DECL_BY_REFERENCE (parms)) + { + /* cp_genericize made this a reference for argument passing, but + we don't want to treat it like one for constexpr evaluation. */ + gcc_assert (TREE_CODE (type) == REFERENCE_TYPE); + gcc_assert (TREE_CODE (TREE_TYPE (x)) == REFERENCE_TYPE); + type = TREE_TYPE (type); + x = convert_from_reference (x); + } arg = cxx_eval_constant_expression (old_call, x, allow_non_constant, TREE_CODE (type) == REFERENCE_TYPE, non_constant_p, overflow_p); diff --git a/gcc/testsuite/g++.dg/cpp0x/constexpr-invisiref1.C b/gcc/testsuite/g++.dg/cpp0x/constexpr-invisiref1.C new file mode 100644 index 0000000..e0ede73 --- /dev/null +++ b/gcc/testsuite/g++.dg/cpp0x/constexpr-invisiref1.C @@ -0,0 +1,36 @@ +// PR c++/55879 +// { dg-do compile { target c++11 } } + +class CAddress +{ +public: + constexpr CAddress(unsigned long begin) : m_Begin(begin) {} + constexpr CAddress(const CAddress &other) : m_Begin(other.m_Begin) {} + +private: + unsigned long m_Begin; +}; + +extern "C" char _lnkDDRRAM; +/* internal compiler error on gcc 4.6.3 */ +const CAddress s_Memmap[2] +{ + {(unsigned long)&_lnkDDRRAM}, /* segmentation fault */ + {0x40000000}, +}; + +class CNested { +public: + constexpr CNested(const CAddress primary) + : m_PrimaryBlock(primary) {} + +private: + CAddress m_PrimaryBlock; +}; + +/* internal compiler error on gcc 4.7.2 */ +const CNested s_taskDescriptions[2] +{ + {{0x42000000}}, + {{0x43000000}}, +}; |