diff options
author | dim <dim@FreeBSD.org> | 2013-12-22 00:07:40 +0000 |
---|---|---|
committer | dim <dim@FreeBSD.org> | 2013-12-22 00:07:40 +0000 |
commit | 952eddef9aff85b1e92626e89baaf7a360e2ac85 (patch) | |
tree | df8df0b0067b381eab470a3b8f28d14a552a6340 /test/SemaCXX/predefined-expr.cpp | |
parent | ea266cad53e3d49771fa38103913d3ec7a166694 (diff) | |
download | FreeBSD-src-952eddef9aff85b1e92626e89baaf7a360e2ac85.zip FreeBSD-src-952eddef9aff85b1e92626e89baaf7a360e2ac85.tar.gz |
Vendor import of clang release_34 branch r197841 (effectively, 3.4 RC3):
https://llvm.org/svn/llvm-project/cfe/branches/release_34@197841
Diffstat (limited to 'test/SemaCXX/predefined-expr.cpp')
-rw-r--r-- | test/SemaCXX/predefined-expr.cpp | 103 |
1 files changed, 103 insertions, 0 deletions
diff --git a/test/SemaCXX/predefined-expr.cpp b/test/SemaCXX/predefined-expr.cpp new file mode 100644 index 0000000..257d44c --- /dev/null +++ b/test/SemaCXX/predefined-expr.cpp @@ -0,0 +1,103 @@ +// RUN: %clang_cc1 -std=c++1y -fblocks -fsyntax-only -verify %s +// PR16946 +// expected-no-diagnostics + +auto foo() { + static_assert(sizeof(__func__) == 4, "foo"); + static_assert(sizeof(__FUNCTION__) == 4, "foo"); + static_assert(sizeof(__PRETTY_FUNCTION__) == 11, "auto foo()"); + return 0; +} + +auto bar() -> decltype(42) { + static_assert(sizeof(__func__) == 4, "bar"); + static_assert(sizeof(__FUNCTION__) == 4, "bar"); + static_assert(sizeof(__PRETTY_FUNCTION__) == 10, "int bar()"); + return 0; +} + +// Within templates. +template <typename T> +int baz() { + static_assert(sizeof(__func__) == 4, "baz"); + static_assert(sizeof(__FUNCTION__) == 4, "baz"); + static_assert(sizeof(__PRETTY_FUNCTION__) == 20, "int baz() [T = int]"); + + []() { + static_assert(sizeof(__func__) == 11, "operator()"); + static_assert(sizeof(__FUNCTION__) == 11, "operator()"); + static_assert(sizeof(__PRETTY_FUNCTION__) == 50, + "auto baz()::<anonymous class>::operator()() const"); + return 0; + } + (); + + ^{ + // FIXME: This is obviously wrong. + static_assert(sizeof(__func__) == 1, "__baz_block_invoke"); + static_assert(sizeof(__FUNCTION__) == 1, "__baz_block_invoke"); + static_assert(sizeof(__PRETTY_FUNCTION__) == 1, "__baz_block_invoke"); + } + (); + + #pragma clang __debug captured + { + static_assert(sizeof(__func__) == 4, "baz"); + static_assert(sizeof(__FUNCTION__) == 4, "baz"); + static_assert(sizeof(__PRETTY_FUNCTION__) == 20, "int baz() [T = int]"); + } + + return 0; +} + +int main() { + static_assert(sizeof(__func__) == 5, "main"); + static_assert(sizeof(__FUNCTION__) == 5, "main"); + static_assert(sizeof(__PRETTY_FUNCTION__) == 11, "int main()"); + + []() { + static_assert(sizeof(__func__) == 11, "operator()"); + static_assert(sizeof(__FUNCTION__) == 11, "operator()"); + static_assert(sizeof(__PRETTY_FUNCTION__) == 51, + "auto main()::<anonymous class>::operator()() const"); + return 0; + } + (); + + ^{ + // FIXME: This is obviously wrong. + static_assert(sizeof(__func__) == 1, "__main_block_invoke"); + static_assert(sizeof(__FUNCTION__) == 1, "__main_block_invoke"); + static_assert(sizeof(__PRETTY_FUNCTION__) == 1, "__main_block_invoke"); + } + (); + + #pragma clang __debug captured + { + static_assert(sizeof(__func__) == 5, "main"); + static_assert(sizeof(__FUNCTION__) == 5, "main"); + static_assert(sizeof(__PRETTY_FUNCTION__) == 11, "int main()"); + + #pragma clang __debug captured + { + static_assert(sizeof(__func__) == 5, "main"); + static_assert(sizeof(__FUNCTION__) == 5, "main"); + static_assert(sizeof(__PRETTY_FUNCTION__) == 11, "int main()"); + } + } + + []() { + #pragma clang __debug captured + { + static_assert(sizeof(__func__) == 11, "operator()"); + static_assert(sizeof(__FUNCTION__) == 11, "operator()"); + static_assert(sizeof(__PRETTY_FUNCTION__) == 51, + "auto main()::<anonymous class>::operator()() const"); + } + } + (); + + baz<int>(); + + return 0; +} |