re PR c++/47703 ([C++0x] ICE: std::sort chokes on simple lambda function)
authorJason Merrill <jason@redhat.com>
Sun, 20 Feb 2011 23:18:11 +0000 (18:18 -0500)
committerJason Merrill <jason@gcc.gnu.org>
Sun, 20 Feb 2011 23:18:11 +0000 (18:18 -0500)
PR c++/47703
* error.c (location_of): Handle non-tagged types.

From-SVN: r170349

gcc/cp/ChangeLog
gcc/cp/error.c
gcc/testsuite/ChangeLog
gcc/testsuite/g++.dg/overload/conv-op1.C [new file with mode: 0644]

index b867ef327bc92052fbfe857c21355658aa31280d..848765d2f92b7229463e1b97f0a5c30b9c889061 100644 (file)
@@ -1,5 +1,8 @@
 2011-02-20  Jason Merrill  <jason@redhat.com>
 
+       PR c++/47703
+       * error.c (location_of): Handle non-tagged types.
+
        PR c++/46472
        * method.c (process_subob_fn): Instantiate constexpr templates.
        * optimize.c (maybe_clone_body): Propagate DECL_DECLARED_CONSTEXPR_P.
index 3e91115ba9d32e336d2e8f56ed10193404921908..28305d222446f69d4a55e1226c9533942500cd30 100644 (file)
@@ -2493,7 +2493,11 @@ location_of (tree t)
   if (TREE_CODE (t) == PARM_DECL && DECL_CONTEXT (t))
     t = DECL_CONTEXT (t);
   else if (TYPE_P (t))
-    t = TYPE_MAIN_DECL (t);
+    {
+      t = TYPE_MAIN_DECL (t);
+      if (t == NULL_TREE)
+       return input_location;
+    }
   else if (TREE_CODE (t) == OVERLOAD)
     t = OVL_FUNCTION (t);
 
index 9eff5ffcd2f530c5632d05a706dbc657c198558f..91ef5f18d8ca1574b7a46eff425e3d86965c3377 100644 (file)
@@ -1,5 +1,7 @@
 2011-02-20  Jason Merrill  <jason@redhat.com>
 
+       * g++.dg/overload/conv-op1.C: New.
+
        * g++.dg/cpp0x/constexpr-synth1.C: New.
 
 2011-02-20  Nicola Pero  <nicola.pero@meta-innovation.com>
diff --git a/gcc/testsuite/g++.dg/overload/conv-op1.C b/gcc/testsuite/g++.dg/overload/conv-op1.C
new file mode 100644 (file)
index 0000000..6a63cba
--- /dev/null
@@ -0,0 +1,17 @@
+// PR c++/47703
+
+typedef void (*pfn)(int &);
+
+struct A
+{
+  operator pfn() { return 0; }
+};
+
+void f()
+{
+  const int i = 42;
+  A()(i);                      // { dg-message "<conversion>" }
+}
+
+// { dg-prune-output "no match" }
+// { dg-prune-output "candidate" }