re PR c++/59838 (ICE with an enum using an incomplete type)
authorMarek Polacek <polacek@redhat.com>
Fri, 17 Jan 2014 15:23:17 +0000 (15:23 +0000)
committerMarek Polacek <mpolacek@gcc.gnu.org>
Fri, 17 Jan 2014 15:23:17 +0000 (15:23 +0000)
PR c++/59838
cp/
* cvt.c (ocp_convert): Don't segfault on non-existing
ENUM_UNDERLYING_TYPE.
testsuite/
* g++.dg/diagnostic/pr59838.C: New test.

From-SVN: r206716

gcc/cp/ChangeLog
gcc/cp/cvt.c
gcc/testsuite/ChangeLog
gcc/testsuite/g++.dg/diagnostic/pr59838.C [new file with mode: 0644]

index 848c406ecf4d86d30837f0b91b01c548c60c444f..66896d9aa135e61142cc9c70a231921638896614 100644 (file)
@@ -1,3 +1,9 @@
+2014-01-17  Marek Polacek  <polacek@redhat.com>
+
+       PR c++/59838
+       * cvt.c (ocp_convert): Don't segfault on non-existing
+       ENUM_UNDERLYING_TYPE.
+
 2014-01-16  Jason Merrill  <jason@redhat.com>
 
        PR c++/59821
index df208cc6876a2980386d2e3833c3f6ee32095f30..c2cdf833802cfb1b3ff452313b6c965d0026675e 100644 (file)
@@ -753,6 +753,7 @@ ocp_convert (tree type, tree expr, int convtype, int flags,
             unspecified.  */
          if ((complain & tf_warning)
              && TREE_CODE (e) == INTEGER_CST
+             && ENUM_UNDERLYING_TYPE (type)
              && !int_fits_type_p (e, ENUM_UNDERLYING_TYPE (type)))
            warning_at (loc, OPT_Wconversion, 
                        "the result of the conversion is unspecified because "
index a78e915bf780f4401f8920b930812b564a9c8ff7..6d57b4126885449a2a2cf0602f96350925f2eb63 100644 (file)
@@ -1,3 +1,8 @@
+2014-01-17  Marek Polacek  <polacek@redhat.com>
+
+       PR c++/59838
+       * g++.dg/diagnostic/pr59838.C: New test.
+
 2014-01-17  Marek Polacek  <polacek@redhat.com>
 
        PR c/58346
diff --git a/gcc/testsuite/g++.dg/diagnostic/pr59838.C b/gcc/testsuite/g++.dg/diagnostic/pr59838.C
new file mode 100644 (file)
index 0000000..d1cf2c7
--- /dev/null
@@ -0,0 +1,4 @@
+// PR c++/59838
+// { dg-do compile }
+
+enum E { a, b = (E) a }; // { dg-error "conversion to incomplete type" }