From e70e0b60724694c40064580368e5b93aae951842 Mon Sep 17 00:00:00 2001 From: Siddhesh Poyarekar Date: Tue, 23 Aug 2011 14:56:48 +0000 Subject: [PATCH] re PR c++/50055 ([PATCH] Location information for the throw() specification in a function may be incorrect) PR c++/50055 * except.c (begin_eh_spec_block): Build EH_SPEC block on the same line as the function. From-SVN: r177990 --- gcc/cp/ChangeLog | 6 ++++++ gcc/cp/except.c | 6 ++++-- gcc/testsuite/ChangeLog | 5 +++++ gcc/testsuite/g++.dg/gcov/gcov-7.C | 28 ++++++++++++++++++++++++++++ 4 files changed, 43 insertions(+), 2 deletions(-) create mode 100644 gcc/testsuite/g++.dg/gcov/gcov-7.C diff --git a/gcc/cp/ChangeLog b/gcc/cp/ChangeLog index b9e83d4348c..5ebab87fcfa 100644 --- a/gcc/cp/ChangeLog +++ b/gcc/cp/ChangeLog @@ -1,3 +1,9 @@ +2011-08-23 Siddhesh Poyarekar + + PR c++/50055 + * except.c (begin_eh_spec_block): Build EH_SPEC block on the + same line as the function. + 2011-08-23 Jakub Jelinek PR c++/46862 diff --git a/gcc/cp/except.c b/gcc/cp/except.c index 129d2f43441..bfc520d93d2 100644 --- a/gcc/cp/except.c +++ b/gcc/cp/except.c @@ -527,15 +527,17 @@ tree begin_eh_spec_block (void) { tree r; + location_t spec_location = DECL_SOURCE_LOCATION (current_function_decl); + /* A noexcept specification (or throw() with -fnothrow-opt) is a MUST_NOT_THROW_EXPR. */ if (TYPE_NOEXCEPT_P (TREE_TYPE (current_function_decl))) { - r = build_stmt (input_location, MUST_NOT_THROW_EXPR, NULL_TREE); + r = build_stmt (spec_location, MUST_NOT_THROW_EXPR, NULL_TREE); TREE_SIDE_EFFECTS (r) = 1; } else - r = build_stmt (input_location, EH_SPEC_BLOCK, NULL_TREE, NULL_TREE); + r = build_stmt (spec_location, EH_SPEC_BLOCK, NULL_TREE, NULL_TREE); add_stmt (r); TREE_OPERAND (r, 0) = push_stmt_list (); return r; diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog index 6d413f35762..bac79615945 100644 --- a/gcc/testsuite/ChangeLog +++ b/gcc/testsuite/ChangeLog @@ -1,3 +1,8 @@ +2011-08-23 Siddhesh Poyarekar + + PR c++/50055 + * g++.dg/gcov/gcov-7.C: New test. + 2011-08-23 Jakub Jelinek PR c++/46862 diff --git a/gcc/testsuite/g++.dg/gcov/gcov-7.C b/gcc/testsuite/g++.dg/gcov/gcov-7.C new file mode 100644 index 00000000000..db3e95a07bc --- /dev/null +++ b/gcc/testsuite/g++.dg/gcov/gcov-7.C @@ -0,0 +1,28 @@ +/* Check that Exception handler specification is not + mapped to the curly braces below the function + declaration. */ + +/* { dg-options "-fprofile-arcs -ftest-coverage" } */ +/* { dg-do run { target native } } */ + +struct foo +{ + foo () throw (int) + { /* count (-) */ + throw (1); + } +}; + +int main () +{ + try + { + foo f; + } + catch ( ...) + { + return 0; + } +} + +/* { dg-final { run-gcov gcov-7.C } } */ -- 2.30.2