if (unsigned_p || signed_p || long_p || short_p)
{
- int ok = 0;
-
- if ((signed_p || unsigned_p) && TREE_CODE (type) != INTEGER_TYPE)
- error ("%<signed%> or %<unsigned%> invalid for %qs", name);
- else if (signed_p && unsigned_p)
- error ("%<signed%> and %<unsigned%> specified together for %qs", name);
- else if (longlong && TREE_CODE (type) != INTEGER_TYPE)
- error ("%<long long%> invalid for %qs", name);
- else if (long_p && TREE_CODE (type) == REAL_TYPE)
- error ("%<long%> invalid for %qs", name);
- else if (short_p && TREE_CODE (type) == REAL_TYPE)
- error ("%<short%> invalid for %qs", name);
- else if ((long_p || short_p) && TREE_CODE (type) != INTEGER_TYPE)
- error ("%<long%> or %<short%> invalid for %qs", name);
- else if ((long_p || short_p || explicit_char || explicit_int) && explicit_intN)
- error ("%<long%>, %<int%>, %<short%>, or %<char%> invalid for %qs", name);
- else if ((long_p || short_p) && explicit_char)
- error ("%<long%> or %<short%> specified with char for %qs", name);
- else if (long_p && short_p)
- error ("%<long%> and %<short%> specified together for %qs", name);
- else if (type == char16_type_node || type == char32_type_node)
+ location_t loc;
+ const char *key;
+ if (unsigned_p)
{
- if (signed_p || unsigned_p)
- error ("%<signed%> or %<unsigned%> invalid for %qs", name);
- else if (short_p || long_p)
- error ("%<short%> or %<long%> invalid for %qs", name);
+ key = "unsigned";
+ loc = declspecs->locations[ds_unsigned];
}
- else
+ else if (signed_p)
+ {
+ key = "signed";
+ loc = declspecs->locations[ds_signed];
+ }
+ else if (longlong)
+ {
+ key = "long long";
+ loc = declspecs->locations[ds_long_long];
+ }
+ else if (long_p)
{
- ok = 1;
- if (!explicit_int && !defaulted_int && !explicit_char && !explicit_intN && pedantic)
+ key = "long";
+ loc = declspecs->locations[ds_long];
+ }
+ else /* if (short_p) */
+ {
+ key = "short";
+ loc = declspecs->locations[ds_short];
+ }
+
+ int ok = 0;
+
+ if (signed_p && unsigned_p)
+ error_at (loc, "%<signed%> and %<unsigned%> specified together");
+ else if (long_p && short_p)
+ error_at (loc, "%<long%> and %<short%> specified together");
+ else if (TREE_CODE (type) != INTEGER_TYPE
+ || type == char16_type_node || type == char32_type_node
+ || ((long_p || short_p)
+ && (explicit_char || explicit_intN)))
+ error_at (loc, "%qs specified with %qT", key, type);
+ else if (!explicit_int && !defaulted_int
+ && !explicit_char && !explicit_intN)
+ {
+ if (typedef_decl)
{
- pedwarn (input_location, OPT_Wpedantic,
- "long, short, signed or unsigned used invalidly for %qs",
- name);
- if (flag_pedantic_errors)
- ok = 0;
+ pedwarn (loc, OPT_Wpedantic, "%qs specified with %qT",
+ key, type);
+ ok = !flag_pedantic_errors;
}
+ else if (declspecs->decltype_p)
+ error_at (loc, "%qs specified with %<decltype%>", key);
+ else
+ error_at (loc, "%qs specified with %<typeof%>", key);
}
+ else
+ ok = 1;
/* Discard the type modifiers if they are invalid. */
if (! ok)