inner declared types are treated as forward declarations - consistency now between innner/nested unions/structs and classes - only relevant to C++

git-svn-id: https://swig.svn.sourceforge.net/svnroot/swig/trunk@11730 626c5289-ae23-0410-ae9c-e8d60b6d4f22
This commit is contained in:
William S Fulton 2009-11-08 20:45:48 +00:00
commit 9b318c45bc
4 changed files with 27 additions and 21 deletions

View file

@ -1,6 +1,17 @@
Version 1.3.41 (in progress)
============================
2009-11-08: wsfulton
Fix inconsistency for inner structs/unions/classes. Uncompileable code was being
generated when inner struct and union declarations were used as types within
the inner struct. The inner struct/union is now treated as a forward declaration making the
behaviour the same as an inner class. (C++ code), eg:
struct Outer {
struct InnerStruct { int x; };
InnerStruct* getInnerStruct();
};
2009-11-08: wsfulton
Ignored nested class/struct warnings now display the name of the ignored class/struct.

View file

@ -45,6 +45,11 @@ struct Outer {
int x;
double y;
} InnerUnion2Name;
// bug #909387 - inner declared types are treated as forward declarations
InnerStruct1* getInnerStruct1() { return 0; }
InnerClass1* getInnerClass1() { return 0; }
InnerUnion1* getInnerUnion1() { return 0; }
};
%}

View file

@ -10,13 +10,3 @@ int a;
%}
// bug #909387
%inline %{
struct foo {
struct happy; // no warning
struct sad { int x; }; // warning
happy *good(); // produces good code
sad *bad(); // produces bad code
};
%}

View file

@ -4396,17 +4396,16 @@ cpp_nested : storage_class cpptype ID LBRACE { cparse_start_line = cparse_line
add_nested(n);
} else {
Swig_warning(WARN_PARSE_NESTED_CLASS, cparse_file, cparse_line, "Nested %s not currently supported (%s ignored).\n", $2, $3);
if (strcmp($2, "class") == 0) {
/* For now, just treat the nested class as a forward
* declaration (SF bug #909387). */
$$ = new_node("classforward");
Setfile($$,cparse_file);
Setline($$,cparse_line);
Setattr($$,"kind",$2);
Setattr($$,"name",$3);
Setattr($$,"sym:weak", "1");
add_symbols($$);
}
/* For now, just treat the nested class/struct/union as a forward
* declaration (SF bug #909387). */
$$ = new_node("classforward");
Setfile($$,cparse_file);
Setline($$,cparse_line);
Setattr($$,"kind",$2);
Setattr($$,"name",$3);
Setattr($$,"sym:weak", "1");
add_symbols($$);
}
}
}
@ -4446,6 +4445,7 @@ cpp_nested : storage_class cpptype ID LBRACE { cparse_start_line = cparse_line
*****/
| storage_class cpptype idcolon COLON base_list LBRACE { cparse_start_line = cparse_line; skip_balanced('{','}');
} SEMI {
Printf(stdout, "cpp_nested (c)\n");
$$ = 0;
if (cplus_mode == CPLUS_PUBLIC) {
Swig_warning(WARN_PARSE_NESTED_CLASS, cparse_file, cparse_line,"Nested %s not currently supported (%s ignored)\n", $2, $3);