Patchwork C++ PATCH to make build_functional_cast call build_value_init unconditionally

login
register
mail settings
Submitter Jason Merrill
Date Aug. 23, 2011, 3:58 p.m.
Message ID <4E53CE1D.7060108@redhat.com>
Download mbox | patch
Permalink /patch/111139/
State New
Headers show

Comments

Jason Merrill - Aug. 23, 2011, 3:58 p.m.
The conditions for value-initialization of a class type have gotten more 
complicated, so we shouldn't try to duplicate them in the caller.

Tested x86_64-pc-linux-gnu, applying to trunk.

Patch

commit b45bd43f5bf3aceb81d467be40bc97bafacb5d1e
Author: Jason Merrill <jason@redhat.com>
Date:   Fri Aug 19 16:35:40 2011 -0400

    	* typeck2.c (build_functional_cast): Don't try to avoid calling
    	build_value_init.
    	* pt.c (instantiate_class_template_1): Don't copy TYPE_HAS_* flags.

diff --git a/gcc/cp/pt.c b/gcc/cp/pt.c
index 6b970f9..3c6b2c5 100644
--- a/gcc/cp/pt.c
+++ b/gcc/cp/pt.c
@@ -8503,16 +8503,6 @@  instantiate_class_template_1 (tree type)
   input_location = DECL_SOURCE_LOCATION (TYPE_NAME (type)) =
     DECL_SOURCE_LOCATION (typedecl);
 
-  TYPE_HAS_USER_CONSTRUCTOR (type) = TYPE_HAS_USER_CONSTRUCTOR (pattern);
-  TYPE_HAS_NEW_OPERATOR (type) = TYPE_HAS_NEW_OPERATOR (pattern);
-  TYPE_HAS_ARRAY_NEW_OPERATOR (type) = TYPE_HAS_ARRAY_NEW_OPERATOR (pattern);
-  TYPE_GETS_DELETE (type) = TYPE_GETS_DELETE (pattern);
-  TYPE_HAS_COPY_ASSIGN (type) = TYPE_HAS_COPY_ASSIGN (pattern);
-  TYPE_HAS_CONST_COPY_ASSIGN (type) = TYPE_HAS_CONST_COPY_ASSIGN (pattern);
-  TYPE_HAS_COPY_CTOR (type) = TYPE_HAS_COPY_CTOR (pattern);
-  TYPE_HAS_CONST_COPY_CTOR (type) = TYPE_HAS_CONST_COPY_CTOR (pattern);
-  TYPE_HAS_DEFAULT_CONSTRUCTOR (type) = TYPE_HAS_DEFAULT_CONSTRUCTOR (pattern);
-  TYPE_HAS_CONVERSION (type) = TYPE_HAS_CONVERSION (pattern);
   TYPE_PACKED (type) = TYPE_PACKED (pattern);
   TYPE_ALIGN (type) = TYPE_ALIGN (pattern);
   TYPE_USER_ALIGN (type) = TYPE_USER_ALIGN (pattern);
diff --git a/gcc/cp/typeck2.c b/gcc/cp/typeck2.c
index 97f98ab..901e4ee 100644
--- a/gcc/cp/typeck2.c
+++ b/gcc/cp/typeck2.c
@@ -1677,10 +1677,7 @@  build_functional_cast (tree exp, tree parms, tsubst_flags_t complain)
      void type, creates an rvalue of the specified type, which is
      value-initialized.  */
 
-  if (parms == NULL_TREE
-      /* If there's a user-defined constructor, value-initialization is
-	 just calling the constructor, so fall through.  */
-      && !TYPE_HAS_USER_CONSTRUCTOR (type))
+  if (parms == NULL_TREE)
     {
       exp = build_value_init (type, complain);
       exp = get_target_expr_sfinae (exp, complain);
diff --git a/gcc/testsuite/g++.dg/template/crash7.C b/gcc/testsuite/g++.dg/template/crash7.C
index 88d3af8..5bd275e 100644
--- a/gcc/testsuite/g++.dg/template/crash7.C
+++ b/gcc/testsuite/g++.dg/template/crash7.C
@@ -5,10 +5,11 @@ 
 // PR c++/10108: ICE in tsubst_decl for error due to non-existence
 // nested type.
 
-template <typename> struct A	// { dg-message "A.void.::A.const A" }
+template <typename> struct A
 {
     template <typename> A(typename A::X) {} // { dg-error "no type" }
 };
 
-A<void> a;	// { dg-error "required|no match" }
-// { dg-prune-output "note" }
+// We currently don't give the "no match" error because we don't add the
+// invalid constructor template to TYPE_METHODS.
+A<void> a;			// { dg-message "required" }