This is the mail archive of the
gcc-patches@gcc.gnu.org
mailing list for the GCC project.
[c++-concepts] template scoping error
- From: Andrew Sutton <andrew dot n dot sutton at gmail dot com>
- To: gcc-patches <gcc-patches at gcc dot gnu dot org>
- Date: Wed, 20 Aug 2014 17:18:22 -0400
- Subject: [c++-concepts] template scoping error
- Authentication-results: sourceware.org; auth=none
Fixes a regression in lookup rules involving declarations with
nested-name-specifiers. In particular, we don't actually want to
execute these rules if we absolutely don't have to.
2014-08-15 Andrew Sutton <andrew.n.sutton@gmail.com>
Fixing regression in scoping rules for templates.
* gcc/cp/semantics.c (fixup_tmeplate_type): Lift check to
finish_template_type.
(finish_template_type): Only do this when concepts are enabled,
and also when the class is actually a template. For non-dependent
types there are no actions to be taken.
Andrew Sutton
Index: gcc/cp/semantics.c
===================================================================
--- gcc/cp/semantics.c (revision 214228)
+++ gcc/cp/semantics.c (working copy)
@@ -3004,10 +3004,6 @@ finish_template_decl (tree parms)
static tree
fixup_template_type (tree type)
{
- // Don't try to fix non-class types.
- if (!CLASS_TYPE_P (type))
- return type;
-
// Find the template parameter list at the a depth appropriate to
// the scope we're trying to enter.
tree parms = current_template_parms;
@@ -3055,8 +3051,12 @@ finish_template_type (tree name, tree ar
NULL_TREE, NULL_TREE, entering_scope,
tf_warning_or_error | tf_user);
- // If entering a scope, correct the lookup to account for constraints.
- if (entering_scope)
+ // If entering a scope of a template, correct the lookup to
+ // account for constraints.
+ if (flag_concepts
+ && entering_scope
+ && CLASS_TYPE_P (type)
+ && CLASSTYPE_IS_TEMPLATE (type))
type = fixup_template_type (type);
if (type == error_mark_node)