OSDN Git Service

Backported from mainline
authorjakub <jakub@138bc75d-0d04-0410-961f-82ee72b054a4>
Fri, 1 Feb 2013 14:05:42 +0000 (14:05 +0000)
committerjakub <jakub@138bc75d-0d04-0410-961f-82ee72b054a4>
Fri, 1 Feb 2013 14:05:42 +0000 (14:05 +0000)
2012-12-13  Jakub Jelinek  <jakub@redhat.com>

PR c++/55652
* typeck2.c (merge_exception_specifiers): Don't call operand_equal_p
if noex is NULL.

* g++.dg/cpp0x/noexcept19.C: New test.

2012-12-06  Jakub Jelinek  <jakub@redhat.com>

PR c++/54207
* except.c (build_noexcept_spec): Avoid direct comparison
with boolean_true_node or boolean_false_node, instead use
operand_equal_p and/or INTEGER_CST check.
* pt.c (tsubst_exception_specification): Likewise.
* typeck2.c (merge_exception_specifiers): Likewise.

* g++.dg/cpp0x/noexcept18.C: New test.

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

gcc/cp/ChangeLog
gcc/cp/except.c
gcc/cp/pt.c
gcc/cp/typeck2.c
gcc/testsuite/ChangeLog
gcc/testsuite/g++.dg/cpp0x/noexcept18.C [new file with mode: 0644]
gcc/testsuite/g++.dg/cpp0x/noexcept19.C [new file with mode: 0644]

index 017bc9f..c3a28f5 100644 (file)
@@ -1,6 +1,21 @@
 2013-02-01  Jakub Jelinek  <jakub@redhat.com>
 
        Backported from mainline
+       2012-12-13  Jakub Jelinek  <jakub@redhat.com>
+
+       PR c++/55652
+       * typeck2.c (merge_exception_specifiers): Don't call operand_equal_p
+       if noex is NULL.
+
+       2012-12-06  Jakub Jelinek  <jakub@redhat.com>
+
+       PR c++/54207
+       * except.c (build_noexcept_spec): Avoid direct comparison
+       with boolean_true_node or boolean_false_node, instead use
+       operand_equal_p and/or INTEGER_CST check.
+       * pt.c (tsubst_exception_specification): Likewise.
+       * typeck2.c (merge_exception_specifiers): Likewise.
+
        2012-12-01  Jakub Jelinek  <jakub@redhat.com>
 
        PR c++/55542
index c56dc2c..f7a1c7e 100644 (file)
@@ -1302,15 +1302,21 @@ build_noexcept_spec (tree expr, int complain)
                                                LOOKUP_NORMAL);
       expr = cxx_constant_value (expr);
     }
-  if (expr == boolean_true_node)
-    return noexcept_true_spec;
-  else if (expr == boolean_false_node)
-    return noexcept_false_spec;
+  if (TREE_CODE (expr) == INTEGER_CST)
+    {
+      if (operand_equal_p (expr, boolean_true_node, 0))
+       return noexcept_true_spec;
+      else
+       {
+         gcc_checking_assert (operand_equal_p (expr, boolean_false_node, 0));
+         return noexcept_false_spec;
+       }
+    }
   else if (expr == error_mark_node)
     return error_mark_node;
   else
     {
-      gcc_assert (processing_template_decl || expr == error_mark_node
+      gcc_assert (processing_template_decl
                  || TREE_CODE (expr) == DEFERRED_NOEXCEPT);
       return build_tree_list (expr, NULL_TREE);
     }
index 4f37840..4cadda8 100644 (file)
@@ -10737,7 +10737,7 @@ tsubst_exception_specification (tree fntype,
     {
       /* A noexcept-specifier.  */
       tree expr = TREE_PURPOSE (specs);
-      if (expr == boolean_true_node || expr == boolean_false_node)
+      if (TREE_CODE (expr) == INTEGER_CST)
        new_specs = expr;
       else if (defer_ok)
        {
index f9ac28b..ce6de16 100644 (file)
@@ -1855,7 +1855,7 @@ merge_exception_specifiers (tree list, tree add, tree fn)
       /* If ADD is a deferred noexcept, we must have been called from
         process_subob_fn.  For implicitly declared functions, we build up
         a list of functions to consider at instantiation time.  */
-      if (noex == boolean_true_node)
+      if (noex && operand_equal_p (noex, boolean_true_node, 0))
        noex = NULL_TREE;
       gcc_assert (fn && (!noex || is_overloaded_fn (noex)));
       noex = build_overload (fn, noex);
index b6e47a3..6bc67e2 100644 (file)
@@ -1,6 +1,16 @@
 2013-02-01  Jakub Jelinek  <jakub@redhat.com>
 
        Backported from mainline
+       2012-12-13  Jakub Jelinek  <jakub@redhat.com>
+
+       PR c++/55652
+       * g++.dg/cpp0x/noexcept19.C: New test.
+
+       2012-12-06  Jakub Jelinek  <jakub@redhat.com>
+
+       PR c++/54207
+       * g++.dg/cpp0x/noexcept18.C: New test.
+
        2012-12-01  Jakub Jelinek  <jakub@redhat.com>
 
        PR c++/55542
diff --git a/gcc/testsuite/g++.dg/cpp0x/noexcept18.C b/gcc/testsuite/g++.dg/cpp0x/noexcept18.C
new file mode 100644 (file)
index 0000000..953fb0e
--- /dev/null
@@ -0,0 +1,11 @@
+// PR c++/54207
+// { dg-do compile }
+// { dg-options "-std=c++11" }
+
+typedef bool B;
+constexpr B foo () { return true; }
+
+void
+bar () noexcept (foo ())
+{
+}
diff --git a/gcc/testsuite/g++.dg/cpp0x/noexcept19.C b/gcc/testsuite/g++.dg/cpp0x/noexcept19.C
new file mode 100644 (file)
index 0000000..12ff86e
--- /dev/null
@@ -0,0 +1,29 @@
+// PR c++/55652
+// { dg-do compile }
+// { dg-options "-std=c++11" }
+
+template <typename T>
+struct A
+{
+  static const bool a = false;
+};
+
+template <typename X, typename Y = A <X>>
+struct B
+{
+  B () noexcept (A <Y>::a) {}
+};
+
+template <typename X, typename Y>
+struct C
+{
+  X x;
+  Y y;
+};
+
+struct D
+{
+  D () throw (int);
+};
+
+C <D, B <D>> c;