1 //===-- main.cpp ------------------------------------------------*- C++ -*-===//
3 // The LLVM Compiler Infrastructure
5 // This file is distributed under the University of Illinois Open Source
6 // License. See LICENSE.TXT for details.
8 //===----------------------------------------------------------------------===//
15 typedef unsigned int my_uint_t;
16 int i; // Find the line number for anonymous namespace variable i.
18 int myanonfunc (int a)
24 variadic_sum (int arg_count...)
28 va_start(args, arg_count);
30 for (int i = 0; i < arg_count; i++)
31 sum += va_arg(args, int);
39 typedef unsigned int uint_t;
41 typedef unsigned int uint_t;
42 int j; // Find the line number for named namespace variable j.
48 float myfunc (float f)
57 typedef unsigned int uint_t;
62 using A::B::j; // using declaration
64 namespace Foo = A::B; // namespace alias
66 using Foo::myfunc; // using declaration
68 using namespace Foo; // using directive
85 void test_namespace_scopes() {
88 printf("ns1::value = %d\n", value); // Evaluate ns1::value
93 printf("ns2::value = %d\n", value); // Evaluate ns2::value
97 int Foo::myfunc(int a)
99 test_namespace_scopes();
101 ::my_uint_t anon_uint = 0;
102 A::uint_t a_uint = 1;
103 B::uint_t b_uint = 2;
104 Y::uint_t y_uint = 3;
107 printf("::i=%d\n", ::i);
108 printf("A::B::j=%d\n", A::B::j);
109 printf("variadic_sum=%d\n", variadic_sum(3, 1, 2, 3));
111 return myfunc2(3) + j + i + a + 2 + anon_uint + a_uint + b_uint + y_uint; // Set break point at this line.
115 main (int argc, char const *argv[])
117 test_lookup_at_global_scope();
118 test_lookup_at_file_scope();
119 A::test_lookup_at_ns_scope();
120 A::B::test_lookup_at_nested_ns_scope();
121 A::B::test_lookup_at_nested_ns_scope_after_using();
122 test_lookup_before_using_directive();
123 test_lookup_after_using_directive();
124 return Foo::myfunc(12);