We ICEd on invalid testcases with auto, because lookup_conversions
got template_type_parm as a parameter and the TYPE_BINFO didn't like
it.  Fixed by checking for RECORD_OR_UNION_TYPE_P first.

Regtested/bootstrapped on x86_64-linux, ok for trunk?

2013-12-20  Marek Polacek  <pola...@redhat.com>

        PR c++/59111
cp/
        * search.c (lookup_conversions): Return NULL_TREE if
        !RECORD_OR_UNION_TYPE_P.
testsuite/
        * g++.dg/cpp0x/pr59111.C: New test.
        * g++.dg/cpp1y/pr59110.C: New test.

--- gcc/cp/search.c.mp  2013-12-20 15:04:51.296753249 +0100
+++ gcc/cp/search.c     2013-12-20 15:04:55.552768259 +0100
@@ -2506,7 +2506,7 @@ lookup_conversions (tree type)
   tree list = NULL_TREE;
 
   complete_type (type);
-  if (!TYPE_BINFO (type))
+  if (!RECORD_OR_UNION_TYPE_P (type) || !TYPE_BINFO (type))
     return NULL_TREE;
 
   lookup_conversions_r (TYPE_BINFO (type), 0, 0,
--- gcc/testsuite/g++.dg/cpp0x/pr59111.C.mp     2013-12-20 14:44:16.871202015 
+0100
+++ gcc/testsuite/g++.dg/cpp0x/pr59111.C        2013-12-20 14:49:48.888403724 
+0100
@@ -0,0 +1,5 @@
+// PR c++/59111
+// { dg-do compile { target c++11 } }
+
+auto& foo();   // { dg-error "type specifier without trailing return type" }
+int i = foo(); // { dg-error "cannot convert" }
--- gcc/testsuite/g++.dg/cpp1y/pr59110.C.mp     2013-12-20 14:51:17.402737711 
+0100
+++ gcc/testsuite/g++.dg/cpp1y/pr59110.C        2013-12-20 14:58:08.988234451 
+0100
@@ -0,0 +1,4 @@
+// PR c++/59110
+// { dg-options "-std=c++1y" }
+
+int i = *(auto*)0; // { dg-error "cannot convert" }

        Marek

Reply via email to