Commit f63991a8 by Alexandre Petit-Bianco Committed by Alexandre Petit-Bianco

re GNATS gcj/48 (Compiler fails to catch constructor problem)

Mon Nov  1 01:32:48 1999  Alexandre Petit-Bianco  <apbianco@cygnus.com>

	* parse.y (resolve_qualified_expression_name): Prevent `this'
 	from being before the superclass constructor has been called.

(This fixes the net PR #48:
 http://sourceware.cygnus.com/ml/java-prs/1999-q3/msg00106.html)

From-SVN: r30317
parent e5de8c72
Mon Nov 1 01:32:48 1999 Alexandre Petit-Bianco <apbianco@cygnus.com>
* parse.y (resolve_qualified_expression_name): Prevent `this'
from being before the superclass constructor has been called.
Sat Oct 30 21:35:13 1999 Todd T. Fries <todd@lighthouse.fries.net> Sat Oct 30 21:35:13 1999 Todd T. Fries <todd@lighthouse.fries.net>
* check-init.c: Fix typo in comment. * check-init.c: Fix typo in comment.
......
...@@ -2238,7 +2238,7 @@ static const short yycheck[] = { 3, ...@@ -2238,7 +2238,7 @@ static const short yycheck[] = { 3,
#define YYPURE 1 #define YYPURE 1
/* -*-C-*- Note some compilers choke on comments on `#line' lines. */ /* -*-C-*- Note some compilers choke on comments on `#line' lines. */
#line 3 "/usr/cygnus/gnupro-98r1/share/bison.simple" #line 3 "/usr/share/misc/bison.simple"
/* Skeleton output parser for bison, /* Skeleton output parser for bison,
Copyright (C) 1984, 1989, 1990 Free Software Foundation, Inc. Copyright (C) 1984, 1989, 1990 Free Software Foundation, Inc.
...@@ -2255,7 +2255,7 @@ static const short yycheck[] = { 3, ...@@ -2255,7 +2255,7 @@ static const short yycheck[] = { 3,
You should have received a copy of the GNU General Public License You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software along with this program; if not, write to the Free Software
Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. */ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */
/* As a special exception, when this file is copied by Bison into a /* As a special exception, when this file is copied by Bison into a
Bison output file, you may use that output file without restriction. Bison output file, you may use that output file without restriction.
...@@ -2389,8 +2389,10 @@ int yydebug; /* nonzero means print parse trace */ ...@@ -2389,8 +2389,10 @@ int yydebug; /* nonzero means print parse trace */
/* Prevent warning if -Wstrict-prototypes. */ /* Prevent warning if -Wstrict-prototypes. */
#ifdef __GNUC__ #ifdef __GNUC__
#ifndef YYPARSE_PARAM
int yyparse (void); int yyparse (void);
#endif #endif
#endif
#if __GNUC__ > 1 /* GNU C and GNU C++ define this. */ #if __GNUC__ > 1 /* GNU C and GNU C++ define this. */
#define __yy_memcpy(TO,FROM,COUNT) __builtin_memcpy(TO,FROM,COUNT) #define __yy_memcpy(TO,FROM,COUNT) __builtin_memcpy(TO,FROM,COUNT)
...@@ -2431,7 +2433,7 @@ __yy_memcpy (char *to, char *from, int count) ...@@ -2431,7 +2433,7 @@ __yy_memcpy (char *to, char *from, int count)
#endif #endif
#endif #endif
#line 196 "/usr/cygnus/gnupro-98r1/share/bison.simple" #line 196 "/usr/share/misc/bison.simple"
/* The user can define YYPARSE_PARAM as the name of an argument to be passed /* The user can define YYPARSE_PARAM as the name of an argument to be passed
into yyparse. The argument should have type void *. into yyparse. The argument should have type void *.
...@@ -4718,7 +4720,7 @@ case 495: ...@@ -4718,7 +4720,7 @@ case 495:
break;} break;}
} }
/* the action file gets copied in in place of this dollarsign */ /* the action file gets copied in in place of this dollarsign */
#line 498 "/usr/cygnus/gnupro-98r1/share/bison.simple" #line 498 "/usr/share/misc/bison.simple"
yyvsp -= yylen; yyvsp -= yylen;
yyssp -= yylen; yyssp -= yylen;
...@@ -9310,6 +9312,12 @@ resolve_qualified_expression_name (wfl, found_decl, where_found, type_found) ...@@ -9310,6 +9312,12 @@ resolve_qualified_expression_name (wfl, found_decl, where_found, type_found)
(wfl, "Keyword `this' used outside allowed context"); (wfl, "Keyword `this' used outside allowed context");
return 1; return 1;
} }
if (ctxp->explicit_constructor_p)
{
parse_error_context (wfl, "Can't reference `this' before the "
"superclass constructor has been called");
return 1;
}
/* We have to generate code for intermediate acess */ /* We have to generate code for intermediate acess */
*where_found = decl = current_this; *where_found = decl = current_this;
*type_found = type = QUAL_DECL_TYPE (decl); *type_found = type = QUAL_DECL_TYPE (decl);
...@@ -11317,7 +11325,7 @@ complete_function_arguments (node) ...@@ -11317,7 +11325,7 @@ complete_function_arguments (node)
int flag = 0; int flag = 0;
tree cn; tree cn;
ctxp->explicit_constructor_p += (CALL_THIS_CONSTRUCTOR_P (node) ? 1 : 0); ctxp->explicit_constructor_p += (CALL_EXPLICIT_CONSTRUCTOR_P (node) ? 1 : 0);
for (cn = TREE_OPERAND (node, 1); cn; cn = TREE_CHAIN (cn)) for (cn = TREE_OPERAND (node, 1); cn; cn = TREE_CHAIN (cn))
{ {
tree wfl = TREE_VALUE (cn), parm, temp; tree wfl = TREE_VALUE (cn), parm, temp;
...@@ -11337,7 +11345,7 @@ complete_function_arguments (node) ...@@ -11337,7 +11345,7 @@ complete_function_arguments (node)
TREE_VALUE (cn) = parm; TREE_VALUE (cn) = parm;
} }
ctxp->explicit_constructor_p -= (CALL_THIS_CONSTRUCTOR_P (node) ? 1 : 0); ctxp->explicit_constructor_p -= (CALL_EXPLICIT_CONSTRUCTOR_P (node) ? 1 : 0);
return flag; return flag;
} }
......
...@@ -6725,6 +6725,12 @@ resolve_qualified_expression_name (wfl, found_decl, where_found, type_found) ...@@ -6725,6 +6725,12 @@ resolve_qualified_expression_name (wfl, found_decl, where_found, type_found)
(wfl, "Keyword `this' used outside allowed context"); (wfl, "Keyword `this' used outside allowed context");
return 1; return 1;
} }
if (ctxp->explicit_constructor_p)
{
parse_error_context (wfl, "Can't reference `this' before the "
"superclass constructor has been called");
return 1;
}
/* We have to generate code for intermediate acess */ /* We have to generate code for intermediate acess */
*where_found = decl = current_this; *where_found = decl = current_this;
*type_found = type = QUAL_DECL_TYPE (decl); *type_found = type = QUAL_DECL_TYPE (decl);
...@@ -8732,7 +8738,7 @@ complete_function_arguments (node) ...@@ -8732,7 +8738,7 @@ complete_function_arguments (node)
int flag = 0; int flag = 0;
tree cn; tree cn;
ctxp->explicit_constructor_p += (CALL_THIS_CONSTRUCTOR_P (node) ? 1 : 0); ctxp->explicit_constructor_p += (CALL_EXPLICIT_CONSTRUCTOR_P (node) ? 1 : 0);
for (cn = TREE_OPERAND (node, 1); cn; cn = TREE_CHAIN (cn)) for (cn = TREE_OPERAND (node, 1); cn; cn = TREE_CHAIN (cn))
{ {
tree wfl = TREE_VALUE (cn), parm, temp; tree wfl = TREE_VALUE (cn), parm, temp;
...@@ -8752,7 +8758,7 @@ complete_function_arguments (node) ...@@ -8752,7 +8758,7 @@ complete_function_arguments (node)
TREE_VALUE (cn) = parm; TREE_VALUE (cn) = parm;
} }
ctxp->explicit_constructor_p -= (CALL_THIS_CONSTRUCTOR_P (node) ? 1 : 0); ctxp->explicit_constructor_p -= (CALL_EXPLICIT_CONSTRUCTOR_P (node) ? 1 : 0);
return flag; return flag;
} }
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment