1 //===-- ns3.cpp ------------------------------------------------*- C++ -*-===//
2 //
3 // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
4 // See https://llvm.org/LICENSE.txt for license information.
5 // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
6 //
7 //===----------------------------------------------------------------------===//
8 
9 #include "ns.h"
10 extern int func();
11 
12 // Note: the following function must be before the using.
13 void test_lookup_before_using_directive()
14 {
15   // BP_before_using_directive
16   std::printf("before using directive: func() = %d\n", func()); // eval func(), exp: 1
17 }
18 using namespace A;
19 void test_lookup_after_using_directive()
20 {
21   // BP_after_using_directive
22   //printf("func() = %d\n", func()); // eval func(), exp: error, amiguous
23   std::printf("after using directive: func2() = %d\n", func2()); // eval func2(), exp: 3
24   std::printf("after using directive: ::func() = %d\n", ::func()); // eval ::func(), exp: 1
25   std::printf("after using directive: B::func() = %d\n", B::func()); // eval B::func(), exp: 4
26 }
27