From 06be49223f63ea7f3cf57146cc580fc1ee73d619 Mon Sep 17 00:00:00 2001 From: Jason Merrill Date: Sun, 20 Feb 2011 18:18:11 -0500 Subject: re PR c++/47703 ([C++0x] ICE: std::sort chokes on simple lambda function) PR c++/47703 * error.c (location_of): Handle non-tagged types. From-SVN: r170349 --- gcc/cp/ChangeLog | 3 +++ gcc/cp/error.c | 6 +++++- gcc/testsuite/ChangeLog | 2 ++ gcc/testsuite/g++.dg/overload/conv-op1.C | 17 +++++++++++++++++ 4 files changed, 27 insertions(+), 1 deletion(-) create mode 100644 gcc/testsuite/g++.dg/overload/conv-op1.C (limited to 'gcc') diff --git a/gcc/cp/ChangeLog b/gcc/cp/ChangeLog index b867ef3..848765d 100644 --- a/gcc/cp/ChangeLog +++ b/gcc/cp/ChangeLog @@ -1,5 +1,8 @@ 2011-02-20 Jason Merrill + 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. diff --git a/gcc/cp/error.c b/gcc/cp/error.c index 3e91115..28305d2 100644 --- a/gcc/cp/error.c +++ b/gcc/cp/error.c @@ -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); diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog index 9eff5ff..91ef5f1 100644 --- a/gcc/testsuite/ChangeLog +++ b/gcc/testsuite/ChangeLog @@ -1,5 +1,7 @@ 2011-02-20 Jason Merrill + * g++.dg/overload/conv-op1.C: New. + * g++.dg/cpp0x/constexpr-synth1.C: New. 2011-02-20 Nicola Pero diff --git a/gcc/testsuite/g++.dg/overload/conv-op1.C b/gcc/testsuite/g++.dg/overload/conv-op1.C new file mode 100644 index 0000000..6a63cba --- /dev/null +++ b/gcc/testsuite/g++.dg/overload/conv-op1.C @@ -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 "" } +} + +// { dg-prune-output "no match" } +// { dg-prune-output "candidate" } -- cgit v1.1