diff options
| author | Michael Kruse <llvm-project@meinersbur.de> | 2025-01-03 10:22:51 +0100 |
|---|---|---|
| committer | Michael Kruse <llvm-project@meinersbur.de> | 2025-01-03 10:22:51 +0100 |
| commit | 38500d63e14ce340236840f60d356cdefb56a52c (patch) | |
| tree | 17edbec446ce9b50d2f215a483b83afb293a635d /clang/test/AST/ByteCode/functions.cpp | |
| parent | 1a3d5daaef7a6a63448a497da3eff7fc9e23df26 (diff) | |
| parent | 27f30029741ecf023baece7b3dde1ff9011ffefc (diff) | |
Merge branch 'main' into users/meinersbur/flang_runtime_split-headersusers/meinersbur/flang_runtime_split-headers
Diffstat (limited to 'clang/test/AST/ByteCode/functions.cpp')
| -rw-r--r-- | clang/test/AST/ByteCode/functions.cpp | 16 |
1 files changed, 6 insertions, 10 deletions
diff --git a/clang/test/AST/ByteCode/functions.cpp b/clang/test/AST/ByteCode/functions.cpp index b00f59a8d8d4..10bea3a0d017 100644 --- a/clang/test/AST/ByteCode/functions.cpp +++ b/clang/test/AST/ByteCode/functions.cpp @@ -303,21 +303,17 @@ namespace ReturnLocalPtr { return &a; // both-warning {{address of stack memory}} } - /// GCC rejects the expression below, just like the new interpreter. The current interpreter - /// however accepts it and only warns about the function above returning an address to stack - /// memory. If we change the condition to 'p() != nullptr', it even succeeds. - static_assert(p() == nullptr, ""); // ref-error {{static assertion failed}} \ - // expected-error {{not an integral constant expression}} - - /// FIXME: The current interpreter emits diagnostics in the reference case below, but the - /// new one does not. + /// FIXME: Both interpreters should diagnose this. We're returning a pointer to a local + /// variable. + static_assert(p() == nullptr, ""); // both-error {{static assertion failed}} + constexpr const int &p2() { - int a = 12; // ref-note {{declared here}} + int a = 12; // both-note {{declared here}} return a; // both-warning {{reference to stack memory associated with local variable}} } static_assert(p2() == 12, ""); // both-error {{not an integral constant expression}} \ - // ref-note {{read of variable whose lifetime has ended}} + // both-note {{read of variable whose lifetime has ended}} } namespace VoidReturn { |
