From: Andrew Pinski Date: Thu, 21 Mar 2024 23:29:20 +0000 (-0700) Subject: Another ICE after conflicting types of redeclaration [PR109619] X-Git-Tag: basepoints/gcc-15~526 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=dbe9062ce070c861cd3fa6435187618413b1b3d1;p=thirdparty%2Fgcc.git Another ICE after conflicting types of redeclaration [PR109619] This another one of these ICE after error issues with the gimplifier and a fallout from r12-3278-g823685221de986af. This case happens when we are trying to fold memcpy/memmove. There is already code to try to catch ERROR_MARKs as arguments to the builtins so just need to change them to use error_operand_p which checks the type of the expression to see if it was an error mark also. Bootstrapped and tested on x86_64-linux-gnu with no regressions. gcc/ChangeLog: PR c/109619 * builtins.cc (fold_builtin_1): Use error_operand_p instead of checking against ERROR_MARK. (fold_builtin_2): Likewise. (fold_builtin_3): Likewise. gcc/testsuite/ChangeLog: PR c/109619 * gcc.dg/redecl-26.c: New test. Signed-off-by: Andrew Pinski --- diff --git a/gcc/builtins.cc b/gcc/builtins.cc index eda8bea9c4be..bb74b5cbcd6f 100644 --- a/gcc/builtins.cc +++ b/gcc/builtins.cc @@ -10461,7 +10461,7 @@ fold_builtin_1 (location_t loc, tree expr, tree fndecl, tree arg0) tree type = TREE_TYPE (TREE_TYPE (fndecl)); enum built_in_function fcode = DECL_FUNCTION_CODE (fndecl); - if (TREE_CODE (arg0) == ERROR_MARK) + if (error_operand_p (arg0)) return NULL_TREE; if (tree ret = fold_const_call (as_combined_fn (fcode), type, arg0)) @@ -10601,8 +10601,8 @@ fold_builtin_2 (location_t loc, tree expr, tree fndecl, tree arg0, tree arg1) tree type = TREE_TYPE (TREE_TYPE (fndecl)); enum built_in_function fcode = DECL_FUNCTION_CODE (fndecl); - if (TREE_CODE (arg0) == ERROR_MARK - || TREE_CODE (arg1) == ERROR_MARK) + if (error_operand_p (arg0) + || error_operand_p (arg1)) return NULL_TREE; if (tree ret = fold_const_call (as_combined_fn (fcode), type, arg0, arg1)) @@ -10693,9 +10693,9 @@ fold_builtin_3 (location_t loc, tree fndecl, tree type = TREE_TYPE (TREE_TYPE (fndecl)); enum built_in_function fcode = DECL_FUNCTION_CODE (fndecl); - if (TREE_CODE (arg0) == ERROR_MARK - || TREE_CODE (arg1) == ERROR_MARK - || TREE_CODE (arg2) == ERROR_MARK) + if (error_operand_p (arg0) + || error_operand_p (arg1) + || error_operand_p (arg2)) return NULL_TREE; if (tree ret = fold_const_call (as_combined_fn (fcode), type, diff --git a/gcc/testsuite/gcc.dg/redecl-26.c b/gcc/testsuite/gcc.dg/redecl-26.c new file mode 100644 index 000000000000..5f8889c4c396 --- /dev/null +++ b/gcc/testsuite/gcc.dg/redecl-26.c @@ -0,0 +1,14 @@ +/* We used to ICE while folding memcpy and memmove. + PR c/109619. */ +/* { dg-do compile } */ +/* { dg-options "" } */ + +int *a1, *a2; + +void foo(__SIZE_TYPE__ a3) /* { dg-note "" } */ +{ + __builtin_memcpy(a1, a2, a3); + __builtin_memmove(a1, a2, a3); + int *a3; /* { dg-error "redeclared as different kind of symbol" } */ +} +