re PR c++/54207 ([C++0x] ICE in build_noexcept_spec when bool is #defined/typedef'd)
authorJakub Jelinek <jakub@redhat.com>
Thu, 6 Dec 2012 18:55:48 +0000 (19:55 +0100)
committerJakub Jelinek <jakub@gcc.gnu.org>
Thu, 6 Dec 2012 18:55:48 +0000 (19:55 +0100)
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.

From-SVN: r194263

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]

index 23a0a92..d228fe2 100644 (file)
@@ -1,3 +1,12 @@
+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-06  Marc Glisse  <marc.glisse@inria.fr>
 
        PR c++/55573
index cbb0235..3689566 100644 (file)
@@ -1316,15 +1316,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 c1e12f0..8b0ead1 100644 (file)
@@ -10844,7 +10844,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 c7262f4..abddd4d 100644 (file)
@@ -1871,7 +1871,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 (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 1912926..9b6462d 100644 (file)
@@ -1,10 +1,11 @@
 2012-12-06  Jakub Jelinek  <jakub@redhat.com>
 
+       PR c++/54207
+       * g++.dg/cpp0x/noexcept18.C: New test.
+
        PR c++/55573
        * g++.dg/cpp0x/constexpr-55573.C: New test.
 
-2012-12-06  Jakub Jelinek  <jakub@redhat.com>
-
        PR c++/55137
        * g++.dg/opt/pr55137.C: New test.
        * gcc.c-torture/execute/pr55137.c: New test.
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 ())
+{
+}