OSDN Git Service

PR c++/50024
authorjason <jason@138bc75d-0d04-0410-961f-82ee72b054a4>
Tue, 23 Aug 2011 20:12:22 +0000 (20:12 +0000)
committerjason <jason@138bc75d-0d04-0410-961f-82ee72b054a4>
Tue, 23 Aug 2011 20:12:22 +0000 (20:12 +0000)
* semantics.c (maybe_constant_value): Don't try to fold { }.
* pt.c (build_non_dependent_expr): Don't wrap { }.
* init.c (build_value_init): Allow scalar value-init in templates.

git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/branches/gcc-4_6-branch@178012 138bc75d-0d04-0410-961f-82ee72b054a4

gcc/cp/ChangeLog
gcc/cp/init.c
gcc/cp/pt.c
gcc/cp/semantics.c
gcc/testsuite/ChangeLog
gcc/testsuite/g++.dg/cpp0x/constexpr-initlist5.C [new file with mode: 0644]

index aae8026..da42ab4 100644 (file)
@@ -1,3 +1,10 @@
+2011-08-23  Jason Merrill  <jason@redhat.com>
+
+       PR c++/50024
+       * semantics.c (maybe_constant_value): Don't try to fold { }.
+       * pt.c (build_non_dependent_expr): Don't wrap { }.
+       * init.c (build_value_init): Allow scalar value-init in templates.
+
 2011-08-23  Jakub Jelinek  <jakub@redhat.com>
 
        PR c++/46862
index 8c2b168..ec3cfe4 100644 (file)
@@ -332,7 +332,7 @@ build_value_init (tree type, tsubst_flags_t complain)
      constructor.  */
 
   /* The AGGR_INIT_EXPR tweaking below breaks in templates.  */
-  gcc_assert (!processing_template_decl);
+  gcc_assert (!processing_template_decl || SCALAR_TYPE_P (type));
 
   if (CLASS_TYPE_P (type))
     {
index 8c0caaf..40de93b 100644 (file)
@@ -18909,6 +18909,10 @@ build_non_dependent_expr (tree expr)
   if (TREE_CODE (expr) == THROW_EXPR)
     return expr;
 
+  /* Don't wrap an initializer list, we need to be able to look inside.  */
+  if (BRACE_ENCLOSED_INITIALIZER_P (expr))
+    return expr;
+
   if (TREE_CODE (expr) == COND_EXPR)
     return build3 (COND_EXPR,
                   TREE_TYPE (expr),
index b96908a..e2a3c39 100644 (file)
@@ -7300,6 +7300,7 @@ maybe_constant_value (tree t)
 
   if (type_dependent_expression_p (t)
       || type_unknown_p (t)
+      || BRACE_ENCLOSED_INITIALIZER_P (t)
       || !potential_constant_expression (t)
       || value_dependent_expression_p (t))
     return t;
index 11cac8f..98c14ca 100644 (file)
@@ -1,3 +1,8 @@
+2011-08-23  Jason Merrill  <jason@redhat.com>
+
+       PR c++/50024
+       * g++.dg/cpp0x/constexpr-initlist5.C: New.
+
 2011-08-23  Jakub Jelinek  <jakub@redhat.com>
 
        PR c++/46862
diff --git a/gcc/testsuite/g++.dg/cpp0x/constexpr-initlist5.C b/gcc/testsuite/g++.dg/cpp0x/constexpr-initlist5.C
new file mode 100644 (file)
index 0000000..97f0399
--- /dev/null
@@ -0,0 +1,15 @@
+// PR c++/50024
+// { dg-options -std=c++0x }
+
+template< class T >
+struct Container
+{
+  Container(){
+    int* ptr = new int{};
+  }
+};
+
+int main() {
+    Container< int > c;
+}
+