summaryrefslogtreecommitdiff
path: root/clang/test/AST/ByteCode/functions.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'clang/test/AST/ByteCode/functions.cpp')
-rw-r--r--clang/test/AST/ByteCode/functions.cpp16
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 {