diff --git a/parse.y b/parse.y index 42010d232..c74b22672 100644 --- a/parse.y +++ b/parse.y @@ -1589,6 +1589,7 @@ package_item /* IEEE1800-2005 A.1.10 */ | function_declaration | task_declaration | data_declaration + | class_declaration ; package_item_list diff --git a/pform.cc b/pform.cc index 68e9a072d..62adb07bc 100644 --- a/pform.cc +++ b/pform.cc @@ -328,9 +328,20 @@ PClass* pform_push_class_scope(const struct vlltype&loc, perm_string name) assert(!pform_cur_generate); + /* If no scope was found then this is being defined in the + * compilation unit scope. */ + if (scopex == 0) { + cerr << class_scope->get_fileline() << ": sorry: class " + "declarations in the compilation unit scope are not yet " + "supported." << endl; + error_count += 1; + lexical_scope = class_scope; + return class_scope; + } + if (scopex->classes.find(name) != scopex->classes.end()) { cerr << class_scope->get_fileline() << ": error: duplicate " - " definition for class '" << name << "' in '" + "definition for class '" << name << "' in '" << scopex->pscope_name() << "'." << endl; error_count += 1; }