===================================================================
@@ -5,4 +5,4 @@
int operator"" _embedraw(const char*)
{ return 41; };
-int k = "Boo!"_embedraw; // { dg-error "unable to find valid user-defined string literal operator" }
+int k = "Boo!"_embedraw; // { dg-error "unable to find valid string literal operator|Possible missing length argument" }
===================================================================
@@ -8,7 +8,7 @@
};
int i = operator"" _Bar(U'x'); // { dg-error "was not declared in this scope" }
-int j = U'x'_Bar; // { dg-error "unable to find user-defined character literal operator" }
+int j = U'x'_Bar; // { dg-error "unable to find character literal operator" }
int
Foo::operator"" _Bar(char32_t) // { dg-error "must be a non-member function" }
===================================================================
@@ -3,13 +3,13 @@
// Check that undeclared literal operator calls and literals give appropriate errors.
int i = operator"" _Bar('x'); // { dg-error "was not declared in this scope" }
-int j = 'x'_Bar; // { dg-error "unable to find user-defined character literal operator" }
+int j = 'x'_Bar; // { dg-error "unable to find character literal operator" }
int ii = operator"" _BarCharStr("Howdy, Pardner!"); // { dg-error "was not declared in this scope" }
-int jj = "Howdy, Pardner!"_BarCharStr; // { dg-error "unable to find user-defined string literal operator" }
+int jj = "Howdy, Pardner!"_BarCharStr; // { dg-error "unable to find string literal operator" }
unsigned long long iULL = operator"" _BarULL(666ULL); // { dg-error "was not declared in this scope" }
-unsigned long long jULL = 666_BarULL; // { dg-error "unable to find user-defined numeric literal operator" }
+unsigned long long jULL = 666_BarULL; // { dg-error "unable to find numeric literal operator" }
long double iLD = operator"" _BarLD(666.0L); // { dg-error "was not declared in this scope" }
-long double jLD = 666.0_BarLD; // { dg-error "unable to find user-defined numeric literal operator" }
+long double jLD = 666.0_BarLD; // { dg-error "unable to find numeric literal operator" }
===================================================================
@@ -3553,34 +3553,32 @@
static tree
cp_parser_userdef_char_literal (cp_parser *parser)
{
- cp_token *token = NULL;
- tree literal, suffix_id, value;
- tree name, decl;
- tree result;
- VEC(tree,gc) *vec;
+ cp_token *token = cp_lexer_consume_token (parser->lexer);
+ tree literal = token->u.value;
+ tree suffix_id = USERDEF_LITERAL_SUFFIX_ID (literal);
+ tree value = USERDEF_LITERAL_VALUE (literal);
+ tree name = cp_literal_operator_id (IDENTIFIER_POINTER (suffix_id));
+ tree decl, result;
- token = cp_lexer_consume_token (parser->lexer);
- literal = token->u.value;
- suffix_id = USERDEF_LITERAL_SUFFIX_ID (literal);
- value = USERDEF_LITERAL_VALUE (literal);
- name = cp_literal_operator_id (IDENTIFIER_POINTER (suffix_id));
-
/* Build up a call to the user-defined operator */
/* Lookup the name we got back from the id-expression. */
- vec = make_tree_vector ();
- VEC_safe_push (tree, gc, vec, value);
- decl = lookup_function_nonclass (name, vec, /*block_p=*/false);
+ VEC(tree,gc) *args = make_tree_vector ();
+ VEC_safe_push (tree, gc, args, value);
+ decl = lookup_function_nonclass (name, args, /*block_p=*/false);
if (!decl || decl == error_mark_node)
{
- error ("unable to find user-defined character literal operator %qD",
- name);
- release_tree_vector (vec);
+ error ("unable to find character literal operator %qD", name);
+ release_tree_vector (args);
return error_mark_node;
}
- result = finish_call_expr (decl, &vec, false, true, tf_warning_or_error);
- release_tree_vector (vec);
+ result = finish_call_expr (decl, &args, false, true, tf_warning_or_error);
+ release_tree_vector (args);
+ if (result != error_mark_node)
+ return result;
- return result;
+ error ("unable to find character literal operator %qD with %qT argument",
+ name, TREE_TYPE (value));
+ return error_mark_node;
}
/* A subroutine of cp_parser_userdef_numeric_literal to
@@ -3615,19 +3613,15 @@
static tree
cp_parser_userdef_numeric_literal (cp_parser *parser)
{
- cp_token *token = NULL;
- tree literal, suffix_id, value, num_string;
- tree name, decl;
- tree result = error_mark_node;
+ cp_token *token = cp_lexer_consume_token (parser->lexer);
+ tree literal = token->u.value;
+ tree suffix_id = USERDEF_LITERAL_SUFFIX_ID (literal);
+ tree value = USERDEF_LITERAL_VALUE (literal);
+ tree num_string = USERDEF_LITERAL_NUM_STRING (literal);
+ tree name = cp_literal_operator_id (IDENTIFIER_POINTER (suffix_id));
+ tree decl, result;
VEC(tree,gc) *args;
- token = cp_lexer_consume_token (parser->lexer);
- literal = token->u.value;
- suffix_id = USERDEF_LITERAL_SUFFIX_ID (literal);
- value = USERDEF_LITERAL_VALUE (literal);
- num_string = USERDEF_LITERAL_NUM_STRING (literal);
- name = cp_literal_operator_id (IDENTIFIER_POINTER (suffix_id));
-
/* Build up a call to the user-defined operator */
/* Lookup the name we got back from the id-expression. */
/* Try to find the literal operator by finishing the call expression
@@ -3681,10 +3675,8 @@
}
release_tree_vector (args);
- if (result == error_mark_node)
- error ("unable to find user-defined numeric literal operator %qD", name);
-
- return result;
+ error ("unable to find numeric literal operator %qD", name);
+ return error_mark_node;
}
/* Parse a user-defined string constant. Returns a call to a user-defined
@@ -3694,37 +3686,33 @@
static tree
cp_parser_userdef_string_literal (cp_token *token)
{
- tree literal, suffix_id, value;
- tree name, decl;
- tree result;
- VEC(tree,gc) *vec;
- int len;
-
- literal = token->u.value;
- suffix_id = USERDEF_LITERAL_SUFFIX_ID (literal);
- name = cp_literal_operator_id (IDENTIFIER_POINTER (suffix_id));
- value = USERDEF_LITERAL_VALUE (literal);
- len = TREE_STRING_LENGTH (value)
+ tree literal = token->u.value;
+ tree suffix_id = USERDEF_LITERAL_SUFFIX_ID (literal);
+ tree name = cp_literal_operator_id (IDENTIFIER_POINTER (suffix_id));
+ tree value = USERDEF_LITERAL_VALUE (literal);
+ int len = TREE_STRING_LENGTH (value)
/ TREE_INT_CST_LOW (TYPE_SIZE_UNIT (TREE_TYPE (TREE_TYPE (value)))) - 1;
+ tree decl, result;
+
/* Build up a call to the user-defined operator */
/* Lookup the name we got back from the id-expression. */
- vec = make_tree_vector ();
- VEC_safe_push (tree, gc, vec, value);
- VEC_safe_push (tree, gc, vec, build_int_cst (size_type_node, len));
- decl = lookup_function_nonclass (name, vec, /*block_p=*/false);
+ VEC(tree,gc) *args = make_tree_vector ();
+ VEC_safe_push (tree, gc, args, value);
+ VEC_safe_push (tree, gc, args, build_int_cst (size_type_node, len));
+ decl = lookup_function_nonclass (name, args, /*block_p=*/false);
if (!decl || decl == error_mark_node)
{
- error ("unable to find user-defined string literal operator %qD", name);
- release_tree_vector (vec);
+ error ("unable to find string literal operator %qD", name);
+ release_tree_vector (args);
return error_mark_node;
}
- result = finish_call_expr (decl, &vec, false, true, tf_none);
+ result = finish_call_expr (decl, &args, false, true, tf_none);
+ release_tree_vector (args);
+
if (result == error_mark_node)
- error ("unable to find valid user-defined string literal operator %qD."
+ error ("unable to find valid string literal operator %qD."
" Possible missing length argument in string literal operator.",
name);
- release_tree_vector (vec);
-
return result;
}