This is the mail archive of the
gcc-patches@gcc.gnu.org
mailing list for the GCC project.
C PATCH to fix ICE with -Wtraditional-conversion (PR c/79662)
- From: Marek Polacek <polacek at redhat dot com>
- To: GCC Patches <gcc-patches at gcc dot gnu dot org>, Joseph Myers <joseph at codesourcery dot com>
- Date: Wed, 22 Feb 2017 19:26:11 +0100
- Subject: C PATCH to fix ICE with -Wtraditional-conversion (PR c/79662)
- Authentication-results: sourceware.org; auth=none
We ICEd on the following test while warning for -Wtraditional-conversion
because at that point VAL had been turned into error_mark_node because we
require a complete type when converting arguments. Fixed by checking
for error_mark_node first so that we don't try to access it later with
TYPE_PRECISION and similar.
Bootstrapped/regtested on x86_64-linux, ok for trunk?
2017-02-22 Marek Polacek <polacek@redhat.com>
PR c/79662
* c-typeck.c (convert_arguments): Handle error_mark_node.
* gcc.dg/enum-incomplete-4.c: New test.
diff --git gcc/c/c-typeck.c gcc/c/c-typeck.c
index ed8ffe4..8c2c561 100644
--- gcc/c/c-typeck.c
+++ gcc/c/c-typeck.c
@@ -3437,15 +3437,18 @@ convert_arguments (location_t loc, vec<location_t> arg_loc, tree typelist,
/* Detect integer changing in width or signedness.
These warnings are only activated with
-Wtraditional-conversion, not with -Wtraditional. */
- else if (warn_traditional_conversion && INTEGRAL_TYPE_P (type)
+ else if (warn_traditional_conversion
+ && INTEGRAL_TYPE_P (type)
&& INTEGRAL_TYPE_P (valtype))
{
tree would_have_been = default_conversion (val);
tree type1 = TREE_TYPE (would_have_been);
- if (TREE_CODE (type) == ENUMERAL_TYPE
- && (TYPE_MAIN_VARIANT (type)
- == TYPE_MAIN_VARIANT (valtype)))
+ if (val == error_mark_node)
+ /* VAL could have been of incomplete type. */;
+ else if (TREE_CODE (type) == ENUMERAL_TYPE
+ && (TYPE_MAIN_VARIANT (type)
+ == TYPE_MAIN_VARIANT (valtype)))
/* No warning if function asks for enum
and the actual arg is that enum type. */
;
diff --git gcc/testsuite/gcc.dg/enum-incomplete-4.c gcc/testsuite/gcc.dg/enum-incomplete-4.c
index e69de29..03fb9f4 100644
--- gcc/testsuite/gcc.dg/enum-incomplete-4.c
+++ gcc/testsuite/gcc.dg/enum-incomplete-4.c
@@ -0,0 +1,11 @@
+/* PR c/79662 */
+/* { dg-do compile } */
+/* { dg-options "" } */
+
+extern enum e ve;
+
+int
+f0 (int i)
+{
+ f0 (ve); /* { dg-error "incomplete" } */
+}
Marek