public inbox for gcc-patches@gcc.gnu.org
 help / color / mirror / Atom feed
* C++ PATCH for c++/54913 (error with static reference member and templates)
@ 2012-12-06 19:43 Jason Merrill
  0 siblings, 0 replies; only message in thread
From: Jason Merrill @ 2012-12-06 19:43 UTC (permalink / raw)
  To: gcc-patches List

[-- Attachment #1: Type: text/plain, Size: 368 bytes --]

We build up a SCOPE_REF to remember that we saw a qualified-id in a 
template.  We also want to convert_from_reference so that a use of a 
reference member decays to a non-reference.  But we were doing them in 
the wrong order, so that the second operand of the SCOPE_REF was an 
INDIRECT_REF, which doesn't make sense.

Tested x86_64-pc-linux-gnu, applying to trunk.

[-- Attachment #2: 54913.patch --]
[-- Type: text/x-patch, Size: 1326 bytes --]

commit fde00723eeea410df8f677fe6753c68e7277796d
Author: Jason Merrill <jason@redhat.com>
Date:   Thu Dec 6 10:31:52 2012 -0500

    	PR c++/54913
    	* semantics.c (finish_qualified_id_expr): convert_from_reference
    	after building a SCOPE_REF.

diff --git a/gcc/cp/semantics.c b/gcc/cp/semantics.c
index 53e849a..6c168e4 100644
--- a/gcc/cp/semantics.c
+++ b/gcc/cp/semantics.c
@@ -1778,8 +1778,6 @@ finish_qualified_id_expr (tree qualifying_class,
     ;
   else
     {
-      expr = convert_from_reference (expr);
-
       /* In a template, return a SCOPE_REF for most qualified-ids
 	 so that we can check access at instantiation time.  But if
 	 we're looking at a member of the current instantiation, we
@@ -1790,6 +1788,8 @@ finish_qualified_id_expr (tree qualifying_class,
 	expr = build_qualified_name (TREE_TYPE (expr),
 				     qualifying_class, expr,
 				     template_p);
+
+      expr = convert_from_reference (expr);
     }
 
   return expr;
diff --git a/gcc/testsuite/g++.dg/template/qualified-id6.C b/gcc/testsuite/g++.dg/template/qualified-id6.C
new file mode 100644
index 0000000..83be874
--- /dev/null
+++ b/gcc/testsuite/g++.dg/template/qualified-id6.C
@@ -0,0 +1,14 @@
+// PR c++/54913
+
+struct E
+{
+  static const int& e;
+};
+
+template<typename>
+struct R
+{
+  R() { E::e; }
+};
+
+R<int> r;

^ permalink raw reply	[flat|nested] only message in thread

only message in thread, other threads:[~2012-12-06 19:43 UTC | newest]

Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2012-12-06 19:43 C++ PATCH for c++/54913 (error with static reference member and templates) 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).