| Chris Lattner | 30fdc8d | 2010-06-08 16:52:24 +0000 | [diff] [blame] | 1 | //===-- 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 | |
| 10 | namespace { |
| Johnny Chen | 7826b0a | 2010-11-16 18:11:55 +0000 | [diff] [blame] | 11 | typedef unsigned int my_uint_t; |
| Johnny Chen | 3d57ee7 | 2010-11-11 23:29:54 +0000 | [diff] [blame] | 12 | int i; // Find the line number for anonymous namespace variable i. |
| Matt Kopec | 201284a | 2013-05-13 22:00:32 +0000 | [diff] [blame] | 13 | |
| 14 | int myanonfunc (int a) |
| 15 | { |
| 16 | return a + a; |
| 17 | } |
| Chris Lattner | 30fdc8d | 2010-06-08 16:52:24 +0000 | [diff] [blame] | 18 | } |
| 19 | |
| 20 | namespace A { |
| 21 | typedef unsigned int uint_t; |
| 22 | namespace B { |
| 23 | typedef unsigned int uint_t; |
| Johnny Chen | 3d57ee7 | 2010-11-11 23:29:54 +0000 | [diff] [blame] | 24 | int j; // Find the line number for named namespace variable j. |
| Chris Lattner | 30fdc8d | 2010-06-08 16:52:24 +0000 | [diff] [blame] | 25 | 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 | |
| 37 | namespace Y |
| 38 | { |
| 39 | typedef unsigned int uint_t; |
| 40 | using A::B::j; |
| 41 | int foo; |
| 42 | } |
| 43 | |
| 44 | using A::B::j; // using declaration |
| 45 | |
| 46 | namespace Foo = A::B; // namespace alias |
| 47 | |
| 48 | using Foo::myfunc; // using declaration |
| 49 | |
| 50 | using namespace Foo; // using directive |
| 51 | |
| 52 | namespace A { |
| 53 | namespace B { |
| 54 | using namespace Y; |
| 55 | int k; |
| 56 | } |
| 57 | } |
| 58 | |
| Johnny Chen | 342927c | 2011-07-28 20:46:14 +0000 | [diff] [blame] | 59 | #include <stdio.h> |
| Chris Lattner | 30fdc8d | 2010-06-08 16:52:24 +0000 | [diff] [blame] | 60 | int Foo::myfunc(int a) |
| 61 | { |
| Johnny Chen | 7826b0a | 2010-11-16 18:11:55 +0000 | [diff] [blame] | 62 | ::my_uint_t anon_uint = 0; |
| Chris Lattner | 30fdc8d | 2010-06-08 16:52:24 +0000 | [diff] [blame] | 63 | 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 Chen | 342927c | 2011-07-28 20:46:14 +0000 | [diff] [blame] | 68 | printf("::i=%d\n", ::i); |
| 69 | printf("A::B::j=%d\n", A::B::j); |
| Matt Kopec | 201284a | 2013-05-13 22:00:32 +0000 | [diff] [blame] | 70 | myanonfunc(3); |
| Johnny Chen | 3d57ee7 | 2010-11-11 23:29:54 +0000 | [diff] [blame] | 71 | return myfunc2(3) + j + i + a + 2 + anon_uint + a_uint + b_uint + y_uint; // Set break point at this line. |
| Chris Lattner | 30fdc8d | 2010-06-08 16:52:24 +0000 | [diff] [blame] | 72 | } |
| 73 | |
| 74 | int |
| 75 | main (int argc, char const *argv[]) |
| 76 | { |
| 77 | return Foo::myfunc(12); |
| 78 | } |