minix/external/bsd/llvm/dist/clang/test/SemaCXX/predefined-expr.cpp
Lionel Sambuc f4a2713ac8 Importing netbsd clang -- pristine
Change-Id: Ia40e9ffdf29b5dab2f122f673ff6802a58bc690f
2014-07-28 17:05:57 +02:00

103 lines
2.9 KiB
C++

// 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;
}