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 c++] Fix some diagnostics problem


Hi,

Some messages that would be passed to error or warning function can't be extracted to translate. This patch is to wrap them into G_() for exgettext to extract.
It is tested on i686-pc-linux-gnu with enabled c++ and run "make gcc.pot" to check the extracted strings.


Ok for trunk?

Thanks
Pearly
2010-02-08  Shujing Zhao  <pearly.zhao@oracle.com>

	* Make-lang.in (cp/cvt.o, cp/parser.o, cp/search.o): Depend on intl.h.
	* cvt.c (warn_ref_binding): Wrap the messages into G_() for easy
	translation.
	* parser.c (cp_parser_postfix_expression, cp_parser_new_type_id)
	(cp_parser_cast_expression, cp_parser_condition, cp_parser_decltype)
	(cp_parser_parameter_declaration)
	(cp_parser_exception_specification_opt)
	(cp_parser_exception_declaration): Likewise.
	* pt.c (check_default_tmpl_args): Likewise.
	* search.c (lookup_field_r): Likewise.

Index: Make-lang.in
===================================================================
--- Make-lang.in	(revision 156592)
+++ Make-lang.in	(working copy)
@@ -279,8 +279,9 @@ cp/init.o: cp/init.c $(CXX_TREE_H) $(TM_
 cp/method.o: cp/method.c $(CXX_TREE_H) $(TM_H) toplev.h $(RTL_H) $(EXPR_H) \
   $(TM_P_H) $(TARGET_H) $(DIAGNOSTIC_H) gt-cp-method.h $(GIMPLE_H)
 cp/cvt.o: cp/cvt.c $(CXX_TREE_H) $(TM_H) cp/decl.h $(FLAGS_H) toplev.h \
-  convert.h $(TARGET_H)
-cp/search.o: cp/search.c $(CXX_TREE_H) $(TM_H) $(FLAGS_H) toplev.h $(RTL_H)
+  convert.h $(TARGET_H) intl.h
+cp/search.o: cp/search.c $(CXX_TREE_H) $(TM_H) $(FLAGS_H) toplev.h $(RTL_H) \
+  intl.h
 cp/tree.o: cp/tree.c $(CXX_TREE_H) $(TM_H) $(FLAGS_H) toplev.h $(RTL_H) \
   insn-config.h $(INTEGRATE_H) $(TREE_INLINE_H) $(REAL_H) gt-cp-tree.h \
   $(TARGET_H) debug.h $(TREE_FLOW_H) $(CGRAPH_H)
@@ -309,7 +310,7 @@ cp/optimize.o: cp/optimize.c $(CXX_TREE_
 cp/mangle.o: cp/mangle.c $(CXX_TREE_H) $(TM_H) toplev.h $(REAL_H) \
   gt-cp-mangle.h $(TARGET_H) $(TM_P_H)
 cp/parser.o: cp/parser.c $(CXX_TREE_H) $(TM_H) $(DIAGNOSTIC_H) gt-cp-parser.h \
-  output.h $(TARGET_H) $(PLUGIN_H)
+  output.h $(TARGET_H) $(PLUGIN_H) intl.h
 cp/cp-gimplify.o: cp/cp-gimplify.c $(CXX_TREE_H) toplev.h $(C_COMMON_H) \
 	$(TM_H) coretypes.h pointer-set.h tree-iterator.h
 
Index: cvt.c
===================================================================
--- cvt.c	(revision 156592)
+++ cvt.c	(working copy)
@@ -33,6 +33,7 @@ along with GCC; see the file COPYING3.  
 #include "tree.h"
 #include "flags.h"
 #include "cp-tree.h"
+#include "intl.h"
 #include "convert.h"
 #include "toplev.h"
 #include "decl.h"
@@ -367,17 +368,17 @@ warn_ref_binding (tree reftype, tree int
       const char *msg;
 
       if (CP_TYPE_VOLATILE_P (ttl) && decl)
-	  msg = "initialization of volatile reference type %q#T from"
-	    " rvalue of type %qT";
+	msg = G_("initialization of volatile reference type %q#T from "
+	         "rvalue of type %qT");
       else if (CP_TYPE_VOLATILE_P (ttl))
-	  msg = "conversion to volatile reference type %q#T "
-	    " from rvalue of type %qT";
+	msg = G_("conversion to volatile reference type %q#T "
+	         "from rvalue of type %qT");
       else if (decl)
-	  msg = "initialization of non-const reference type %q#T from"
-	    " rvalue of type %qT";
+	msg = G_("initialization of non-const reference type %q#T from "
+	         "rvalue of type %qT");
       else
-	  msg = "conversion to non-const reference type %q#T from"
-	    " rvalue of type %qT";
+	msg = G_("conversion to non-const reference type %q#T from "
+	         "rvalue of type %qT");
 
       permerror (input_location, msg, reftype, intype);
     }
Index: parser.c
===================================================================
--- parser.c	(revision 156592)
+++ parser.c	(working copy)
@@ -28,6 +28,7 @@ along with GCC; see the file COPYING3.  
 #include "cpplib.h"
 #include "tree.h"
 #include "cp-tree.h"
+#include "intl.h"
 #include "c-pragma.h"
 #include "decl.h"
 #include "flags.h"
@@ -4537,7 +4538,7 @@ cp_parser_postfix_expression (cp_parser 
 	/* New types cannot be defined in the cast.  */
 	saved_message = parser->type_definition_forbidden_message;
 	parser->type_definition_forbidden_message
-	  = "types may not be defined in casts";
+	  = G_("types may not be defined in casts");
 
 	/* Look for the opening `<'.  */
 	cp_parser_require (parser, CPP_LESS, "%<<%>");
@@ -4600,7 +4601,7 @@ cp_parser_postfix_expression (cp_parser 
 	/* Types cannot be defined in a `typeid' expression.  */
 	saved_message = parser->type_definition_forbidden_message;
 	parser->type_definition_forbidden_message
-	  = "types may not be defined in a %<typeid%> expression";
+	  = G_("types may not be defined in a %<typeid%> expression");
 	/* We can't be sure yet whether we're looking at a type-id or an
 	   expression.  */
 	cp_parser_parse_tentatively (parser);
@@ -5837,7 +5838,7 @@ cp_parser_new_type_id (cp_parser* parser
      complete.)  */
   saved_message = parser->type_definition_forbidden_message;
   parser->type_definition_forbidden_message
-    = "types may not be defined in a new-type-id";
+    = G_("types may not be defined in a new-type-id");
   /* Parse the type-specifier-seq.  */
   cp_parser_type_specifier_seq (parser, /*is_declaration=*/false,
 				/*is_trailing_return=*/false,
@@ -6150,7 +6151,7 @@ cp_parser_cast_expression (cp_parser *pa
       /* Types may not be defined in a cast.  */
       saved_message = parser->type_definition_forbidden_message;
       parser->type_definition_forbidden_message
-	= "types may not be defined in casts";
+	= G_("types may not be defined in casts");
       /* Consume the `('.  */
       cp_lexer_consume_token (parser->lexer);
       /* A very tricky bit is that `(struct S) { 3 }' is a
@@ -8103,7 +8104,7 @@ cp_parser_condition (cp_parser* parser)
      condition.  */
   saved_message = parser->type_definition_forbidden_message;
   parser->type_definition_forbidden_message
-    = "types may not be defined in conditions";
+    = G_("types may not be defined in conditions");
   /* Parse the type-specifier-seq.  */
   cp_parser_type_specifier_seq (parser, /*is_declaration==*/true,
 				/*is_trailing_return=*/false,
@@ -9513,7 +9514,7 @@ cp_parser_decltype (cp_parser *parser)
 
   /* And create the new one.  */
   parser->type_definition_forbidden_message
-    = "types may not be defined in %<decltype%> expressions";
+    = G_("types may not be defined in %<decltype%> expressions");
 
   /* The restrictions on constant-expressions do not apply inside
      decltype expressions.  */
@@ -15022,7 +15023,7 @@ cp_parser_parameter_declaration (cp_pars
   /* Type definitions may not appear in parameter types.  */
   saved_message = parser->type_definition_forbidden_message;
   parser->type_definition_forbidden_message
-    = "types may not be defined in parameter types";
+    = G_("types may not be defined in parameter types");
 
   /* Parse the declaration-specifiers.  */
   cp_parser_decl_specifier_seq (parser,
@@ -17212,7 +17213,7 @@ cp_parser_exception_specification_opt (c
       /* Types may not be defined in an exception-specification.  */
       saved_message = parser->type_definition_forbidden_message;
       parser->type_definition_forbidden_message
-	= "types may not be defined in an exception-specification";
+	= G_("types may not be defined in an exception-specification");
       /* Parse the type-id-list.  */
       type_id_list = cp_parser_type_id_list (parser);
       /* Restore the saved message.  */
@@ -17393,7 +17394,7 @@ cp_parser_exception_declaration (cp_pars
   /* Types may not be defined in exception-declarations.  */
   saved_message = parser->type_definition_forbidden_message;
   parser->type_definition_forbidden_message
-    = "types may not be defined in exception-declarations";
+    = G_("types may not be defined in exception-declarations");
 
   /* Parse the type-specifier-seq.  */
   cp_parser_type_specifier_seq (parser, /*is_declaration=*/true,
Index: pt.c
===================================================================
--- pt.c	(revision 156592)
+++ pt.c	(working copy)
@@ -4112,16 +4112,19 @@ check_default_tmpl_args (tree decl, tree
 
   /* Figure out what error message to issue.  */
   if (is_friend_decl == 2)
-    msg = "default template arguments may not be used in function template friend re-declaration";
+    msg = G_("default template arguments may not be used in function template "
+	     "friend re-declaration");
   else if (is_friend_decl)
-    msg = "default template arguments may not be used in function template friend declarations";
+    msg = G_("default template arguments may not be used in function template "
+	     "friend declarations");
   else if (TREE_CODE (decl) == FUNCTION_DECL && (cxx_dialect == cxx98))
-    msg = ("default template arguments may not be used in function templates "
-	   "without -std=c++0x or -std=gnu++0x");
+    msg = G_("default template arguments may not be used in function templates "
+	     "without -std=c++0x or -std=gnu++0x");
   else if (is_partial)
-    msg = "default template arguments may not be used in partial specializations";
+    msg = G_("default template arguments may not be used in "
+	     "partial specializations");
   else
-    msg = "default argument for template parameter for class enclosing %qD";
+    msg = G_("default argument for template parameter for class enclosing %qD");
 
   if (current_class_type && TYPE_BEING_DEFINED (current_class_type))
     /* If we're inside a class definition, there's no need to
@@ -4172,7 +4175,8 @@ check_default_tmpl_args (tree decl, tree
       /* At this point, if we're still interested in issuing messages,
 	 they must apply to classes surrounding the object declared.  */
       if (msg)
-	msg = "default argument for template parameter for class enclosing %qD";
+	msg = G_("default argument for template parameter for class "
+		 "enclosing %qD");
     }
 
   return no_errors;
Index: search.c
===================================================================
--- search.c	(revision 156592)
+++ search.c	(working copy)
@@ -29,6 +29,7 @@ along with GCC; see the file COPYING3.  
 #include "tm.h"
 #include "tree.h"
 #include "cp-tree.h"
+#include "intl.h"
 #include "obstack.h"
 #include "flags.h"
 #include "rtl.h"
@@ -1101,7 +1102,7 @@ lookup_field_r (tree binfo, void *data)
 	  /* Add the new value.  */
 	  lfi->ambiguous = tree_cons (NULL_TREE, nval, lfi->ambiguous);
 	  TREE_TYPE (lfi->ambiguous) = error_mark_node;
-	  lfi->errstr = "request for member %qD is ambiguous";
+	  lfi->errstr = G_("request for member %qD is ambiguous");
 	}
     }
   else

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