re PR c/79662 (ICE on invalid code in convert_arguments in c/c-typeck.c:3452)
authorMarek Polacek <polacek@redhat.com>
Wed, 22 Feb 2017 21:28:42 +0000 (21:28 +0000)
committerMarek Polacek <mpolacek@gcc.gnu.org>
Wed, 22 Feb 2017 21:28:42 +0000 (21:28 +0000)
PR c/79662
* c-typeck.c (convert_arguments): Handle error_mark_node.

* gcc.dg/enum-incomplete-4.c: New test.

From-SVN: r245660

gcc/c/ChangeLog
gcc/c/c-typeck.c
gcc/testsuite/ChangeLog
gcc/testsuite/gcc.dg/enum-incomplete-4.c [new file with mode: 0644]

index 5cff63a24d1b5c791b62673c21ab819dc382ac7f..8283c827d8723038cd95e93f54a80761aa33401f 100644 (file)
@@ -1,3 +1,8 @@
+2017-02-22  Marek Polacek  <polacek@redhat.com>
+
+       PR c/79662
+       * c-typeck.c (convert_arguments): Handle error_mark_node.
+
 2017-02-19  Prathamesh Kulkarni  <prathamesh.kulkarni@linaro.org>
 
        * gimple-parser.c (c_parser_gimple_postfix_expression): Check return
index ed8ffe4c2e7269232b7c1037ab21c3bab66e7022..8c2c561eb72e48d65d9fec653e32cd26770d55bd 100644 (file)
@@ -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.  */
                        ;
index 31e7b4fb79e0ce753d7156128164e996cc1f8b04..6fae11a52e5e4517b3d8953a77ec9b9087afc234 100644 (file)
@@ -7,6 +7,9 @@
        PR c++/79657
        * g++.dg/ext/underlying_type12.C: New test.
 
+       PR c/79662
+       * gcc.dg/enum-incomplete-4.c: New test.
+
 2017-02-22  Jakub Jelinek  <jakub@redhat.com>
 
        PR target/70465
diff --git a/gcc/testsuite/gcc.dg/enum-incomplete-4.c b/gcc/testsuite/gcc.dg/enum-incomplete-4.c
new file mode 100644 (file)
index 0000000..03fb9f4
--- /dev/null
@@ -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" } */
+}