diff mbox

[C++] PR 38761, 40872

Message ID 4E9EBAF3.7090201@oracle.com
State New
Headers show

Commit Message

Paolo Carlini Oct. 19, 2011, 11:56 a.m. UTC
Hi,

these simple PRs are both about conditional expressions in error calls 
which apparently make the life very hard to gettext: today I double 
checked and current 0.18.1 is still unable to cope correctly with those, 
it just doesn't extract the second message. Thus the below, which simply 
uses G_() in a few more places.

Tested x86_64-linux (the make gcc.pot output too, of course)

Ok?

Thanks,
Paolo.

/////////////////////////
2011-10-19  Paolo Carlini  <paolo.carlini@oracle.com>

	PR c++/38761
	PR c++/40872
	* decl.c (duplicate_decls, make_typename_type, grokdeclarator): Use
	G_() in error message strings to facilitate translation.
	* semantics.c (finish_id_expression): Likewise.
	* parser.c (cp_parser_nested_name_specifier_opt,
	cp_parser_parameter_declaration): Likewise.

Comments

Jason Merrill Oct. 19, 2011, 12:44 p.m. UTC | #1
OK.

Jason
diff mbox

Patch

Index: decl.c
===================================================================
--- decl.c	(revision 180180)
+++ decl.c	(working copy)
@@ -1542,8 +1542,8 @@  duplicate_decls (tree newdecl, tree olddecl, bool
 	  error_at (DECL_SOURCE_LOCATION (newdecl), errmsg, newdecl);
 	  if (DECL_NAME (olddecl) != NULL_TREE)
 	    error ((DECL_INITIAL (olddecl) && namespace_bindings_p ())
-			 ? "%q+#D previously defined here"
-			 : "%q+#D previously declared here", olddecl);
+		   ? G_("%q+#D previously defined here")
+		   : G_("%q+#D previously declared here"), olddecl);
 	  return error_mark_node;
 	}
       else if (TREE_CODE (olddecl) == FUNCTION_DECL
@@ -3236,8 +3236,8 @@  make_typename_type (tree context, tree name, enum
   if (!t)
     {
       if (complain & tf_error)
-	error (want_template ? "no class template named %q#T in %q#T"
-	       : "no type named %q#T in %q#T", name, context);
+	error (want_template ? G_("no class template named %q#T in %q#T")
+	       : G_("no type named %q#T in %q#T"), name, context);
       return error_mark_node;
     }
   
@@ -9143,13 +9143,13 @@  grokdeclarator (const cp_declarator *declarator,
 		   virtual.  A constructor may not be static.  */
 		if (staticp == 2)
 		  error ((flags == DTOR_FLAG)
-			 ? "destructor cannot be static member function"
-			 : "constructor cannot be static member function");
+			 ? G_("destructor cannot be static member function")
+			 : G_("constructor cannot be static member function"));
 		if (memfn_quals)
 		  {
 		    error ((flags == DTOR_FLAG)
-			   ? "destructors may not be cv-qualified"
-			   : "constructors may not be cv-qualified");
+			   ? G_("destructors may not be cv-qualified")
+			   : G_("constructors may not be cv-qualified"));
 		    memfn_quals = TYPE_UNQUALIFIED;
 		  }
 
@@ -9502,8 +9502,10 @@  grokdeclarator (const cp_declarator *declarator,
 	      && (!friendp || funcdef_flag))
 	    {
 	      error (funcdef_flag
-		     ? "cannot define member function %<%T::%s%> within %<%T%>"
-		     : "cannot declare member function %<%T::%s%> within %<%T%>",
+		     ? G_("cannot define member function %<%T::%s%> "
+			  "within %<%T%>")
+		     : G_("cannot declare member function %<%T::%s%> "
+			  "within %<%T%>"),
 		     ctype, name, current_class_type);
 	      return error_mark_node;
 	    }
@@ -10223,8 +10225,8 @@  grokdeclarator (const cp_declarator *declarator,
 		     || sfk == sfk_destructor)
 	      {
 		error (funcdef_flag
-		       ? "%qs defined in a non-class scope"
-		       : "%qs declared in a non-class scope", name);
+		       ? G_("%qs defined in a non-class scope")
+		       : G_("%qs declared in a non-class scope"), name);
 		sfk = sfk_none;
 	      }
 	  }
Index: semantics.c
===================================================================
--- semantics.c	(revision 180180)
+++ semantics.c	(working copy)
@@ -34,6 +34,7 @@  along with GCC; see the file COPYING3.  If not see
 #include "c-family/c-objc.h"
 #include "tree-inline.h"
 #include "tree-mudflap.h"
+#include "intl.h"
 #include "toplev.h"
 #include "flags.h"
 #include "output.h"
@@ -2985,8 +2986,8 @@  finish_id_expression (tree id_expression,
 	  else
 	    {
 	      error (TREE_CODE (decl) == VAR_DECL
-		     ? "use of %<auto%> variable from containing function"
-		     : "use of parameter from containing function");
+		     ? G_("use of %<auto%> variable from containing function")
+		     : G_("use of parameter from containing function"));
 	      error ("  %q+#D declared here", decl);
 	      return error_mark_node;
 	    }
Index: parser.c
===================================================================
--- parser.c	(revision 180180)
+++ parser.c	(working copy)
@@ -4752,8 +4752,8 @@  cp_parser_nested_name_specifier_opt (cp_parser *pa
 	       && (TREE_CODE (TYPENAME_TYPE_FULLNAME (new_scope))
 		   == TEMPLATE_ID_EXPR)))
 	permerror (input_location, TYPE_P (new_scope)
-		   ? "%qT is not a template"
-		   : "%qD is not a template",
+		   ? G_("%qT is not a template")
+		   : G_("%qD is not a template"),
 		   new_scope);
       /* If it is a class scope, try to complete it; we are about to
 	 be looking up names inside the class.  */
@@ -16810,17 +16810,20 @@  cp_parser_parameter_declaration (cp_parser *parser
 	  
 	  if (id_declarator && id_declarator->kind == cdk_id)
 	    error_at (declarator_token_start->location,
-		      template_parm_p 
-		      ? "template parameter pack %qD"
-		      " cannot have a default argument"
-		      : "parameter pack %qD cannot have a default argument",
+		      template_parm_p
+		      ? G_("template parameter pack %qD "
+			   "cannot have a default argument")
+		      : G_("parameter pack %qD cannot have "
+			   "a default argument"),
 		      id_declarator->u.id.unqualified_name);
 	  else
 	    error_at (declarator_token_start->location,
-		      template_parm_p 
-		      ? "template parameter pack cannot have a default argument"
-		      : "parameter pack cannot have a default argument");
-	  
+		      template_parm_p
+		      ? G_("template parameter pack cannot have "
+			   "a default argument")
+		      : G_("parameter pack cannot have a "
+			   "default argument"));
+
 	  default_argument = NULL_TREE;
 	}
     }