* C++ PATCH for c++/79580, ICE with compound literal
@ 2017-02-20 5:49 Jason Merrill
0 siblings, 0 replies; only message in thread
From: Jason Merrill @ 2017-02-20 5:49 UTC (permalink / raw)
To: gcc-patches List
[-- Attachment #1: Type: text/plain, Size: 256 bytes --]
We were treating a compound literal type defined in the initializer
for a static data member as though it were a member of the class.
Fixed by ignoring classes when defining a type from within an
expression.
Tested x86_64-pc-linux-gnu, applying to trunk.
[-- Attachment #2: 79580.diff --]
[-- Type: text/plain, Size: 1263 bytes --]
commit 23c08aed737764678bbe1af31ddaa16b2d0a4061
Author: Jason Merrill <jason@redhat.com>
Date: Sun Feb 19 16:50:38 2017 -0500
PR c++/79580 - ICE with compound literal
* parser.c (cp_parser_class_head): If we're in the middle of an
expression, use ts_within_enclosing_non_class.
diff --git a/gcc/cp/parser.c b/gcc/cp/parser.c
index feeafce..4656b4f 100644
--- a/gcc/cp/parser.c
+++ b/gcc/cp/parser.c
@@ -22771,7 +22771,10 @@ cp_parser_class_head (cp_parser* parser,
/* If the class was unnamed, create a dummy name. */
if (!id)
id = make_anon_name ();
- type = xref_tag (class_key, id, /*tag_scope=*/ts_current,
+ tag_scope tag_scope = (parser->in_type_id_in_expr_p
+ ? ts_within_enclosing_non_class
+ : ts_current);
+ type = xref_tag (class_key, id, tag_scope,
parser->num_template_parameter_lists);
}
diff --git a/gcc/testsuite/g++.dg/ext/complit15.C b/gcc/testsuite/g++.dg/ext/complit15.C
new file mode 100644
index 0000000..f12752d
--- /dev/null
+++ b/gcc/testsuite/g++.dg/ext/complit15.C
@@ -0,0 +1,8 @@
+// PR c++/79580
+// { dg-options "-flto -std=c++98" }
+
+class a
+{
+ static const double b;
+};
+const double a::b ((union { double c; }){}.c);
^ permalink raw reply [flat|nested] only message in thread
only message in thread, other threads:[~2017-02-20 5:48 UTC | newest]
Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2017-02-20 5:49 C++ PATCH for c++/79580, ICE with compound literal Jason Merrill
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).