[C++] Advertise -fext-numeric-literals in error messages

Marc Glisse marc.glisse@inria.fr
Wed Jan 1 18:33:00 GMT 2014


an error message like the following:

error: unable to find numeric literal operator 'operator"" iF'

for using _Complex_I can be a bit hard for users to handle. This adds a 
note that -std=gnu++11 and -fext-numeric-literals might help. Ideally we 
would check if the suffix is indeed recognized by -fext-numeric-literals 
before printing this text, but that's harder, someone else can do that 

No testcase because notes are pruned in the testsuite.

Bootstrap+testsuite on x86_64-unknown-linux-gnu.

2014-01-01  Marc Glisse  <marc.glisse@inria.fr>

 	PR c++/59087
 	* parser.c (cp_parser_userdef_numeric_literal): Mention
 	-fext-numeric-literals in the message.

Marc Glisse
-------------- next part --------------
Index: gcc/cp/parser.c
--- gcc/cp/parser.c	(revision 206274)
+++ gcc/cp/parser.c	(working copy)
@@ -3918,20 +3918,23 @@ cp_parser_userdef_numeric_literal (cp_pa
       result = finish_call_expr (decl, &args, false, true, tf_none);
       if (result != error_mark_node)
 	  release_tree_vector (args);
 	  return result;
   release_tree_vector (args);
   error ("unable to find numeric literal operator %qD", name);
+  if (!cpp_get_options (parse_in)->ext_numeric_literals)
+    inform (token->location, "use -std=gnu++11 or -fext-numeric-literals "
+	    "to enable more built-in suffixes");
   return error_mark_node;
 /* Parse a user-defined string constant.  Returns a call to a user-defined
    literal operator taking a character pointer and the length of the string
    as arguments.  */
 static tree
 cp_parser_userdef_string_literal (cp_token *token)

More information about the Gcc-patches mailing list