char *namep;
int vrb = 2;
- if (! pretty_p)
+ if (!pretty_p)
{
name = "";
vrb = 0;
input_location = saved_location;
}
if (!ix && !current_function_decl)
- pedwarn ("%J%qD is not defined outside of function scope", decl, decl);
+ pedwarn ("%qD is not defined outside of function scope", decl);
return decl;
}
const int nchars_max = flag_isoc99 ? 4095 : 509;
int length = TREE_STRING_LENGTH (value);
int nchars;
- tree e_type, i_type;
-
+ tree e_type, i_type, a_type;
+
/* Compute the number of elements, for the array type. */
nchars = wide_flag ? length / wchar_bytes : length;
nchars - 1, nchars_max, flag_isoc99 ? 99 : 89);
e_type = wide_flag ? wchar_type_node : char_type_node;
- /* Create the array type for the string constant.
- -Wwrite-strings says make the string constant an array of const char
- so that copying it to a non-const pointer will get a warning.
- For C++, this is the standard behavior. */
- if (flag_const_strings)
- e_type = build_type_variant (e_type, 1, 0);
+ /* Create the array type for the string constant. flag_const_strings
+ says make the string constant an array of const char so that
+ copying it to a non-const pointer will get a warning. For C++,
+ this is the standard behavior.
+
+ The C++ front end relies on TYPE_MAIN_VARIANT of a cv-qualified
+ array type being the unqualified version of that type.
+ Therefore, if we are constructing an array of const char, we must
+ construct the matching unqualified array type first. The C front
+ end does not require this, but it does no harm, so we do it
+ unconditionally. */
i_type = build_index_type (build_int_cst (NULL_TREE, nchars - 1));
- TREE_TYPE (value) = build_array_type (e_type, i_type);
+ a_type = build_array_type (e_type, i_type);
+ if (flag_const_strings)
+ {
+ /* bleah, c_build_qualified_type should set TYPE_MAIN_VARIANT. */
+ tree qa_type = c_build_qualified_type (a_type, TYPE_QUAL_CONST);
+ TYPE_MAIN_VARIANT (qa_type) = a_type;
+ a_type = qa_type;
+ }
+ TREE_TYPE (value) = a_type;
TREE_CONSTANT (value) = 1;
TREE_INVARIANT (value) = 1;
TREE_READONLY (value) = 1;
don't warn unless pedantic. */
if ((pedantic
|| TYPE_UNSIGNED (type)
- || ! constant_fits_type_p (expr,
- c_common_unsigned_type (type)))
+ || !constant_fits_type_p (expr,
+ c_common_unsigned_type (type)))
&& skip_evaluation == 0)
warning ("overflow in implicit constant conversion");
}
while (add)
{
struct tlist *next = add->next;
- if (! copy)
+ if (!copy)
add->next = *to;
- if (! exclude_writer || add->writer != exclude_writer)
+ if (!exclude_writer || add->writer != exclude_writer)
*to = copy ? new_tlist (*to, add->expr, add->writer) : add;
add = next;
}
if (tmp2->expr == add->expr)
{
found = 1;
- if (! tmp2->writer)
+ if (!tmp2->writer)
tmp2->writer = add->writer;
}
- if (! found)
+ if (!found)
{
*end = copy ? add : new_tlist (NULL, add->expr, add->writer);
end = &(*end)->next;
{
if (list->expr == written
&& list->writer != writer
- && (! only_writes || list->writer)
+ && (!only_writes || list->writer)
&& DECL_NAME (list->expr))
{
warned_ids = new_tlist (warned_ids, written, NULL_TREE);
{
struct tlist *tmp_before, *tmp_nosp, *tmp_list2, *tmp_list3;
enum tree_code code;
- char cl;
+ enum tree_code_class cl;
/* X may be NULL if it is the operand of an empty statement expression
({ }). */
if (t->expr == x)
break;
- if (! t)
+ if (!t)
{
t = XOBNEW (&tlist_obstack, struct tlist_cache);
t->next = save_expr_cache;
add_tlist (pno_sp, t->cache_after_sp, NULL_TREE, 1);
return;
}
- default:
- break;
- }
-
- if (cl == '1')
- {
- if (first_rtl_op (code) == 0)
- return;
- x = TREE_OPERAND (x, 0);
- writer = 0;
- goto restart;
- }
- switch (cl)
- {
- case 'r':
- case '<':
- case '2':
- case 'e':
- case 's':
- case 'x':
- {
- int lp;
- int max = first_rtl_op (TREE_CODE (x));
- for (lp = 0; lp < max; lp++)
- {
- tmp_before = tmp_nosp = 0;
- verify_tree (TREE_OPERAND (x, lp), &tmp_before, &tmp_nosp, NULL_TREE);
- merge_tlist (&tmp_nosp, tmp_before, 0);
- add_tlist (pno_sp, tmp_nosp, NULL_TREE, 0);
- }
- break;
- }
+ default:
+ /* For other expressions, simply recurse on their operands.
+ Manual tail recursion for unary expressions.
+ Other non-expressions need not be processed. */
+ if (cl == tcc_unary)
+ {
+ if (first_rtl_op (code) == 0)
+ return;
+ x = TREE_OPERAND (x, 0);
+ writer = 0;
+ goto restart;
+ }
+ else if (IS_EXPR_CODE_CLASS (cl))
+ {
+ int lp;
+ int max = first_rtl_op (TREE_CODE (x));
+ for (lp = 0; lp < max; lp++)
+ {
+ tmp_before = tmp_nosp = 0;
+ verify_tree (TREE_OPERAND (x, lp), &tmp_before, &tmp_nosp, 0);
+ merge_tlist (&tmp_nosp, tmp_before, 0);
+ add_tlist (pno_sp, tmp_nosp, NULL_TREE, 0);
+ }
+ }
+ return;
}
}
tree
c_common_signed_or_unsigned_type (int unsignedp, tree type)
{
- if (! INTEGRAL_TYPE_P (type)
+ if (!INTEGRAL_TYPE_P (type)
|| TYPE_UNSIGNED (type) == unsignedp)
return type;
else
log = tree_floor_log2 (value);
- return log + 1 + ! unsignedp;
+ return log + 1 + !unsignedp;
}
\f
/* Print an error message for invalid operands to arith operation
opname = "||"; break;
case BIT_XOR_EXPR:
opname = "^"; break;
- case LROTATE_EXPR:
- case RROTATE_EXPR:
- opname = "rotate"; break;
default:
- opname = "unknown"; break;
+ gcc_unreachable ();
}
error ("invalid operands to binary %s", opname);
}
the second arg is 0. */
if (TREE_CONSTANT (primop0)
- && ! integer_zerop (primop1) && ! real_zerop (primop1))
+ && !integer_zerop (primop1) && !real_zerop (primop1))
{
tree tem = primop0;
int temi = unsignedp0;
enumerated type itself. In C++, TYPE_MAX_VALUE and
TYPE_MIN_VALUE have already been set correctly on the
enumeration type. */
- if (!c_dialect_cxx() && TREE_CODE (type) == ENUMERAL_TYPE)
+ if (!c_dialect_cxx () && TREE_CODE (type) == ENUMERAL_TYPE)
type = c_common_type_for_size (TYPE_PRECISION (type), unsignedp0);
maxval = TYPE_MAX_VALUE (type);
>= 0, the signedness of the comparison isn't an issue,
so suppress the warning. */
if (extra_warnings && !in_system_header
- && ! (TREE_CODE (primop0) == INTEGER_CST
- && ! TREE_OVERFLOW (convert (c_common_signed_type (type),
- primop0))))
+ && !(TREE_CODE (primop0) == INTEGER_CST
+ && !TREE_OVERFLOW (convert (c_common_signed_type (type),
+ primop0))))
warning ("comparison of unsigned expression >= 0 is always true");
value = truthvalue_true_node;
break;
case LT_EXPR:
if (extra_warnings && !in_system_header
- && ! (TREE_CODE (primop0) == INTEGER_CST
- && ! TREE_OVERFLOW (convert (c_common_signed_type (type),
- primop0))))
+ && !(TREE_CODE (primop0) == INTEGER_CST
+ && !TREE_OVERFLOW (convert (c_common_signed_type (type),
+ primop0))))
warning ("comparison of unsigned expression < 0 is always false");
value = truthvalue_false_node;
break;
This helps produce common subexpressions. */
if ((TREE_CODE (intop) == PLUS_EXPR || TREE_CODE (intop) == MINUS_EXPR)
- && ! TREE_CONSTANT (intop)
+ && !TREE_CONSTANT (intop)
&& TREE_CONSTANT (TREE_OPERAND (intop, 1))
&& TREE_CONSTANT (size_exp)
/* If the constant comes from pointer subtraction,
/* If the constant is unsigned, and smaller than the pointer size,
then we must skip this optimization. This is because it could cause
an overflow error if the constant is negative but INTOP is not. */
- && (! TYPE_UNSIGNED (TREE_TYPE (intop))
+ && (!TYPE_UNSIGNED (TREE_TYPE (intop))
|| (TYPE_PRECISION (TREE_TYPE (intop))
== TYPE_PRECISION (TREE_TYPE (ptrop)))))
{
case ADDR_EXPR:
{
if (TREE_CODE (TREE_OPERAND (expr, 0)) == FUNCTION_DECL
- && ! DECL_WEAK (TREE_OPERAND (expr, 0)))
+ && !DECL_WEAK (TREE_OPERAND (expr, 0)))
{
/* Common Ada/Pascal programmer's mistake. We always warn
about this since it is so bad. */
{
int i = 0;
int shift, size;
- tree t = (tree)p;
+ tree t = (tree) p;
tree t2;
switch (TREE_CODE (t))
{
return ((size << 24) | (i << shift));
}
+static GTY((param_is (union tree_node))) htab_t type_hash_table;
+
/* Return the typed-based alias set for T, which may be an expression
or a type. Return -1 if we don't do anything special. */
{
tree u;
PTR *slot;
- static htab_t type_hash_table;
/* Permit type-punning when accessing a union, provided the access
is directly through the union. For example, this code does not
return 0;
/* That's all the expressions we handle specially. */
- if (! TYPE_P (t))
+ if (!TYPE_P (t))
return -1;
/* The C standard guarantees that any object may be accessed via an
/* Look up t in hash table. Only one of the compatible types within each
alias set is recorded in the table. */
if (!type_hash_table)
- type_hash_table = htab_create (1021, c_type_hash,
+ type_hash_table = htab_create_ggc (1021, c_type_hash,
(htab_eq) lang_hooks.types_compatible_p,
NULL);
slot = htab_find_slot (type_hash_table, t, INSERT);
lang_hooks.decls.pushdecl (build_decl (TYPE_DECL, NULL_TREE,
intDI_type_node));
#if HOST_BITS_PER_WIDE_INT >= 64
- lang_hooks.decls.pushdecl (build_decl (TYPE_DECL,
- get_identifier ("__int128_t"),
- intTI_type_node));
+ if (targetm.scalar_mode_supported_p (TImode))
+ lang_hooks.decls.pushdecl (build_decl (TYPE_DECL,
+ get_identifier ("__int128_t"),
+ intTI_type_node));
#endif
lang_hooks.decls.pushdecl (build_decl (TYPE_DECL, NULL_TREE,
unsigned_intQI_type_node));
lang_hooks.decls.pushdecl (build_decl (TYPE_DECL, NULL_TREE,
unsigned_intDI_type_node));
#if HOST_BITS_PER_WIDE_INT >= 64
- lang_hooks.decls.pushdecl (build_decl (TYPE_DECL,
- get_identifier ("__uint128_t"),
- unsigned_intTI_type_node));
+ if (targetm.scalar_mode_supported_p (TImode))
+ lang_hooks.decls.pushdecl (build_decl (TYPE_DECL,
+ get_identifier ("__uint128_t"),
+ unsigned_intTI_type_node));
#endif
/* Create the widest literal types. */
return t;
}
-/* Walk the statement tree, rooted at *tp. Apply FUNC to all the
- sub-trees of *TP in a pre-order traversal. FUNC is called with the
- DATA and the address of each sub-tree. If FUNC returns a non-NULL
- value, the traversal is aborted, and the value returned by FUNC is
- returned. If FUNC sets WALK_SUBTREES to zero, then the subtrees of
- the node being visited are not walked.
-
- We don't need a without_duplicates variant of this one because the
- statement tree is a tree, not a graph. */
-
-tree
-walk_stmt_tree (tree *tp, walk_tree_fn func, void *data)
-{
- enum tree_code code;
- int walk_subtrees;
- tree result;
- int i, len;
-
-#define WALK_SUBTREE(NODE) \
- do \
- { \
- result = walk_stmt_tree (&(NODE), func, data); \
- if (result) \
- return result; \
- } \
- while (0)
-
- /* Skip empty subtrees. */
- if (!*tp)
- return NULL_TREE;
-
- /* Skip subtrees below non-statement nodes. */
- if (!STATEMENT_CODE_P (TREE_CODE (*tp)))
- return NULL_TREE;
-
- /* Call the function. */
- walk_subtrees = 1;
- result = (*func) (tp, &walk_subtrees, data);
-
- /* If we found something, return it. */
- if (result)
- return result;
-
- /* FUNC may have modified the tree, recheck that we're looking at a
- statement node. */
- code = TREE_CODE (*tp);
- if (!STATEMENT_CODE_P (code))
- return NULL_TREE;
-
- /* Visit the subtrees unless FUNC decided that there was nothing
- interesting below this point in the tree. */
- if (walk_subtrees)
- {
- /* Walk over all the sub-trees of this operand. Statement nodes
- never contain RTL, and we needn't worry about TARGET_EXPRs. */
- len = TREE_CODE_LENGTH (code);
-
- /* Go through the subtrees. We need to do this in forward order so
- that the scope of a FOR_EXPR is handled properly. */
- for (i = 0; i < len; ++i)
- WALK_SUBTREE (TREE_OPERAND (*tp, i));
- }
-
- /* Finally visit the chain. This can be tail-recursion optimized if
- we write it this way. */
- return walk_stmt_tree (&TREE_CHAIN (*tp), func, data);
-
-#undef WALK_SUBTREE
-}
-
/* Used to compare case labels. K1 and K2 are actually tree nodes
representing case labels, or NULL_TREE for a `default' label.
Returns -1 if K1 is ordered before K2, -1 if K1 is ordered after
expression. If both low_value and high_value are out of range,
don't insert the case label and return NULL_TREE. */
if (low_value
- && ! check_case_bounds (type, orig_type,
- &low_value, high_value ? &high_value : NULL))
+ && !check_case_bounds (type, orig_type,
+ &low_value, high_value ? &high_value : NULL))
return NULL_TREE;
/* Look up the LOW_VALUE in the table of case labels we already
/* Change this type to have a type with the specified mode.
First check for the special modes. */
- if (! strcmp (p, "byte"))
+ if (!strcmp (p, "byte"))
mode = byte_mode;
else if (!strcmp (p, "word"))
mode = word_mode;
- else if (! strcmp (p, "pointer"))
+ else if (!strcmp (p, "pointer"))
mode = ptr_mode;
else
for (j = 0; j < NUM_MACHINE_MODES; j++)
if (!strcmp (p, GET_MODE_NAME (j)))
- mode = (enum machine_mode) j;
+ {
+ mode = (enum machine_mode) j;
+ break;
+ }
if (mode == VOIDmode)
{
- error ("unknown machine mode %<%s%>", p);
+ error ("unknown machine mode %qs", p);
return NULL_TREE;
}
}
if (!valid_mode)
{
- error ("unable to emulate %<%s%>", p);
+ error ("unable to emulate %qs", p);
return NULL_TREE;
}
if (!targetm.valid_pointer_mode (mode))
{
- error ("invalid pointer mode %<%s%>", p);
+ error ("invalid pointer mode %qs", p);
return NULL_TREE;
}
if (typefm == NULL_TREE)
{
- error ("no data type for mode %<%s%>", p);
+ error ("no data type for mode %qs", p);
return NULL_TREE;
}
else if (TREE_CODE (type) == ENUMERAL_TYPE)
this mode for this type. */
if (TREE_CODE (typefm) != INTEGER_TYPE)
{
- error ("cannot use mode %qs for enumeral types",
- GET_MODE_NAME (mode));
+ error ("cannot use mode %qs for enumeral types", p);
return NULL_TREE;
}
TYPE_PRECISION (type) = TYPE_PRECISION (typefm);
typefm = type;
}
+ else if (VECTOR_MODE_P (mode)
+ ? TREE_CODE (type) != TREE_CODE (TREE_TYPE (typefm))
+ : TREE_CODE (type) != TREE_CODE (typefm))
+ {
+ error ("mode %qs applied to inappropriate type", p);
+ return NULL_TREE;
+ }
+
*node = typefm;
/* No need to layout the type here. The caller should do this. */
{
if (TREE_CODE (decl) == VAR_DECL
&& current_function_decl != NULL_TREE
- && ! TREE_STATIC (decl))
+ && !TREE_STATIC (decl))
{
error ("%Jsection attribute cannot be specified for "
"local variables", decl);
tree decl = *node;
if ((TREE_CODE (decl) == FUNCTION_DECL && DECL_INITIAL (decl))
- || (TREE_CODE (decl) != FUNCTION_DECL && ! DECL_EXTERNAL (decl)))
+ || (TREE_CODE (decl) != FUNCTION_DECL && !DECL_EXTERNAL (decl)))
{
error ("%J%qD defined both normally and as an alias", decl, decl);
*no_add_attrs = true;
id = TREE_VALUE (args);
if (TREE_CODE (id) != STRING_CST)
{
- error ("alias arg not a string");
+ error ("alias argument not a string");
*no_add_attrs = true;
return NULL_TREE;
}
return NULL_TREE;
}
}
- else if (decl_function_context (decl) != 0 || ! TREE_PUBLIC (decl))
+ else if (decl_function_context (decl) != 0 || !TREE_PUBLIC (decl))
{
warning ("%qs attribute ignored", IDENTIFIER_POINTER (name));
return NULL_TREE;
if (TREE_CODE (id) != STRING_CST)
{
- error ("visibility arg not a string");
+ error ("visibility argument not a string");
return NULL_TREE;
}
if (TYPE_P (decl))
{
decl = TYPE_NAME (decl);
- if (! decl)
+ if (!decl)
return NULL_TREE;
}
else if (strcmp (TREE_STRING_POINTER (id), "protected") == 0)
DECL_VISIBILITY (decl) = VISIBILITY_PROTECTED;
else
- error ("visibility arg must be one of \"default\", \"hidden\", \"protected\" or \"internal\"");
+ error ("visibility argument must be one of \"default\", \"hidden\", \"protected\" or \"internal\"");
DECL_VISIBILITY_SPECIFIED (decl) = 1;
/* For decls only, go ahead and attach the attribute to the node as well.
{
tree decl = *node;
- if (! DECL_THREAD_LOCAL (decl))
+ if (!DECL_THREAD_LOCAL (decl))
{
warning ("%qs attribute ignored", IDENTIFIER_POINTER (name));
*no_add_attrs = true;
id = TREE_VALUE (args);
if (TREE_CODE (id) != STRING_CST)
{
- error ("tls_model arg not a string");
+ error ("tls_model argument not a string");
*no_add_attrs = true;
return NULL_TREE;
}
&& strcmp (TREE_STRING_POINTER (id), "local-dynamic")
&& strcmp (TREE_STRING_POINTER (id), "global-dynamic"))
{
- error ("tls_model arg must be one of \"local-exec\", \"initial-exec\", \"local-dynamic\" or \"global-dynamic\"");
+ error ("tls_model argument must be one of \"local-exec\", \"initial-exec\", \"local-dynamic\" or \"global-dynamic\"");
*no_add_attrs = true;
return NULL_TREE;
}
if (TREE_CODE (size) == NON_LVALUE_EXPR)
size = TREE_OPERAND (size, 0);
- if (! host_integerp (size, 1))
+ if (!host_integerp (size, 1))
{
warning ("%qs attribute ignored", IDENTIFIER_POINTER (name));
return NULL_TREE;
if (TREE_CODE (type) == RECORD_TYPE
|| (GET_MODE_CLASS (orig_mode) != MODE_FLOAT
&& GET_MODE_CLASS (orig_mode) != MODE_INT)
- || ! host_integerp (TYPE_SIZE_UNIT (type), 1))
+ || !host_integerp (TYPE_SIZE_UNIT (type), 1))
{
error ("invalid vector type for attribute %qs",
IDENTIFIER_POINTER (name));
/* If no arguments are specified, all pointer arguments should be
non-null. Verify a full prototype is given so that the arguments
will have the correct types when we actually check them later. */
- if (! args)
+ if (!args)
{
- if (! TYPE_ARG_TYPES (type))
+ if (!TYPE_ARG_TYPES (type))
{
error ("nonnull attribute without arguments on a non-prototype");
*no_add_attrs = true;
tree argument;
unsigned HOST_WIDE_INT arg_num = 0, ck_num;
- if (! get_nonnull_operand (TREE_VALUE (args), &arg_num))
+ if (!get_nonnull_operand (TREE_VALUE (args), &arg_num))
{
- error ("nonnull argument has invalid operand number (arg %lu)",
+ error ("nonnull argument has invalid operand number (argument %lu)",
(unsigned long) attr_arg_num);
*no_add_attrs = true;
return NULL_TREE;
{
for (ck_num = 1; ; ck_num++)
{
- if (! argument || ck_num == arg_num)
+ if (!argument || ck_num == arg_num)
break;
argument = TREE_CHAIN (argument);
}
- if (! argument
+ if (!argument
|| TREE_CODE (TREE_VALUE (argument)) == VOID_TYPE)
{
- error ("nonnull argument with out-of-range operand number (arg %lu, operand %lu)",
+ error ("nonnull argument with out-of-range operand number (argument %lu, operand %lu)",
(unsigned long) attr_arg_num, (unsigned long) arg_num);
*no_add_attrs = true;
return NULL_TREE;
if (TREE_CODE (TREE_VALUE (argument)) != POINTER_TYPE)
{
- error ("nonnull argument references non-pointer operand (arg %lu, operand %lu)",
+ error ("nonnull argument references non-pointer operand (argument %lu, operand %lu)",
(unsigned long) attr_arg_num, (unsigned long) arg_num);
*no_add_attrs = true;
return NULL_TREE;
for (param = params, param_num = 1; ;
param_num++, param = TREE_CHAIN (param))
{
- if (! param)
+ if (!param)
break;
- if (! args || nonnull_check_p (args, param_num))
+ if (!args || nonnull_check_p (args, param_num))
check_function_arguments_recurse (check_nonnull_arg, NULL,
TREE_VALUE (param),
param_num);
return;
if (integer_zerop (param))
- warning ("null argument where non-null required (arg %lu)",
+ warning ("null argument where non-null required (argument %lu)",
(unsigned long) param_num);
}
cleanup_id = TREE_VALUE (args);
if (TREE_CODE (cleanup_id) != IDENTIFIER_NODE)
{
- error ("cleanup arg not an identifier");
+ error ("cleanup argument not an identifier");
*no_add_attrs = true;
return NULL_TREE;
}
cleanup_decl = lookup_name (cleanup_id);
if (!cleanup_decl || TREE_CODE (cleanup_decl) != FUNCTION_DECL)
{
- error ("cleanup arg not a function");
+ error ("cleanup argument not a function");
*no_add_attrs = true;
return NULL_TREE;
}
resort_field_decl_cmp);
}
+/* Subroutine of c_parse_error.
+ Return the result of concatenating LHS and RHS. RHS is really
+ a string literal, its first character is indicated by RHS_START and
+ RHS_SIZE is its length (including the terminating NUL character).
+
+ The caller is responsible for deleting the returned pointer. */
+
+static char *
+catenate_strings (const char *lhs, const char *rhs_start, int rhs_size)
+{
+ const int lhs_size = strlen (lhs);
+ char *result = XNEWVEC (char, lhs_size + rhs_size);
+ strncpy (result, lhs, lhs_size);
+ strncpy (result + lhs_size, rhs_start, rhs_size);
+ return result;
+}
+
/* Issue the error given by MSGID, indicating that it occurred before
TOKEN, which had the associated VALUE. */
void
c_parse_error (const char *msgid, enum cpp_ttype token, tree value)
{
- const char *string = _(msgid);
+#define catenate_messages(M1, M2) catenate_strings ((M1), (M2), sizeof (M2))
+
+ char *message = NULL;
if (token == CPP_EOF)
- error ("%s at end of input", string);
+ message = catenate_messages (msgid, " at end of input");
else if (token == CPP_CHAR || token == CPP_WCHAR)
{
unsigned int val = TREE_INT_CST_LOW (value);
const char *const ell = (token == CPP_CHAR) ? "" : "L";
if (val <= UCHAR_MAX && ISGRAPH (val))
- error ("%s before %s'%c'", string, ell, val);
+ message = catenate_messages (msgid, " before %s'%c'");
else
- error ("%s before %s'\\x%x'", string, ell, val);
+ message = catenate_messages (msgid, " before %s'\\x%x'");
+
+ error (message, ell, val);
+ free (message);
+ message = NULL;
}
- else if (token == CPP_STRING
- || token == CPP_WSTRING)
- error ("%s before string constant", string);
+ else if (token == CPP_STRING || token == CPP_WSTRING)
+ message = catenate_messages (msgid, " before string constant");
else if (token == CPP_NUMBER)
- error ("%s before numeric constant", string);
+ message = catenate_messages (msgid, " before numeric constant");
else if (token == CPP_NAME)
- error ("%s before \"%s\"", string, IDENTIFIER_POINTER (value));
+ {
+ message = catenate_messages (msgid, " before %qs");
+ error (message, IDENTIFIER_POINTER (value));
+ free (message);
+ message = NULL;
+ }
else if (token < N_TTYPES)
- error ("%s before %qs token", string, cpp_type2name (token));
+ {
+ message = catenate_messages (msgid, " before %qs token");
+ error (message, cpp_type2name (token));
+ free (message);
+ message = NULL;
+ }
else
- error ("%s", string);
+ error (msgid);
+
+ if (message)
+ {
+ error (message);
+ free (message);
+ }
+#undef catenate_messages
}
/* Walk a gimplified function and warn for functions whose return value is
return convert (size_type_node, fold_offsetof_1 (expr));
}
+/* Return nonzero if REF is an lvalue valid for this language;
+ otherwise, print an error message and return zero. USE says
+ how the lvalue is being used and so selects the error message. */
+
+int
+lvalue_or_else (tree ref, enum lvalue_use use)
+{
+ int win = lvalue_p (ref);
+
+ if (!win)
+ {
+ switch (use)
+ {
+ case lv_assign:
+ error ("invalid lvalue in assignment");
+ break;
+ case lv_increment:
+ error ("invalid lvalue in increment");
+ break;
+ case lv_decrement:
+ error ("invalid lvalue in decrement");
+ break;
+ case lv_addressof:
+ error ("invalid lvalue in unary %<&%>");
+ break;
+ case lv_asm:
+ error ("invalid lvalue in asm statement");
+ break;
+ default:
+ gcc_unreachable ();
+ }
+ }
+
+ return win;
+}
+
#include "gt-c-common.h"