aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorPaolo Carlini <paolo.carlini@oracle.com>2014-03-13 09:51:52 +0000
committerPaolo Carlini <paolo@gcc.gnu.org>2014-03-13 09:51:52 +0000
commit9299bde01aed78cfea5a779eae1f79bac9c3ac00 (patch)
tree41f000d0a75618cc89cd877f4ffbf92d592a5c2e
parenteba14fca8919a408f95fadf383f8c87fb79e797c (diff)
downloadgcc-9299bde01aed78cfea5a779eae1f79bac9c3ac00.zip
gcc-9299bde01aed78cfea5a779eae1f79bac9c3ac00.tar.gz
gcc-9299bde01aed78cfea5a779eae1f79bac9c3ac00.tar.bz2
re PR c++/60254 ([c++11] ICE with non-const expression in static_assert)
/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
-rw-r--r--gcc/cp/ChangeLog6
-rw-r--r--gcc/cp/semantics.c3
-rw-r--r--gcc/testsuite/ChangeLog7
-rw-r--r--gcc/testsuite/g++.dg/cpp0x/static_assert10.C8
-rw-r--r--gcc/testsuite/g++.dg/cpp0x/static_assert11.C10
-rw-r--r--gcc/testsuite/g++.dg/cpp0x/static_assert3.C2
6 files changed, 34 insertions, 2 deletions
diff --git a/gcc/cp/ChangeLog b/gcc/cp/ChangeLog
index 4848b54..e5732f2 100644
--- a/gcc/cp/ChangeLog
+++ b/gcc/cp/ChangeLog
@@ -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
diff --git a/gcc/cp/semantics.c b/gcc/cp/semantics.c
index 1c9e153..886fbb8 100644
--- a/gcc/cp/semantics.c
+++ b/gcc/cp/semantics.c
@@ -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;
}
diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog
index 66aad32..9cdf30d 100644
--- a/gcc/testsuite/ChangeLog
+++ b/gcc/testsuite/ChangeLog
@@ -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
index 0000000..216f259
--- /dev/null
+++ b/gcc/testsuite/g++.dg/cpp0x/static_assert10.C
@@ -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
index 0000000..8a7362d
--- /dev/null
+++ b/gcc/testsuite/g++.dg/cpp0x/static_assert11.C
@@ -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" }
+ }
+};
diff --git a/gcc/testsuite/g++.dg/cpp0x/static_assert3.C b/gcc/testsuite/g++.dg/cpp0x/static_assert3.C
index ff71300..addde13 100644
--- a/gcc/testsuite/g++.dg/cpp0x/static_assert3.C
+++ b/gcc/testsuite/g++.dg/cpp0x/static_assert3.C
@@ -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 }