Browse Source

Improve interrogate diagnostics when encountering unknown types

rdb 10 years ago
parent
commit
909856c75d

File diff suppressed because it is too large
+ 700 - 683
dtool/src/cppparser/cppBison.cxx.prebuilt


+ 27 - 6
dtool/src/cppparser/cppBison.yxx

@@ -341,6 +341,7 @@ pop_struct() {
 %type <u.inst_ident> empty_instance_identifier
 %type <u.inst_ident> empty_instance_identifier
 %type <u.type> type
 %type <u.type> type
 %type <u.decl> type_decl
 %type <u.decl> type_decl
+%type <u.decl> var_type_decl
 %type <u.type> predefined_type
 %type <u.type> predefined_type
 %type <u.type> full_type
 %type <u.type> full_type
 %type <u.struct_type> anonymous_struct
 %type <u.struct_type> anonymous_struct
@@ -676,7 +677,7 @@ type_like_declaration:
         ;
         ;
 
 
 multiple_var_declaration:
 multiple_var_declaration:
-        storage_class type_decl
+        storage_class var_type_decl
 {
 {
   // We don't need to push/pop type, because we can't nest
   // We don't need to push/pop type, because we can't nest
   // multiple_var_declarations.
   // multiple_var_declarations.
@@ -691,11 +692,15 @@ multiple_var_declaration:
 {
 {
   pop_storage_class();
   pop_storage_class();
 }
 }
-        | storage_class KW_CONST type
+        | storage_class KW_CONST var_type_decl
 {
 {
   // We don't need to push/pop type, because we can't nest
   // We don't need to push/pop type, because we can't nest
   // multiple_var_declarations.
   // multiple_var_declarations.
-  current_type = $3;
+  if ($3->as_type_declaration()) {
+    current_type = $3->as_type_declaration()->_type;
+  } else {
+    current_type = $3->as_type();
+  }
   push_storage_class($1);
   push_storage_class($1);
 }
 }
         multiple_const_instance_identifiers
         multiple_const_instance_identifiers
@@ -750,7 +755,7 @@ multiple_const_instance_identifiers:
 
 
 
 
 typedef_declaration:
 typedef_declaration:
-        storage_class type_decl
+        storage_class var_type_decl
 {
 {
   // We don't need to push/pop type, because we can't nest
   // We don't need to push/pop type, because we can't nest
   // multiple_var_declarations.
   // multiple_var_declarations.
@@ -765,11 +770,15 @@ typedef_declaration:
 {
 {
   pop_storage_class();
   pop_storage_class();
 }
 }
-        | storage_class KW_CONST type
+        | storage_class KW_CONST var_type_decl
 {
 {
   // We don't need to push/pop type, because we can't nest
   // We don't need to push/pop type, because we can't nest
   // multiple_var_declarations.
   // multiple_var_declarations.
-  current_type = $3;
+  if ($3->as_type_declaration()) {
+    current_type = $3->as_type_declaration()->_type;
+  } else {
+    current_type = $3->as_type();
+  }
   push_storage_class($1);
   push_storage_class($1);
 }
 }
         typedef_const_instance_identifiers
         typedef_const_instance_identifiers
@@ -1892,6 +1901,18 @@ predefined_type:
 }
 }
         ;
         ;
 
 
+var_type_decl:
+        type_decl
+{
+  $$ = $1;
+}
+        | IDENTIFIER
+{
+  yyerror(string("unknown type '") + $1->get_fully_scoped_name() + "'", @1);
+
+  $$ = CPPType::new_type(new CPPSimpleType(CPPSimpleType::T_unknown));
+}
+
 full_type:
 full_type:
         type empty_instance_identifier
         type empty_instance_identifier
 {
 {

+ 1 - 1
dtool/src/cppparser/cppScope.cxx

@@ -1116,7 +1116,7 @@ handle_declaration(CPPDeclaration *decl, CPPScope *global_scope,
       // We don't do redefinitions of typedefs.  But we don't complain
       // We don't do redefinitions of typedefs.  But we don't complain
       // as long as this is actually a typedef to the previous definition.
       // as long as this is actually a typedef to the previous definition.
       if (other_type != def->_type &&
       if (other_type != def->_type &&
-          (other_td == NULL || other_td->_type != def->_type)) {
+          (other_td == NULL || !other_td->_type->is_equivalent(*def->_type))) {
 
 
         if (error_sink != NULL) {
         if (error_sink != NULL) {
           ostringstream errstr;
           ostringstream errstr;

Some files were not shown because too many files changed in this diff