This is the mail archive of the gcc-patches@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

[patch] PR c++/18368: backport to 3.4 branch


Title says it all.

Bootstrapped and regtested on i686-pc-linux-gnu.
Ok for the 3.4 branch?

Regards,
Volker


2005-09-01  Volker Reichelt  <reichelt@igpm.rwth-aachen.de>

	Backport:

	2004-11-27  Mark Mitchell  <mark@codesourcery.com>
	PR c++/18368
	* parser.c (cp_parser_check_for_definition_in_return_type): Take
	the defined type as a parameter, and inform the user about the
	possibility of a missing semicolon.
	(cp_parser_explicit_instantiation): Adjust call to
	cp_parser_check_for_definition_in_return_type.
	(cp_parser_init_declarator): Likewise.
	(cp_parser_member_declaration): Likewise.

===================================================================
--- gcc/gcc/cp/parser.c	31 Aug 2005 10:16:00 -0000	1.157.2.59
+++ gcc/gcc/cp/parser.c	1 Sep 2005 11:06:47 -0000
@@ -1719,7 +1719,7 @@ static bool cp_parser_simulate_error
 static void cp_parser_check_type_definition
   (cp_parser *);
 static void cp_parser_check_for_definition_in_return_type
-  (tree, int);
+  (tree, tree);
 static void cp_parser_check_for_invalid_template_id
   (cp_parser *, tree);
 static bool cp_parser_non_integral_constant_expression
@@ -1851,14 +1851,13 @@ cp_parser_check_type_definition (cp_pars
     error ("%s", parser->type_definition_forbidden_message);
 }
 
-/* This function is called when a declaration is parsed.  If
-   DECLARATOR is a function declarator and DECLARES_CLASS_OR_ENUM
-   indicates that a type was defined in the decl-specifiers for DECL,
-   then an error is issued.  */
+/* This function is called when the DECLARATOR is processed.  The TYPE
+   was a type defined in the decl-specifiers.  If it is invalid to
+   define a type in the decl-specifiers for DECLARATOR, an error is
+   issued.  */
 
 static void
-cp_parser_check_for_definition_in_return_type (tree declarator, 
-					       int declares_class_or_enum)
+cp_parser_check_for_definition_in_return_type (tree declarator, tree type)
 {
   /* [dcl.fct] forbids type definitions in return types.
      Unfortunately, it's not easy to know whether or not we are
@@ -1868,9 +1867,12 @@ cp_parser_check_for_definition_in_return
 	     || TREE_CODE (declarator) == ADDR_EXPR))
     declarator = TREE_OPERAND (declarator, 0);
   if (declarator
-      && TREE_CODE (declarator) == CALL_EXPR 
-      && declares_class_or_enum & 2)
-    error ("new types may not be defined in a return type");
+      && TREE_CODE (declarator) == CALL_EXPR)
+    {
+      error ("new types may not be defined in a return type");
+      inform ("(perhaps a semicolon is missing after the definition of `%T')",
+	      type);
+    }
 }
 
 /* A type-specifier (TYPE) has been parsed which cannot be followed by
@@ -8628,8 +8630,9 @@ cp_parser_explicit_instantiation (cp_par
 				/*ctor_dtor_or_conv_p=*/NULL,
 				/*parenthesized_p=*/NULL,
 				/*member_p=*/false);
-      cp_parser_check_for_definition_in_return_type (declarator, 
-						     declares_class_or_enum);
+      if (declares_class_or_enum & 2)
+	cp_parser_check_for_definition_in_return_type
+	  (declarator, TREE_VALUE (decl_specifiers));
       if (declarator != error_mark_node)
 	{
 	  decl = grokdeclarator (declarator, decl_specifiers, 
@@ -10003,8 +10006,9 @@ cp_parser_init_declarator (cp_parser* pa
   if (declarator == error_mark_node)
     return error_mark_node;
 
-  cp_parser_check_for_definition_in_return_type (declarator,
-						 declares_class_or_enum);
+  if (declares_class_or_enum & 2)
+    cp_parser_check_for_definition_in_return_type
+      (declarator, TREE_VALUE (decl_specifiers));
 
   /* Figure out what scope the entity declared by the DECLARATOR is
      located in.  `grokdeclarator' sometimes changes the scope, so
@@ -12706,8 +12710,9 @@ cp_parser_member_declaration (cp_parser*
 		  return;
 		}
 
-	      cp_parser_check_for_definition_in_return_type 
-		(declarator, declares_class_or_enum);
+	      if (declares_class_or_enum & 2)
+		cp_parser_check_for_definition_in_return_type
+		  (declarator, TREE_VALUE (decl_specifiers));
 
 	      /* Look for an asm-specification.  */
 	      asm_specification = cp_parser_asm_specification_opt (parser);
===================================================================



Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]