summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorWilliam S Fulton <wsf@fultondesigns.co.uk>2010-09-18 01:14:21 +0000
committerWilliam S Fulton <wsf@fultondesigns.co.uk>2010-09-18 01:14:21 +0000
commitb01277a19be53421d66f800c942e5b8663100a46 (patch)
tree147b073ef65649856b7e6da0e4dd84c592f6fd25
parent8b31a92f6168b1bb1e17ca64aebbe6e29c5fc24a (diff)
downloadswig-b01277a19be53421d66f800c942e5b8663100a46.tar.gz
Various inherited class warning/error line number fixes
git-svn-id: https://swig.svn.sourceforge.net/svnroot/swig/trunk@12223 626c5289-ae23-0410-ae9c-e8d60b6d4f22
-rw-r--r--CHANGES.current4
-rw-r--r--Examples/test-suite/errors/cpp_inherit.i47
-rw-r--r--Examples/test-suite/errors/expected.log24
-rwxr-xr-xExamples/test-suite/errors/make.sh1
-rw-r--r--Source/CParse/cscanner.c6
-rw-r--r--Source/CParse/parser.y40
-rw-r--r--Source/Modules/typepass.cxx17
7 files changed, 108 insertions, 31 deletions
diff --git a/CHANGES.current b/CHANGES.current
index ff5b40fb6..d98b99f1a 100644
--- a/CHANGES.current
+++ b/CHANGES.current
@@ -5,6 +5,10 @@ See the RELEASENOTES file for a summary of changes in each release.
Version 2.0.1 (in progress)
===========================
+2010-09-18: wsfulton
+ More file and line error/warning reporting fixes for various inherited
+ class problems.
+
2010-09-15: wsfulton
A much improved debugging of SWIG source experience is now available and
documented in the "Debugging SWIG" section in the Doc/Devel/internals.html
diff --git a/Examples/test-suite/errors/cpp_inherit.i b/Examples/test-suite/errors/cpp_inherit.i
new file mode 100644
index 000000000..fdc77d1d5
--- /dev/null
+++ b/Examples/test-suite/errors/cpp_inherit.i
@@ -0,0 +1,47 @@
+%module xxx
+
+%inline %{
+struct A5;
+int A6;
+template<typename T> struct A7
+{
+};
+template<typename T> struct A8
+{
+};
+
+struct A0
+:
+ public A1
+ ,
+ A2,
+ private A3
+ ,
+ private A4
+ ,
+ A5
+ ,
+ A6
+ ,
+ A7<int>
+ ,
+ protected A8<double>
+{
+};
+
+struct A1
+{
+};
+
+class B1 {};
+
+class B0 :
+ B1,
+ B2<int>
+{
+};
+
+struct Recursive : Recursive
+{
+};
+%}
diff --git a/Examples/test-suite/errors/expected.log b/Examples/test-suite/errors/expected.log
index 1fd592f04..7cbce4c30 100644
--- a/Examples/test-suite/errors/expected.log
+++ b/Examples/test-suite/errors/expected.log
@@ -207,6 +207,24 @@ cpp_extend_undefined.i:6: Warning 303: %extend defined for an undeclared class f
:::::::::::::::::::::::::::::::: cpp_inline_namespace.i :::::::::::::::::::::::::::::::::::
cpp_inline_namespace.i:4: Error: %inline directive inside a namespace is disallowed.
+:::::::::::::::::::::::::::::::: cpp_inherit.i :::::::::::::::::::::::::::::::::::
+cpp_inherit.i:18: Warning 309: private inheritance from base 'A3' (ignored).
+cpp_inherit.i:20: Warning 309: private inheritance from base 'A4' (ignored).
+cpp_inherit.i:28: Warning 309: protected inheritance from base 'A8< double >' (ignored).
+cpp_inherit.i:39: Warning 319: No access specifier given for base class 'B1' (ignored).
+cpp_inherit.i:40: Warning 319: No access specifier given for base class 'B2< int >' (ignored).
+cpp_inherit.i:15: Warning 401: Base class 'A1' undefined.
+cpp_inherit.i:33: Warning 401: 'A1' must be defined before it is used as a base class.
+cpp_inherit.i:17: Warning 401: Nothing known about base class 'A2'. Ignored.
+cpp_inherit.i:22: Warning 402: Base class 'A5' is incomplete.
+cpp_inherit.i:4: Warning 402: Only forward declaration 'A5' was found.
+cpp_inherit.i:24: Error: 'A6' is not a valid base class.
+cpp_inherit.i:5: Error: See definition of 'A6'.
+cpp_inherit.i:24: Warning 401: Nothing known about base class 'A6'. Ignored.
+cpp_inherit.i:26: Warning 401: Nothing known about base class 'A7< int >'. Ignored.
+cpp_inherit.i:26: Warning 401: Maybe you forgot to instantiate 'A7< int >' using %template.
+cpp_inherit.i:45: Warning 323: Recursive scope inheritance of 'Recursive'.
+
:::::::::::::::::::::::::::::::: cpp_missing_rtemplate.i :::::::::::::::::::::::::::::::::::
cpp_missing_rtemplate.i:4: Error: Syntax error in input(1).
@@ -224,7 +242,7 @@ cpp_nested.i:6: Warning 325: Nested class not currently supported (Bar ignored)
cpp_nested.i:12: Warning 325: Nested class not currently supported (Grok ignored)
:::::::::::::::::::::::::::::::: cpp_no_access.i :::::::::::::::::::::::::::::::::::
-cpp_no_access.i:3: Warning 319: No access specifier given for base class foo (ignored).
+cpp_no_access.i:3: Warning 319: No access specifier given for base class 'foo' (ignored).
:::::::::::::::::::::::::::::::: cpp_nobase.i :::::::::::::::::::::::::::::::::::
cpp_nobase.i:3: Warning 401: Nothing known about base class 'Bar'. Ignored.
@@ -236,8 +254,8 @@ cpp_nobase.i:6: Warning 401: Maybe you forgot to instantiate 'Bar< int >' using
:::::::::::::::::::::::::::::::: cpp_private_defvalue.i :::::::::::::::::::::::::::::::::::
:::::::::::::::::::::::::::::::: cpp_private_inherit.i :::::::::::::::::::::::::::::::::::
-cpp_private_inherit.i:6: Warning 309: private inheritance ignored.
-cpp_private_inherit.i:9: Warning 309: protected inheritance ignored.
+cpp_private_inherit.i:6: Warning 309: private inheritance from base 'Foo' (ignored).
+cpp_private_inherit.i:9: Warning 309: protected inheritance from base 'Foo' (ignored).
:::::::::::::::::::::::::::::::: cpp_template_argname.i :::::::::::::::::::::::::::::::::::
diff --git a/Examples/test-suite/errors/make.sh b/Examples/test-suite/errors/make.sh
index 0fb3e14a4..0a81254f4 100755
--- a/Examples/test-suite/errors/make.sh
+++ b/Examples/test-suite/errors/make.sh
@@ -64,6 +64,7 @@ cpp_bad_extern
cpp_extend_redefine
cpp_extend_undefined
cpp_inline_namespace
+cpp_inherit
cpp_missing_rtemplate
cpp_namespace_alias
cpp_namespace_aliasnot
diff --git a/Source/CParse/cscanner.c b/Source/CParse/cscanner.c
index f88841c09..7d848878c 100644
--- a/Source/CParse/cscanner.c
+++ b/Source/CParse/cscanner.c
@@ -791,7 +791,7 @@ int yylex(void) {
if (strcmp(yytext, "typename") == 0)
return (TYPENAME);
if (strcmp(yytext, "template") == 0) {
- yylval.ivalue = cparse_line;
+ yylval.intvalue = cparse_line;
return (TEMPLATE);
}
if (strcmp(yytext, "delete") == 0) {
@@ -833,7 +833,7 @@ int yylex(void) {
return (SIZEOF);
if (strcmp(yytext, "typedef") == 0) {
- yylval.ivalue = 0;
+ yylval.intvalue = 0;
return (TYPEDEF);
}
@@ -875,7 +875,7 @@ int yylex(void) {
if (strcmp(yytext, "%constant") == 0)
return (CONSTANT);
if (strcmp(yytext, "%typedef") == 0) {
- yylval.ivalue = 1;
+ yylval.intvalue = 1;
return (TYPEDEF);
}
if (strcmp(yytext, "%native") == 0)
diff --git a/Source/CParse/parser.y b/Source/CParse/parser.y
index 09ed9bcf2..d792021c6 100644
--- a/Source/CParse/parser.y
+++ b/Source/CParse/parser.y
@@ -1628,7 +1628,7 @@ static void tag_nodes(Node *n, const_String_or_char_ptr attrname, DOH *value) {
String *str;
Parm *p;
ParmList *pl;
- int ivalue;
+ int intvalue;
Node *node;
};
@@ -1639,7 +1639,7 @@ static void tag_nodes(Node *n, const_String_or_char_ptr attrname, DOH *value) {
%token <loc> INCLUDE IMPORT INSERT
%token <str> CHARCONST
%token <dtype> NUM_INT NUM_FLOAT NUM_UNSIGNED NUM_LONG NUM_ULONG NUM_LONGLONG NUM_ULONGLONG NUM_BOOL
-%token <ivalue> TYPEDEF
+%token <intvalue> TYPEDEF
%token <type> TYPE_INT TYPE_UNSIGNED TYPE_SHORT TYPE_LONG TYPE_FLOAT TYPE_DOUBLE TYPE_CHAR TYPE_WCHAR TYPE_VOID TYPE_SIGNED TYPE_BOOL TYPE_COMPLEX TYPE_TYPEDEF TYPE_RAW TYPE_NON_ISO_INT8 TYPE_NON_ISO_INT16 TYPE_NON_ISO_INT32 TYPE_NON_ISO_INT64
%token LPAREN RPAREN COMMA SEMI EXTERN INIT LBRACE RBRACE PERIOD
%token CONST_QUAL VOLATILE REGISTER STRUCT UNION EQUAL SIZEOF MODULE LBRACKET RBRACKET
@@ -1657,7 +1657,7 @@ static void tag_nodes(Node *n, const_String_or_char_ptr attrname, DOH *value) {
%token QUESTIONMARK
%token TYPES PARMS
%token NONID DSTAR DCNOT
-%token <ivalue> TEMPLATE
+%token <intvalue> TEMPLATE
%token <str> OPERATOR
%token <str> COPERATOR
%token PARSETYPE PARSEPARM PARSEPARMS
@@ -1728,7 +1728,7 @@ static void tag_nodes(Node *n, const_String_or_char_ptr attrname, DOH *value) {
%type <id> string stringnum ;
%type <tparms> template_parms;
%type <dtype> cpp_end cpp_vend;
-%type <ivalue> rename_namewarn;
+%type <intvalue> rename_namewarn;
%type <ptype> type_specifier primitive_type_list ;
%type <node> fname stringtype;
%type <node> featattr;
@@ -4540,7 +4540,8 @@ cpp_protection_decl : PUBLIC COLON {
------------------------------------------------------------ */
cpp_nested : storage_class cpptype idcolon inherit LBRACE {
- cparse_start_line = cparse_line; skip_balanced('{','}');
+ cparse_start_line = cparse_line;
+ skip_balanced('{','}');
$<str>$ = NewString(scanner_ccode); /* copied as initializers overwrite scanner_ccode */
} cpp_opt_declarators {
$$ = 0;
@@ -4565,7 +4566,8 @@ cpp_nested : storage_class cpptype idcolon inherit LBRACE {
------------------------------------------------------------ */
| storage_class cpptype inherit LBRACE {
- cparse_start_line = cparse_line; skip_balanced('{','}');
+ cparse_start_line = cparse_line;
+ skip_balanced('{','}');
$<str>$ = NewString(scanner_ccode); /* copied as initializers overwrite scanner_ccode */
} cpp_opt_declarators {
$$ = 0;
@@ -5883,28 +5885,34 @@ base_list : base_specifier {
}
;
-base_specifier : opt_virtual idcolon {
+base_specifier : opt_virtual {
+ $<intvalue>$ = cparse_line;
+ } idcolon {
$$ = NewHash();
Setfile($$,cparse_file);
- Setline($$,cparse_line);
- Setattr($$,"name",$2);
+ Setline($$,$<intvalue>2);
+ Setattr($$,"name",$3);
+ Setfile($3,cparse_file);
+ Setline($3,$<intvalue>2);
if (last_cpptype && (Strcmp(last_cpptype,"struct") != 0)) {
Setattr($$,"access","private");
- Swig_warning(WARN_PARSE_NO_ACCESS,cparse_file,cparse_line,
- "No access specifier given for base class %s (ignored).\n",$2);
+ Swig_warning(WARN_PARSE_NO_ACCESS, Getfile($$), Getline($$), "No access specifier given for base class '%s' (ignored).\n", SwigType_namestr($3));
} else {
Setattr($$,"access","public");
}
}
- | opt_virtual access_specifier opt_virtual idcolon {
+ | opt_virtual access_specifier {
+ $<intvalue>$ = cparse_line;
+ } opt_virtual idcolon {
$$ = NewHash();
Setfile($$,cparse_file);
- Setline($$,cparse_line);
- Setattr($$,"name",$4);
+ Setline($$,$<intvalue>3);
+ Setattr($$,"name",$5);
+ Setfile($5,cparse_file);
+ Setline($5,$<intvalue>3);
Setattr($$,"access",$2);
if (Strcmp($2,"public") != 0) {
- Swig_warning(WARN_PARSE_PRIVATE_INHERIT, cparse_file,
- cparse_line,"%s inheritance ignored.\n", $2);
+ Swig_warning(WARN_PARSE_PRIVATE_INHERIT, Getfile($$), Getline($$), "%s inheritance from base '%s' (ignored).\n", $2, SwigType_namestr($5));
}
}
;
diff --git a/Source/Modules/typepass.cxx b/Source/Modules/typepass.cxx
index e0e06d54e..438b66617 100644
--- a/Source/Modules/typepass.cxx
+++ b/Source/Modules/typepass.cxx
@@ -175,10 +175,10 @@ class TypePass:private Dispatcher {
}
}
if (Strcmp(nodeType(bcls), "classforward") != 0) {
- Swig_error(Getfile(cls), Getline(cls), "'%s' does not have a valid base class.\n", Getattr(cls, "name"));
- Swig_error(Getfile(bcls), Getline(bcls), "'%s' is not a valid base class.\n", SwigType_namestr(bname));
+ Swig_error(Getfile(bname), Getline(bname), "'%s' is not a valid base class.\n", SwigType_namestr(bname));
+ Swig_error(Getfile(bcls), Getline(bcls), "See definition of '%s'.\n", SwigType_namestr(bname));
} else {
- Swig_warning(WARN_TYPE_INCOMPLETE, Getfile(cls), Getline(cls), "Base class '%s' is incomplete.\n", SwigType_namestr(bname));
+ Swig_warning(WARN_TYPE_INCOMPLETE, Getfile(bname), Getline(bname), "Base class '%s' is incomplete.\n", SwigType_namestr(bname));
Swig_warning(WARN_TYPE_INCOMPLETE, Getfile(bcls), Getline(bcls), "Only forward declaration '%s' was found.\n", SwigType_namestr(bname));
clsforward = 1;
}
@@ -189,7 +189,7 @@ class TypePass:private Dispatcher {
ilist = alist = NewList();
Append(ilist, bcls);
} else {
- Swig_warning(WARN_TYPE_UNDEFINED_CLASS, Getfile(cls), Getline(cls), "Base class '%s' undefined.\n", SwigType_namestr(bname));
+ Swig_warning(WARN_TYPE_UNDEFINED_CLASS, Getfile(bname), Getline(bname), "Base class '%s' undefined.\n", SwigType_namestr(bname));
Swig_warning(WARN_TYPE_UNDEFINED_CLASS, Getfile(bcls), Getline(bcls), "'%s' must be defined before it is used as a base class.\n", SwigType_namestr(bname));
}
}
@@ -202,10 +202,9 @@ class TypePass:private Dispatcher {
if (!bcls) {
if (!clsforward) {
if (ispublic && !Getmeta(bname, "already_warned")) {
- Swig_warning(WARN_TYPE_UNDEFINED_CLASS, Getfile(cls), Getline(cls), "Nothing known about base class '%s'. Ignored.\n", SwigType_namestr(bname));
+ Swig_warning(WARN_TYPE_UNDEFINED_CLASS, Getfile(bname), Getline(bname), "Nothing known about base class '%s'. Ignored.\n", SwigType_namestr(bname));
if (Strchr(bname, '<')) {
- Swig_warning(WARN_TYPE_UNDEFINED_CLASS, Getfile(cls), Getline(cls), "Maybe you forgot to instantiate '%s' using %%template.\n",
- SwigType_namestr(bname));
+ Swig_warning(WARN_TYPE_UNDEFINED_CLASS, Getfile(bname), Getline(bname), "Maybe you forgot to instantiate '%s' using %%template.\n", SwigType_namestr(bname));
}
Setmeta(bname, "already_warned", "1");
}
@@ -259,7 +258,7 @@ class TypePass:private Dispatcher {
Delete(bsmart);
Delete(smart);
} else {
- Swig_error(Getfile(first), Getline(first), "Invalid type (%s) in 'smartptr' feature for class %s.\n", smartptr, clsname);
+ Swig_error(Getfile(first), Getline(first), "Invalid type (%s) in 'smartptr' feature for class %s.\n", SwigType_namestr(smartptr), SwigType_namestr(clsname));
}
}
if (!importmode) {
@@ -275,7 +274,7 @@ class TypePass:private Dispatcher {
Symtab *st = Getattr(cls, "symtab");
Symtab *bst = Getattr(bclass, "symtab");
if (st == bst) {
- Swig_warning(WARN_PARSE_REC_INHERITANCE, Getfile(cls), Getline(cls), "Recursive scope inheritance of '%s'.\n", Getattr(cls, "name"));
+ Swig_warning(WARN_PARSE_REC_INHERITANCE, Getfile(cls), Getline(cls), "Recursive scope inheritance of '%s'.\n", SwigType_namestr(Getattr(cls, "name")));
continue;
}
Symtab *s = Swig_symbol_current();