[PATCH] Minor parser change, method decl marking for inlining.

Alexandre Petit-Bianco apbianco@cygnus.com
Fri Oct 29 14:45:00 GMT 1999


I committed the following patch to enhance the error message produced
when certain type of constructors are invoked improperly and the mark
static, final and private method inlineable. Note that this patch
isn't sufficient to trigger Java method inlining. An other patch in
under investigation.

./A

Fri Oct 29 14:35:18 1999  Alexandre Petit-Bianco  <apbianco@cygnus.com>

	* class.c (add_method_1): Set DECL_INLINE to 1 for private, static
 	and final method.

Fri Oct 29 14:23:32 1999  Alexandre Petit-Bianco  <apbianco@cygnus.com>

	* parse.y (expression_statement:): Call function to report
 	improper invocation of a constructor.
	(parse_ctor_invocation_error): New function.

Index: class.c
===================================================================
RCS file: /cvs/gcc/egcs/gcc/java/class.c,v
retrieving revision 1.45
retrieving revision 1.46
diff -u -p -r1.45 -r1.46
--- class.c	1999/09/11 22:22:57	1.45
+++ class.c	1999/10/29 21:32:27	1.46
@@ -427,10 +427,13 @@ add_method_1 (handle_class, access_flags
 
   if (access_flags & ACC_PUBLIC) METHOD_PUBLIC (fndecl) = 1;
   if (access_flags & ACC_PROTECTED) METHOD_PROTECTED (fndecl) = 1;
-  if (access_flags & ACC_PRIVATE) METHOD_PRIVATE (fndecl) = 1;
+  if (access_flags & ACC_PRIVATE)
+    METHOD_PRIVATE (fndecl) = DECL_INLINE (fndecl) = 1;
   if (access_flags & ACC_NATIVE) METHOD_NATIVE (fndecl) = 1;
-  if (access_flags & ACC_STATIC) METHOD_STATIC (fndecl) = 1;
-  if (access_flags & ACC_FINAL) METHOD_FINAL (fndecl) = 1;
+  if (access_flags & ACC_STATIC) 
+    METHOD_STATIC (fndecl) = DECL_INLINE (fndecl) = 1;
+  if (access_flags & ACC_FINAL) 
+    METHOD_FINAL (fndecl) = DECL_INLINE (fndecl) = 1;
   if (access_flags & ACC_SYNCHRONIZED) METHOD_SYNCHRONIZED (fndecl) = 1;
   if (access_flags & ACC_ABSTRACT) METHOD_ABSTRACT (fndecl) = 1;
   if (access_flags & ACC_TRANSIENT) METHOD_TRANSIENT (fndecl) = 1;

Index: parse.y
===================================================================
RCS file: /cvs/gcc/egcs/gcc/java/parse.y,v
retrieving revision 1.114
diff -u -p -r1.114 parse.y
--- parse.y	1999/10/22 06:06:47	1.114
+++ parse.y	1999/10/29 21:21:48
@@ -93,6 +93,7 @@ static tree method_declarator PROTO ((tr
 static void parse_warning_context PVPROTO ((tree cl, const char *msg, ...))
   ATTRIBUTE_PRINTF_2;
 static void issue_warning_error_from_context PROTO ((tree, const char *msg, va_list));
+static void parse_ctor_invocation_error PROTO ((void));
 static tree parse_jdk1_1_error PROTO ((const char *));
 static void complete_class_report_errors PROTO ((jdep *));
 static int process_imports PROTO ((void));
@@ -1343,16 +1344,14 @@ expression_statement:
 		{yyerror ("')' expected"); RECOVER;}
 |       this_or_super OP_TK CP_TK error
 		{
-		  yyerror ("Constructor invocation must be first "
-			   "thing in a constructor"); 
+		  parse_ctor_invocation_error ();
 		  RECOVER;
 		}
 |       this_or_super OP_TK argument_list error
 		{yyerror ("')' expected"); RECOVER;}
 |       this_or_super OP_TK argument_list CP_TK error
 		{
-		  yyerror ("Constructor invocation must be first "
-			   "thing in a constructor"); 
+		  parse_ctor_invocation_error ();
 		  RECOVER;
 		}
 |	name DOT_TK SUPER_TK error
@@ -2434,7 +2433,17 @@ java_pop_parser_context (generate)
     free (toFree);
 }
 
-/* Reporting JDK1.1 features not implemented */
+/* Reporting an constructor invocation error.  */
+static void
+parse_ctor_invocation_error ()
+{
+  if (DECL_CONSTRUCTOR_P (current_function_decl))
+    yyerror ("Constructor invocation must be first thing in a constructor"); 
+  else
+    yyerror ("Only constructors can invoke constructors");
+}
+
+/* Reporting JDK1.1 features not implemented.  */
 
 static tree
 parse_jdk1_1_error (msg)


More information about the Gcc-patches mailing list