CBMC
All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Modules Pages
cpp_typecheck_using.cpp
Go to the documentation of this file.
1/*******************************************************************\
2
3Module: C++ Language Type Checking
4
5Author: Daniel Kroening, kroening@cs.cmu.edu
6
7\*******************************************************************/
8
11
12#include "cpp_typecheck.h"
13
15
17{
18 // there are two forms of using clauses:
19 // a) using namespace SCOPE; ("using directive")
20 // b) using SCOPE::id; ("using declaration")
21
24
25 irep_idt base_name;
27 resolver.resolve_scope(cpp_using.name(), base_name, template_args);
28
29 bool qualified=cpp_using.name().is_qualified();
30
33
34 bool using_directive=cpp_using.get_namespace();
35
36 if(id_set.empty())
37 {
38 error().source_location=cpp_using.name().source_location();
39 error() << "using " << (using_directive ? "namespace" : "identifier")
40 << " '" << base_name << "' not found" << eom;
41 throw 0;
42 }
43
44 // go back to where we used to be
45 save_scope.restore();
46
47 for(cpp_scopest::id_sett::iterator
48 it=id_set.begin();
49 it!=id_set.end();
50 it++)
51 {
53 {
54 if((*it)->id_class==cpp_idt::id_classt::NAMESPACE)
56 static_cast<cpp_scopet &>(**it));
57 else
58 {
59 // we should likely complain about this
60 }
61 }
62 else // declaration
63 {
64 // we copy all 'normal' identifiers into the current scope
65 if((*it)->id_class!=cpp_idt::id_classt::TEMPLATE_PARAMETER &&
66 (*it)->id_class!=cpp_idt::id_classt::NAMESPACE)
68 }
69 }
70}
ait supplies three of the four components needed: an abstract interpreter (in this case handling func...
Definition ai.h:562
cpp_scopet & current_scope()
Definition cpp_scopes.h:32
cpp_idt & insert(const irep_idt &_base_name)
Definition cpp_scope.h:52
void add_using_scope(cpp_scopet &other)
Definition cpp_scope.h:109
id_sett lookup(const irep_idt &base_name_to_lookup, lookup_kindt kind)
Definition cpp_scope.h:32
void convert(cpp_linkage_spect &)
cpp_scopest cpp_scopes
dstringt has one field, an unsigned integer no which is an index into a static table of strings.
Definition dstring.h:38
source_locationt source_location
Definition message.h:239
mstreamt & error() const
Definition message.h:391
static eomt eom
Definition message.h:289
C++ Language Type Checking.