aboutsummaryrefslogtreecommitdiff
path: root/gcc
diff options
context:
space:
mode:
authorPaolo Carlini <paolo.carlini@oracle.com>2013-10-11 14:35:23 +0000
committerPaolo Carlini <paolo@gcc.gnu.org>2013-10-11 14:35:23 +0000
commit20e8fa532721590da0c89a8f442a9d1197eb2083 (patch)
tree6817098a3e4cee1557cdcd8c01ab3a80bd44e84f /gcc
parentacd15a286e182ee4b3331a35503bcd67a4294331 (diff)
downloadgcc-20e8fa532721590da0c89a8f442a9d1197eb2083.zip
gcc-20e8fa532721590da0c89a8f442a9d1197eb2083.tar.gz
gcc-20e8fa532721590da0c89a8f442a9d1197eb2083.tar.bz2
re PR c++/58633 (ICE with decltype of destructor call)
/cp 2013-10-11 Paolo Carlini <paolo.carlini@oracle.com> PR c++/58633 * parser.c (cp_parser_commit_to_topmost_tentative_parse): New. (cp_parser_pseudo_destructor_name): Use it. /testsuite 2013-10-11 Paolo Carlini <paolo.carlini@oracle.com> PR c++/58633 * g++.dg/cpp0x/decltype57.C: New. From-SVN: r203448
Diffstat (limited to 'gcc')
-rw-r--r--gcc/cp/ChangeLog6
-rw-r--r--gcc/cp/parser.c30
-rw-r--r--gcc/testsuite/ChangeLog5
-rw-r--r--gcc/testsuite/g++.dg/cpp0x/decltype57.C8
4 files changed, 48 insertions, 1 deletions
diff --git a/gcc/cp/ChangeLog b/gcc/cp/ChangeLog
index 1e0c46c..d1af382 100644
--- a/gcc/cp/ChangeLog
+++ b/gcc/cp/ChangeLog
@@ -1,5 +1,11 @@
2013-10-11 Paolo Carlini <paolo.carlini@oracle.com>
+ PR c++/58633
+ * parser.c (cp_parser_commit_to_topmost_tentative_parse): New.
+ (cp_parser_pseudo_destructor_name): Use it.
+
+2013-10-11 Paolo Carlini <paolo.carlini@oracle.com>
+
PR c++/31671
* pt.c (convert_nontype_argument): Set expr_type to
TREE_TYPE (probe_type).
diff --git a/gcc/cp/parser.c b/gcc/cp/parser.c
index 83fdfab..4189bf6 100644
--- a/gcc/cp/parser.c
+++ b/gcc/cp/parser.c
@@ -2395,6 +2395,8 @@ static void cp_parser_parse_tentatively
(cp_parser *);
static void cp_parser_commit_to_tentative_parse
(cp_parser *);
+static void cp_parser_commit_to_topmost_tentative_parse
+ (cp_parser *);
static void cp_parser_abort_tentative_parse
(cp_parser *);
static bool cp_parser_parse_definitely
@@ -6741,7 +6743,7 @@ cp_parser_pseudo_destructor_name (cp_parser* parser,
/* Once we see the ~, this has to be a pseudo-destructor. */
if (!processing_template_decl && !cp_parser_error_occurred (parser))
- cp_parser_commit_to_tentative_parse (parser);
+ cp_parser_commit_to_topmost_tentative_parse (parser);
/* Look for the type-name again. We are not responsible for
checking that it matches the first type-name. */
@@ -24449,6 +24451,32 @@ cp_parser_commit_to_tentative_parse (cp_parser* parser)
}
}
+/* Commit to the topmost currently active tentative parse.
+
+ Note that this function shouldn't be called when there are
+ irreversible side-effects while in a tentative state. For
+ example, we shouldn't create a permanent entry in the symbol
+ table, or issue an error message that might not apply if the
+ tentative parse is aborted. */
+
+static void
+cp_parser_commit_to_topmost_tentative_parse (cp_parser* parser)
+{
+ cp_parser_context *context = parser->context;
+ cp_lexer *lexer = parser->lexer;
+
+ if (context)
+ {
+ if (context->status == CP_PARSER_STATUS_KIND_COMMITTED)
+ return;
+ context->status = CP_PARSER_STATUS_KIND_COMMITTED;
+
+ while (!cp_lexer_saving_tokens (lexer))
+ lexer = lexer->next;
+ cp_lexer_commit_tokens (lexer);
+ }
+}
+
/* Abort the currently active tentative parse. All consumed tokens
will be rolled back, and no diagnostics will be issued. */
diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog
index c27d500..87ff2a7 100644
--- a/gcc/testsuite/ChangeLog
+++ b/gcc/testsuite/ChangeLog
@@ -1,5 +1,10 @@
2013-10-11 Paolo Carlini <paolo.carlini@oracle.com>
+ PR c++/58633
+ * g++.dg/cpp0x/decltype57.C: New.
+
+2013-10-11 Paolo Carlini <paolo.carlini@oracle.com>
+
PR c++/31671
* g++.dg/template/nontype26.C: New.
diff --git a/gcc/testsuite/g++.dg/cpp0x/decltype57.C b/gcc/testsuite/g++.dg/cpp0x/decltype57.C
new file mode 100644
index 0000000..353cc72
--- /dev/null
+++ b/gcc/testsuite/g++.dg/cpp0x/decltype57.C
@@ -0,0 +1,8 @@
+// PR c++/58633
+// { dg-do compile { target c++11 } }
+
+void foo(int i)
+{
+ typedef int I;
+ decltype(i.I::~I())* p;
+}