aboutsummaryrefslogtreecommitdiff
path: root/gcc/c/c-parser.cc
diff options
context:
space:
mode:
authorJakub Jelinek <jakub@redhat.com>2024-02-26 16:30:16 +0100
committerJakub Jelinek <jakub@redhat.com>2024-02-26 16:30:16 +0100
commit77576915cfd26e603aba5295dfdac54a5545f5f2 (patch)
tree02588076aef2e17a4c41db23cb45a02a074a5ae2 /gcc/c/c-parser.cc
parent10c73c111652208c5f9dc63a52933f4d6550cadd (diff)
downloadgcc-77576915cfd26e603aba5295dfdac54a5545f5f2.zip
gcc-77576915cfd26e603aba5295dfdac54a5545f5f2.tar.gz
gcc-77576915cfd26e603aba5295dfdac54a5545f5f2.tar.bz2
c: Improve some diagnostics for __builtin_stdc_bit_* [PR114042]
The PR complains that for the __builtin_stdc_bit_* "builtins" the diagnostics doesn't mention the name of the builtin the user used, but instead __builtin_{clz,ctz,popcount}g instead (which is what the FE immediately lowers it to). The following patch repeats the checks from check_builtin_function_arguments which are there done on BUILT_IN_{CLZ,CTZ,POPCOUNT}G, such that they diagnose it with the name of the "builtin" user actually used before it is gone. 2024-02-26 Jakub Jelinek <jakub@redhat.com> PR c/114042 * c-parser.cc (c_parser_postfix_expression): Diagnose __builtin_stdc_bit_* argument with ENUMERAL_TYPE or BOOLEAN_TYPE type or if signed here rather than on the replacement builtins in check_builtin_function_arguments. * gcc.dg/builtin-stdc-bit-2.c: Adjust testcase for actual builtin names rather than names of builtin replacements.
Diffstat (limited to 'gcc/c/c-parser.cc')
-rw-r--r--gcc/c/c-parser.cc21
1 files changed, 21 insertions, 0 deletions
diff --git a/gcc/c/c-parser.cc b/gcc/c/c-parser.cc
index 8019e60..53e99aa 100644
--- a/gcc/c/c-parser.cc
+++ b/gcc/c/c-parser.cc
@@ -11859,6 +11859,27 @@ c_parser_postfix_expression (c_parser *parser)
expr.set_error ();
break;
}
+ if (TREE_CODE (TREE_TYPE (arg_p->value)) == ENUMERAL_TYPE)
+ {
+ error_at (loc, "argument %u in call to function "
+ "%qs has enumerated type", 1, name);
+ expr.set_error ();
+ break;
+ }
+ if (TREE_CODE (TREE_TYPE (arg_p->value)) == BOOLEAN_TYPE)
+ {
+ error_at (loc, "argument %u in call to function "
+ "%qs has boolean type", 1, name);
+ expr.set_error ();
+ break;
+ }
+ if (!TYPE_UNSIGNED (TREE_TYPE (arg_p->value)))
+ {
+ error_at (loc, "argument 1 in call to function "
+ "%qs has signed type", name);
+ expr.set_error ();
+ break;
+ }
tree arg = arg_p->value;
tree type = TYPE_MAIN_VARIANT (TREE_TYPE (arg));
/* Expand: