]> git.ipfire.org Git - thirdparty/gcc.git/commitdiff
re PR c++/60254 ([c++11] ICE with non-const expression in static_assert)
authorPaolo Carlini <paolo.carlini@oracle.com>
Thu, 13 Mar 2014 09:51:52 +0000 (09:51 +0000)
committerPaolo Carlini <paolo@gcc.gnu.org>
Thu, 13 Mar 2014 09:51:52 +0000 (09:51 +0000)
/cp
2014-03-13  Paolo Carlini  <paolo.carlini@oracle.com>

PR c++/60254
* semantics.c (finish_static_assert): Call cxx_constant_value only
if require_potential_rvalue_constant_expression returns true.

/testsuite
2014-03-13  Paolo Carlini  <paolo.carlini@oracle.com>

PR c++/60254
* g++.dg/cpp0x/static_assert10.C: New.
* g++.dg/cpp0x/static_assert11.C: Likewise.
* g++.dg/cpp0x/static_assert3.C: Adjust.

From-SVN: r208538

gcc/cp/ChangeLog
gcc/cp/semantics.c
gcc/testsuite/ChangeLog
gcc/testsuite/g++.dg/cpp0x/static_assert10.C [new file with mode: 0644]
gcc/testsuite/g++.dg/cpp0x/static_assert11.C [new file with mode: 0644]
gcc/testsuite/g++.dg/cpp0x/static_assert3.C

index 4848b54223ff5f1dfb740e41dda891f28c928e05..e5732f2d490ea0af007c34af920a5a5c3f4a9434 100644 (file)
@@ -1,3 +1,9 @@
+2014-03-13  Paolo Carlini  <paolo.carlini@oracle.com>
+
+       PR c++/60254
+       * semantics.c (finish_static_assert): Call cxx_constant_value only
+       if require_potential_rvalue_constant_expression returns true.
+
 2014-03-11  Paolo Carlini  <paolo.carlini@oracle.com>
 
        PR c++/60389
index 1c9e153e3e32b7818fa097fcc054c51b27f24efe..886fbb88bc94b05ff9bf5e09a4a293724b844010 100644 (file)
@@ -6860,7 +6860,8 @@ finish_static_assert (tree condition, tree message, location_t location,
       else if (condition && condition != error_mark_node)
        {
          error ("non-constant condition for static assertion");
-         cxx_constant_value (condition);
+         if (require_potential_rvalue_constant_expression (condition))
+           cxx_constant_value (condition);
        }
       input_location = saved_loc;
     }
index 66aad3290c5690c2f170c5348a0dbf3ea39765c8..9cdf30dad15a563141c882660df2a32f76c97fe5 100644 (file)
@@ -1,3 +1,10 @@
+2014-03-13  Paolo Carlini  <paolo.carlini@oracle.com>
+
+       PR c++/60254
+       * g++.dg/cpp0x/static_assert10.C: New.
+       * g++.dg/cpp0x/static_assert11.C: Likewise.
+       * g++.dg/cpp0x/static_assert3.C: Adjust.
+
 2014-03-13  Richard Biener  <rguenther@suse.de>
 
        * lib/lto.exp (lto-execute): Fix error catching for dg-final.
diff --git a/gcc/testsuite/g++.dg/cpp0x/static_assert10.C b/gcc/testsuite/g++.dg/cpp0x/static_assert10.C
new file mode 100644 (file)
index 0000000..216f259
--- /dev/null
@@ -0,0 +1,8 @@
+// PR c++/60254
+// { dg-do compile { target c++11 } }
+
+template<typename T> bool foo(T)
+{
+  int i;
+  static_assert(foo(i), "Error"); // { dg-error "non-constant condition|not usable" }
+}
diff --git a/gcc/testsuite/g++.dg/cpp0x/static_assert11.C b/gcc/testsuite/g++.dg/cpp0x/static_assert11.C
new file mode 100644 (file)
index 0000000..8a7362d
--- /dev/null
@@ -0,0 +1,10 @@
+// PR c++/60254
+// { dg-do compile { target c++11 } }
+
+struct A
+{
+  template<typename T> bool foo(T)
+  {
+    static_assert(foo(0), "Error"); // { dg-error "non-constant condition|constant expression" }
+  }
+};
index ff71300c663ceaef205dc7dd04a2881ed3780a90..addde13c114264345c4a4b137559b8e806f101c3 100644 (file)
@@ -1,4 +1,4 @@
 // { dg-do compile { target c++11 } }
 static_assert(7 / 0, "X"); // { dg-error "non-constant condition" "non-constant" }
 // { dg-warning "division by zero" "zero" { target *-*-* } 2 }
-// { dg-error "7 / 0.. is not a constant expression" "not a constant" { target *-*-* } 2 }
+// { dg-error "division by zero is not a constant-expression" "not a constant" { target *-*-* } 2 }