public inbox for gcc-patches@gcc.gnu.org
 help / color / mirror / Atom feed
* [PATCH 0/3] Track lifetimes in constant evaluation [PR70331,...]
@ 2023-03-28 11:32 Nathaniel Shead
  2023-03-28 11:32 ` [PATCH 1/3] c++: Track lifetimes in constant evaluation [PR70331,PR96630,PR98675] Nathaniel Shead
                   ` (2 more replies)
  0 siblings, 3 replies; 6+ messages in thread
From: Nathaniel Shead @ 2023-03-28 11:32 UTC (permalink / raw)
  To: gcc-patches; +Cc: Nathaniel Shead

The first patch fixes PR70331, PR96630, and PR98675 regarding
constexpr evaluation not correctly diagnosing uses of dangling
references and pointers. The following two patches clean up and improve
some of the errors that are generated by this change, but aren't
strictly necessary.

This is my first change to the frontend, so any feedback is welcome. In
particular, I'm not sure if the way I went about the fix was correct:
for simplicity and efficiency's sake I added a new flag to
tree_decl_common, but this feels somewhat overkill for what is otherwise
a very locally useful property. 

Another option here would be to add a new lookup table to
constexpr_global_ctx which tracks what decls are in lifetime, but I
expect that to negatively impact performance. I haven't done any
benchmarks on this however.

Bootstrapped and regression tested on x86_64 linux.

---

Nathaniel Shead (3):
  c++: Track lifetimes in constant evaluation [PR70331,PR96630,PR98675]
  c++: Improve constexpr error for dangling local variables
  c++: Improve location information in constexpr evaluation

 gcc/cp/constexpr.cc                           | 149 ++++++++++++------
 gcc/cp/module.cc                              |   2 +
 gcc/cp/semantics.cc                           |   5 +-
 gcc/cp/typeck.cc                              |   5 +-
 gcc/print-tree.cc                             |   4 +
 gcc/testsuite/g++.dg/cpp0x/constexpr-48089.C  |  10 +-
 gcc/testsuite/g++.dg/cpp0x/constexpr-diag3.C  |   2 +-
 gcc/testsuite/g++.dg/cpp0x/constexpr-ice20.C  |   2 +-
 gcc/testsuite/g++.dg/cpp1y/constexpr-89481.C  |   3 +-
 .../g++.dg/cpp1y/constexpr-lifetime1.C        |  14 ++
 .../g++.dg/cpp1y/constexpr-lifetime2.C        |  20 +++
 .../g++.dg/cpp1y/constexpr-lifetime3.C        |  13 ++
 .../g++.dg/cpp1y/constexpr-lifetime4.C        |  11 ++
 .../g++.dg/cpp1y/constexpr-lifetime5.C        |  11 ++
 gcc/testsuite/g++.dg/cpp1y/constexpr-union5.C |   4 +-
 gcc/testsuite/g++.dg/cpp1y/pr68180.C          |   4 +-
 .../g++.dg/cpp1z/constexpr-lambda6.C          |   4 +-
 gcc/testsuite/g++.dg/cpp2a/bit-cast11.C       |  10 +-
 gcc/testsuite/g++.dg/cpp2a/bit-cast12.C       |  10 +-
 gcc/testsuite/g++.dg/cpp2a/bit-cast14.C       |  14 +-
 gcc/testsuite/g++.dg/cpp2a/constexpr-98122.C  |   4 +-
 .../g++.dg/cpp2a/constexpr-dynamic17.C        |   5 +-
 gcc/testsuite/g++.dg/cpp2a/constexpr-init1.C  |   5 +-
 gcc/testsuite/g++.dg/cpp2a/constexpr-new12.C  |   6 +-
 gcc/testsuite/g++.dg/cpp2a/constexpr-new3.C   |  10 +-
 gcc/testsuite/g++.dg/ext/constexpr-vla2.C     |   4 +-
 gcc/testsuite/g++.dg/ext/constexpr-vla3.C     |   4 +-
 gcc/testsuite/g++.dg/ubsan/pr63956.C          |   4 +-
 .../g++.dg/warn/Wreturn-local-addr-6.C        |   3 -
 gcc/tree-core.h                               |   5 +-
 gcc/tree.h                                    |   6 +
 .../25_algorithms/equal/constexpr_neg.cc      |   7 +-
 32 files changed, 247 insertions(+), 113 deletions(-)
 create mode 100644 gcc/testsuite/g++.dg/cpp1y/constexpr-lifetime1.C
 create mode 100644 gcc/testsuite/g++.dg/cpp1y/constexpr-lifetime2.C
 create mode 100644 gcc/testsuite/g++.dg/cpp1y/constexpr-lifetime3.C
 create mode 100644 gcc/testsuite/g++.dg/cpp1y/constexpr-lifetime4.C
 create mode 100644 gcc/testsuite/g++.dg/cpp1y/constexpr-lifetime5.C

-- 
2.34.1


^ permalink raw reply	[flat|nested] 6+ messages in thread

end of thread, other threads:[~2023-03-28 12:04 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2023-03-28 11:32 [PATCH 0/3] Track lifetimes in constant evaluation [PR70331,...] Nathaniel Shead
2023-03-28 11:32 ` [PATCH 1/3] c++: Track lifetimes in constant evaluation [PR70331,PR96630,PR98675] Nathaniel Shead
2023-03-28 11:50   ` [PATCH 1/3] c++: Track lifetimes in constant evaluation [PR70331, PR96630, PR98675] Jakub Jelinek
2023-03-28 12:04     ` Nathaniel Shead
2023-03-28 11:32 ` [PATCH 2/3] c++: Improve constexpr error for dangling local variables Nathaniel Shead
2023-03-28 11:32 ` [PATCH 3/3] c++: Improve location information in constexpr evaluation Nathaniel Shead

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).