* [C++ Patch] PR 57947
@ 2013-07-30 13:16 Paolo Carlini
2013-07-30 13:36 ` Jason Merrill
0 siblings, 1 reply; 4+ messages in thread
From: Paolo Carlini @ 2013-07-30 13:16 UTC (permalink / raw)
To: gcc-patches; +Cc: Jason Merrill
[-- Attachment #1: Type: text/plain, Size: 465 bytes --]
Hi,
this issue, error recovery in C++98 mode, is a bit tricky: as far as I
can see, it boils down to the fact that in C++98 mode we don't want to
handle specially std::initializer_list. Otherwise, after the error
message we crash in convert_like_real where we try to handle ck_list, @
line 6056. With the below we emit the exact same diagnostic we emit for
init_list or any other non special name.
Tested x86_64-linux.
Thanks,
Paolo.
////////////////////
[-- Attachment #2: CL_57947 --]
[-- Type: text/plain, Size: 311 bytes --]
/cp
2013-07-30 Paolo Carlini <paolo.carlini@oracle.com>
PR c++/57947
* call.c (add_list_candidates): Only handle specially totype with
TYPE_HAS_LIST_CTOR (totype) set if cxx_dialect != cxx98.
/testsuite
2013-07-30 Paolo Carlini <paolo.carlini@oracle.com>
PR c++/57947
* g++.dg/parse/crash63.C: New.
[-- Attachment #3: patch_57947 --]
[-- Type: text/plain, Size: 1086 bytes --]
Index: cp/call.c
===================================================================
--- cp/call.c (revision 201331)
+++ cp/call.c (working copy)
@@ -3370,7 +3370,8 @@ add_list_candidates (tree fns, tree first_arg,
;
/* If the class has a list ctor, try passing the list as a single
argument first, but only consider list ctors. */
- else if (TYPE_HAS_LIST_CTOR (totype))
+ else if (TYPE_HAS_LIST_CTOR (totype)
+ && cxx_dialect != cxx98)
{
flags |= LOOKUP_LIST_ONLY;
args = make_tree_vector_single (init_list);
Index: testsuite/g++.dg/parse/crash63.C
===================================================================
--- testsuite/g++.dg/parse/crash63.C (revision 0)
+++ testsuite/g++.dg/parse/crash63.C (working copy)
@@ -0,0 +1,10 @@
+// PR c++/57947
+// { dg-options "-std=c++98" }
+
+namespace std
+{
+ template <class E> class initializer_list {};
+ template <int N> struct D { D(initializer_list<int>) {} };
+ D<0> d {1, 2, 3}; // { dg-error "constructor|no matching" }
+ // { dg-warning "initializer list" "" { target *-*-* } 8 }
+}
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [C++ Patch] PR 57947
2013-07-30 13:16 [C++ Patch] PR 57947 Paolo Carlini
@ 2013-07-30 13:36 ` Jason Merrill
2013-07-30 14:48 ` Paolo Carlini
0 siblings, 1 reply; 4+ messages in thread
From: Jason Merrill @ 2013-07-30 13:36 UTC (permalink / raw)
To: Paolo Carlini, gcc-patches
How about just returning false from is_std_init_list in C++98 mode?
Jason
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [C++ Patch] PR 57947
2013-07-30 13:36 ` Jason Merrill
@ 2013-07-30 14:48 ` Paolo Carlini
2013-07-30 16:49 ` Jason Merrill
0 siblings, 1 reply; 4+ messages in thread
From: Paolo Carlini @ 2013-07-30 14:48 UTC (permalink / raw)
To: Jason Merrill; +Cc: gcc-patches
[-- Attachment #1: Type: text/plain, Size: 180 bytes --]
Hi,
On 07/30/2013 03:30 PM, Jason Merrill wrote:
> How about just returning false from is_std_init_list in C++98 mode?
Sure. It works great.
Thanks,
Paolo.
////////////////////
[-- Attachment #2: CL_57947_2 --]
[-- Type: text/plain, Size: 254 bytes --]
/cp
2013-07-30 Paolo Carlini <paolo.carlini@oracle.com>
PR c++/57947
* call.c (is_std_init_list): Return false if cxx_dialect == cxx98.
/testsuite
2013-07-30 Paolo Carlini <paolo.carlini@oracle.com>
PR c++/57947
* g++.dg/parse/crash63.C: New.
[-- Attachment #3: patch_57947_2 --]
[-- Type: text/plain, Size: 965 bytes --]
Index: cp/call.c
===================================================================
--- cp/call.c (revision 201331)
+++ cp/call.c (working copy)
@@ -9396,6 +9396,8 @@ is_std_init_list (tree type)
/* Look through typedefs. */
if (!TYPE_P (type))
return false;
+ if (cxx_dialect == cxx98)
+ return false;
type = TYPE_MAIN_VARIANT (type);
return (CLASS_TYPE_P (type)
&& CP_TYPE_CONTEXT (type) == std_node
Index: testsuite/g++.dg/parse/crash63.C
===================================================================
--- testsuite/g++.dg/parse/crash63.C (revision 0)
+++ testsuite/g++.dg/parse/crash63.C (working copy)
@@ -0,0 +1,10 @@
+// PR c++/57947
+// { dg-options "-std=c++98" }
+
+namespace std
+{
+ template <class E> class initializer_list {};
+ template <int N> struct D { D(initializer_list<int>) {} };
+ D<0> d {1, 2, 3}; // { dg-error "constructor|no matching" }
+ // { dg-warning "initializer list" "" { target *-*-* } 8 }
+}
^ permalink raw reply [flat|nested] 4+ messages in thread
end of thread, other threads:[~2013-07-30 16:39 UTC | newest]
Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2013-07-30 13:16 [C++ Patch] PR 57947 Paolo Carlini
2013-07-30 13:36 ` Jason Merrill
2013-07-30 14:48 ` Paolo Carlini
2013-07-30 16:49 ` Jason Merrill
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).