C++ PATCH for c++/46058 (ICE on explicit scope in template)

Submitted by Jason Merrill on Dec. 3, 2010, 4:56 p.m.

Details

Message ID 4CF92137.4050302@redhat.com
State New
Headers show

Commit Message

Jason Merrill Dec. 3, 2010, 4:56 p.m.
In templates we keep SCOPE_REFs around even when they aren't dependent 
so that we can give access control errors at instantiation time.  But 
that means we need to be able to deal with them.

Tested x86_64-pc-linux-gnu, applied to trunk.
commit dc6397243e8affb028a658b5491c1b5b9d755d0a
Author: Jason Merrill <jason@redhat.com>
Date:   Wed Nov 24 18:20:49 2010 -0500

    	PR c++/46058
    	* tree.c (lvalue_kind) [SCOPE_REF]: Handle non-dependent case.

Patch hide | download patch | download mbox

diff --git a/gcc/cp/tree.c b/gcc/cp/tree.c
index 5538eea..1a77dc1 100644
--- a/gcc/cp/tree.c
+++ b/gcc/cp/tree.c
@@ -146,9 +146,12 @@  lvalue_kind (const_tree ref)
 	return clk_ordinary;
       break;
 
-      /* A currently unresolved scope ref.  */
+      /* A scope ref in a template, left as SCOPE_REF to support later
+	 access checking.  */
     case SCOPE_REF:
-      gcc_unreachable ();
+      gcc_assert (!type_dependent_expression_p (CONST_CAST_TREE(ref)));
+      return lvalue_kind (TREE_OPERAND (ref, 1));
+
     case MAX_EXPR:
     case MIN_EXPR:
       /* Disallow <? and >? as lvalues if either argument side-effects.  */
diff --git a/gcc/testsuite/g++.dg/template/scope4.C b/gcc/testsuite/g++.dg/template/scope4.C
new file mode 100644
index 0000000..a4ae074
--- /dev/null
+++ b/gcc/testsuite/g++.dg/template/scope4.C
@@ -0,0 +1,15 @@ 
+// PR c++/46058
+
+class StringLiterals {
+public:
+   static const char dec[];
+};
+
+template<class St, class Base, const char* name>
+class NoValueCommand : public Base {
+public:
+};
+
+template<class St, class Base>
+class DecBasic : public NoValueCommand<St,Base,StringLiterals::dec> {
+};