aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorNathan Sidwell <nathan@acm.org>2016-04-01 12:10:17 +0000
committerNathan Sidwell <nathan@gcc.gnu.org>2016-04-01 12:10:17 +0000
commitf9bf89bb6a91192cfd37c5ba9823245c5f91a133 (patch)
treec3fa1d2d7c3ec986ecf88309c6206c316b44041a
parent4afdcfaa6f925047857feebc13d50a4583a75eb0 (diff)
downloadgcc-f9bf89bb6a91192cfd37c5ba9823245c5f91a133.zip
gcc-f9bf89bb6a91192cfd37c5ba9823245c5f91a133.tar.gz
gcc-f9bf89bb6a91192cfd37c5ba9823245c5f91a133.tar.bz2
re PR c++/68475 (ICE: in merge_exception_specifiers, at cp/typeck2.c:2115 with -fno-exceptions on invalid code)
PR c++/68475 * decl.c (check_redeclaration_exception_specification): Check regardless of -fno-exceptions. * typeck2.c (merge_exception_specifiers): Relax assert by checking flag_exceptions too. * g++.dg/g++.dg/cpp0x/noexcept29.C: New. From-SVN: r234667
-rw-r--r--gcc/cp/ChangeLog8
-rw-r--r--gcc/cp/decl.c11
-rw-r--r--gcc/cp/typeck2.c2
-rw-r--r--gcc/testsuite/ChangeLog2
-rw-r--r--gcc/testsuite/g++.dg/cpp0x/noexcept29.C19
5 files changed, 37 insertions, 5 deletions
diff --git a/gcc/cp/ChangeLog b/gcc/cp/ChangeLog
index d457acc..e44818d 100644
--- a/gcc/cp/ChangeLog
+++ b/gcc/cp/ChangeLog
@@ -1,3 +1,11 @@
+2016-04-01 Nathan Sidwell <nathan@acm.org>
+
+ PR c++/68475
+ * decl.c (check_redeclaration_exception_specification): Check
+ regardless of -fno-exceptions.
+ * typeck2.c (merge_exception_specifiers): Relax assert by checking
+ flag_exceptions too.
+
2016-03-31 Nathan Sidwell <nathan@acm.org>
* decl.c (start_preparsed_function): Remove unnecessary bracing.
diff --git a/gcc/cp/decl.c b/gcc/cp/decl.c
index a6c5855..9260f4c 100644
--- a/gcc/cp/decl.c
+++ b/gcc/cp/decl.c
@@ -1202,16 +1202,19 @@ check_redeclaration_exception_specification (tree new_decl,
specialization, of that function shall have an
exception-specification with the same set of type-ids. */
if (! DECL_IS_BUILTIN (old_decl)
- && flag_exceptions
&& !comp_except_specs (new_exceptions, old_exceptions, ce_normal))
{
const char *msg
= "declaration of %q+F has a different exception specifier";
bool complained = true;
- if (! DECL_IN_SYSTEM_HEADER (old_decl))
- error (msg, new_decl);
- else
+ if (DECL_IN_SYSTEM_HEADER (old_decl))
complained = pedwarn (0, OPT_Wsystem_headers, msg, new_decl);
+ else if (!flag_exceptions)
+ /* We used to silently permit mismatched eh specs with
+ -fno-exceptions, so make them a pedwarn now. */
+ complained = pedwarn (0, OPT_Wpedantic, msg, new_decl);
+ else
+ error (msg, new_decl);
if (complained)
inform (0, "from previous declaration %q+F", old_decl);
}
diff --git a/gcc/cp/typeck2.c b/gcc/cp/typeck2.c
index 4ab77cd..b921689 100644
--- a/gcc/cp/typeck2.c
+++ b/gcc/cp/typeck2.c
@@ -2143,7 +2143,7 @@ merge_exception_specifiers (tree list, tree add)
return add;
noex = TREE_PURPOSE (list);
gcc_checking_assert (!TREE_PURPOSE (add)
- || errorcount
+ || errorcount || !flag_exceptions
|| cp_tree_equal (noex, TREE_PURPOSE (add)));
/* Combine the dynamic-exception-specifiers, if any. */
diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog
index 8f6210a..519a926 100644
--- a/gcc/testsuite/ChangeLog
+++ b/gcc/testsuite/ChangeLog
@@ -1,3 +1,5 @@
+2016-04-01 Nathan Sidwell <nathan@acm.org>
+
2016-04-01 Ilya Enkovich <enkovich.gnu@gmail.com>
PR target/69890
diff --git a/gcc/testsuite/g++.dg/cpp0x/noexcept29.C b/gcc/testsuite/g++.dg/cpp0x/noexcept29.C
new file mode 100644
index 0000000..8b920c5
--- /dev/null
+++ b/gcc/testsuite/g++.dg/cpp0x/noexcept29.C
@@ -0,0 +1,19 @@
+// { dg-do compile { target c++11 } }
+// { dg-additional-options "-fno-exceptions" }
+
+// PR68475 we used to not check eh spec matching with -fno-exceptions,
+// but this could lead to ICEs.
+
+template <typename> struct traits;
+
+template <typename T> struct X
+{
+ void Foo () noexcept (traits <T>::foo ()); // { dg-message "previous declaration" }
+};
+
+template <typename T>
+void
+X<T>::Foo () noexcept (traits <T>::bar ()) // { dg-error "different exception specifier" }
+{
+}
+