public inbox for gcc-patches@gcc.gnu.org
 help / color / mirror / Atom feed
* RFC (DECL_CONSTRUCTOR_P): C++ PATCH for c++/83911, ICE with multiversioned constructor
@ 2018-02-16 22:48 Jason Merrill
  2018-02-16 23:41 ` Nathan Sidwell
  2018-02-17 19:15 ` Nathan Sidwell
  0 siblings, 2 replies; 3+ messages in thread
From: Jason Merrill @ 2018-02-16 22:48 UTC (permalink / raw)
  To: Nathan Sidwell; +Cc: gcc-patches List

[-- Attachment #1: Type: text/plain, Size: 475 bytes --]

We hit the bug in this testcase because build_over_call replaces the
constructor with a dispatcher function, and then build_aggr_init_expr
doesn't recognize it as a constructor.

Messing with the DECL_NAME of the dispatcher seems messy, but copying
the DECL_CXX_CONSTRUCTOR_P flag is easy.  So we can change the test in
build_aggr_init_expr, or change the definition of DECL_CONSTRUCTOR_P.
I lean toward the latter as more uniform, but not strongly.  Do you
have an opinion?

[-- Attachment #2: 83911.diff --]
[-- Type: text/plain, Size: 2880 bytes --]

commit 8bc517d8acbb898aa7776c420e2ba65cc5f8d31a
Author: Jason Merrill <jason@redhat.com>
Date:   Fri Feb 16 16:53:47 2018 -0500

            PR c++/83911 - ICE with multiversioned constructor.
    
            * cp-tree.h (DECL_CONSTRUCTOR_P): Use DECL_CXX_CONSTRUCTOR_P.
            (DECL_DESTRUCTOR_P): Use DECL_CXX_DESTRUCTOR_P.
            * mangle.c (write_unqualified_name): Check IDENTIFIER_[CD]TOR_P.
            * call.c (get_function_version_dispatcher): Copy
            DECL_CXX_CONSTRUCTOR_P.

diff --git a/gcc/cp/call.c b/gcc/cp/call.c
index 7c93c6d8290..35496528aa6 100644
--- a/gcc/cp/call.c
+++ b/gcc/cp/call.c
@@ -7489,7 +7489,10 @@ get_function_version_dispatcher (tree fn)
     }
 
   retrofit_lang_decl (dispatcher_decl);
-  gcc_assert (dispatcher_decl != NULL);
+
+  if (DECL_CXX_CONSTRUCTOR_P (fn))
+    DECL_CXX_CONSTRUCTOR_P (dispatcher_decl) = true;
+
   return dispatcher_decl;
 }
 
diff --git a/gcc/cp/cp-tree.h b/gcc/cp/cp-tree.h
index 9038d677b2d..77ae2e94187 100644
--- a/gcc/cp/cp-tree.h
+++ b/gcc/cp/cp-tree.h
@@ -2695,7 +2695,7 @@ struct GTY(()) lang_decl {
 /* For FUNCTION_DECLs and TEMPLATE_DECLs: nonzero means that this function
    is a constructor.  */
 #define DECL_CONSTRUCTOR_P(NODE) \
-  IDENTIFIER_CTOR_P (DECL_NAME (NODE))
+  DECL_CXX_CONSTRUCTOR_P (STRIP_TEMPLATE (NODE))
 
 /* Nonzero if NODE (a FUNCTION_DECL) is a constructor for a complete
    object.  */
@@ -2724,7 +2724,7 @@ struct GTY(()) lang_decl {
 /* Nonzero if NODE (a FUNCTION_DECL or TEMPLATE_DECL)
    is a destructor.  */
 #define DECL_DESTRUCTOR_P(NODE)				\
-  IDENTIFIER_DTOR_P (DECL_NAME (NODE))
+  DECL_CXX_DESTRUCTOR_P (STRIP_TEMPLATE (NODE))
 
 /* Nonzero if NODE (a FUNCTION_DECL) is a destructor, but not the
    specialized in-charge constructor, in-charge deleting constructor,
diff --git a/gcc/cp/mangle.c b/gcc/cp/mangle.c
index 94c4bed2848..ecd4eb066d4 100644
--- a/gcc/cp/mangle.c
+++ b/gcc/cp/mangle.c
@@ -1351,9 +1351,9 @@ write_unqualified_name (tree decl)
   else if (DECL_DECLARES_FUNCTION_P (decl))
     {
       found = true;
-      if (DECL_CONSTRUCTOR_P (decl))
+      if (IDENTIFIER_CTOR_P (DECL_NAME (decl)))
 	write_special_name_constructor (decl);
-      else if (DECL_DESTRUCTOR_P (decl))
+      else if (IDENTIFIER_DTOR_P (DECL_NAME (decl)))
 	write_special_name_destructor (decl);
       else if (DECL_CONV_FN_P (decl))
 	{
diff --git a/gcc/testsuite/g++.dg/ext/mv27.C b/gcc/testsuite/g++.dg/ext/mv27.C
new file mode 100644
index 00000000000..443a54be765
--- /dev/null
+++ b/gcc/testsuite/g++.dg/ext/mv27.C
@@ -0,0 +1,18 @@
+// PR c++/83911
+// { dg-do compile { target i?86-*-* x86_64-*-* } }
+// { dg-require-ifunc "" }
+
+class SimdFloat
+{
+public:
+    __attribute__ ((target ("default")))
+    SimdFloat(float x) {}
+
+    __attribute__ ((target ("avx2")))
+    SimdFloat(float x) {}
+};
+
+SimdFloat foo()
+{
+    return 1;
+}

^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: RFC (DECL_CONSTRUCTOR_P): C++ PATCH for c++/83911, ICE with multiversioned constructor
  2018-02-16 22:48 RFC (DECL_CONSTRUCTOR_P): C++ PATCH for c++/83911, ICE with multiversioned constructor Jason Merrill
@ 2018-02-16 23:41 ` Nathan Sidwell
  2018-02-17 19:15 ` Nathan Sidwell
  1 sibling, 0 replies; 3+ messages in thread
From: Nathan Sidwell @ 2018-02-16 23:41 UTC (permalink / raw)
  To: Jason Merrill; +Cc: gcc-patches List

On 02/16/2018 05:48 PM, Jason Merrill wrote:
> We hit the bug in this testcase because build_over_call replaces the
> constructor with a dispatcher function, and then build_aggr_init_expr
> doesn't recognize it as a constructor.
> 
> Messing with the DECL_NAME of the dispatcher seems messy, but copying
> the DECL_CXX_CONSTRUCTOR_P flag is easy.  So we can change the test in
> build_aggr_init_expr, or change the definition of DECL_CONSTRUCTOR_P.
> I lean toward the latter as more uniform, but not strongly.  Do you
> have an opinion?

Using the ctor name for the dispatcher doesn't seem wonky to me -- it is after 
all a constructor.  But then I've not looked at the code.  Might be bored in 
airports tomorrow ...  If I fail to respond, go with your approach.

nathan

-- 
Nathan Sidwell

^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: RFC (DECL_CONSTRUCTOR_P): C++ PATCH for c++/83911, ICE with multiversioned constructor
  2018-02-16 22:48 RFC (DECL_CONSTRUCTOR_P): C++ PATCH for c++/83911, ICE with multiversioned constructor Jason Merrill
  2018-02-16 23:41 ` Nathan Sidwell
@ 2018-02-17 19:15 ` Nathan Sidwell
  1 sibling, 0 replies; 3+ messages in thread
From: Nathan Sidwell @ 2018-02-17 19:15 UTC (permalink / raw)
  To: Jason Merrill; +Cc: gcc-patches List

On 02/16/2018 05:48 PM, Jason Merrill wrote:
> We hit the bug in this testcase because build_over_call replaces the
> constructor with a dispatcher function, and then build_aggr_init_expr
> doesn't recognize it as a constructor.
> 
> Messing with the DECL_NAME of the dispatcher seems messy, but copying
> the DECL_CXX_CONSTRUCTOR_P flag is easy.  So we can change the test in
> build_aggr_init_expr, or change the definition of DECL_CONSTRUCTOR_P.
> I lean toward the latter as more uniform, but not strongly.  Do you
> have an opinion?

Yeah, I think copying DECL_CXX_CONSTRUCTOR_P is the right approach.  I wondered 
about dtors, operator fns and conversion fns.  They also rely on identifier flags.

dtors ICEs add_method (feel free to file a defect and assign to me).  assignment 
operator seems ok.  That assop is ok, suggests the change to mangle.c isn;t 
needed -- we mangle the name early enough?

[We could move CXX_{CON,DE}STRUCTOR_P functionality into the operator 
enumeration to free up a couple of flags, but that's definitely a stage 1 change]

nathan
-- 
Nathan Sidwell

^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2018-02-17 19:15 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2018-02-16 22:48 RFC (DECL_CONSTRUCTOR_P): C++ PATCH for c++/83911, ICE with multiversioned constructor Jason Merrill
2018-02-16 23:41 ` Nathan Sidwell
2018-02-17 19:15 ` Nathan Sidwell

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).