blob: 9f3583b47e27a2b2899456cb36ab26998b988f1b [file] [log] [blame]
Chris Lattner30fdc8d2010-06-08 16:52:24 +00001//===-- main.cpp ------------------------------------------------*- C++ -*-===//
2//
3// The LLVM Compiler Infrastructure
4//
5// This file is distributed under the University of Illinois Open Source
6// License. See LICENSE.TXT for details.
7//
8//===----------------------------------------------------------------------===//
9
10namespace {
Johnny Chen7826b0a2010-11-16 18:11:55 +000011 typedef unsigned int my_uint_t;
Johnny Chen3d57ee72010-11-11 23:29:54 +000012 int i; // Find the line number for anonymous namespace variable i.
Matt Kopec201284a2013-05-13 22:00:32 +000013
14 int myanonfunc (int a)
15 {
16 return a + a;
17 }
Chris Lattner30fdc8d2010-06-08 16:52:24 +000018}
19
20namespace A {
21 typedef unsigned int uint_t;
22 namespace B {
23 typedef unsigned int uint_t;
Johnny Chen3d57ee72010-11-11 23:29:54 +000024 int j; // Find the line number for named namespace variable j.
Chris Lattner30fdc8d2010-06-08 16:52:24 +000025 int myfunc (int a);
26 int myfunc2(int a)
27 {
28 return a + 2;
29 }
30 float myfunc (float f)
31 {
32 return f - 2.0;
33 }
34 }
35}
36
37namespace Y
38{
39 typedef unsigned int uint_t;
40 using A::B::j;
41 int foo;
42}
43
44using A::B::j; // using declaration
45
46namespace Foo = A::B; // namespace alias
47
48using Foo::myfunc; // using declaration
49
50using namespace Foo; // using directive
51
52namespace A {
53 namespace B {
54 using namespace Y;
55 int k;
56 }
57}
58
Johnny Chen342927c2011-07-28 20:46:14 +000059#include <stdio.h>
Chris Lattner30fdc8d2010-06-08 16:52:24 +000060int Foo::myfunc(int a)
61{
Johnny Chen7826b0a2010-11-16 18:11:55 +000062 ::my_uint_t anon_uint = 0;
Chris Lattner30fdc8d2010-06-08 16:52:24 +000063 A::uint_t a_uint = 1;
64 B::uint_t b_uint = 2;
65 Y::uint_t y_uint = 3;
66 i = 3;
67 j = 4;
Johnny Chen342927c2011-07-28 20:46:14 +000068 printf("::i=%d\n", ::i);
69 printf("A::B::j=%d\n", A::B::j);
Matt Kopec201284a2013-05-13 22:00:32 +000070 myanonfunc(3);
Johnny Chen3d57ee72010-11-11 23:29:54 +000071 return myfunc2(3) + j + i + a + 2 + anon_uint + a_uint + b_uint + y_uint; // Set break point at this line.
Chris Lattner30fdc8d2010-06-08 16:52:24 +000072}
73
74int
75main (int argc, char const *argv[])
76{
77 return Foo::myfunc(12);
78}