aboutsummaryrefslogtreecommitdiff
path: root/gcc/cp
diff options
context:
space:
mode:
authorJason Merrill <jason@redhat.com>2015-08-05 21:33:27 -0400
committerJason Merrill <jason@gcc.gnu.org>2015-08-05 21:33:27 -0400
commita2b4cfaa896be68bd0df2f75805ff50a549fd5d4 (patch)
treeeea821c19b9474a2d220f27d9e0044a063e2b838 /gcc/cp
parentd8835b4d85ea1bb4b99ad891d417cd88719b7aff (diff)
downloadgcc-a2b4cfaa896be68bd0df2f75805ff50a549fd5d4.zip
gcc-a2b4cfaa896be68bd0df2f75805ff50a549fd5d4.tar.gz
gcc-a2b4cfaa896be68bd0df2f75805ff50a549fd5d4.tar.bz2
decl.c (cp_finish_decl): Tidy.
* decl.c (cp_finish_decl): Tidy. * typeck.c (finish_class_member_access_expr): Use type_dependent_expression_p. * semantics.c (finish_id_expression): Use type_dependent_expression_p. Don't build_qualified_name for a decl in non-dependent scope. * pt.c (type_dependent_expression_p): A TEMPLATE_ID_EXPR of an identifier is dependent. Remove variable_template_p check. From-SVN: r226652
Diffstat (limited to 'gcc/cp')
-rw-r--r--gcc/cp/ChangeLog9
-rw-r--r--gcc/cp/decl.c3
-rw-r--r--gcc/cp/pt.c5
-rw-r--r--gcc/cp/semantics.c94
-rw-r--r--gcc/cp/typeck.c7
5 files changed, 29 insertions, 89 deletions
diff --git a/gcc/cp/ChangeLog b/gcc/cp/ChangeLog
index e0075e0..502dc20 100644
--- a/gcc/cp/ChangeLog
+++ b/gcc/cp/ChangeLog
@@ -1,5 +1,14 @@
2015-08-05 Jason Merrill <jason@redhat.com>
+ * decl.c (cp_finish_decl): Tidy.
+ * typeck.c (finish_class_member_access_expr): Use
+ type_dependent_expression_p.
+ * semantics.c (finish_id_expression): Use
+ type_dependent_expression_p. Don't build_qualified_name for a
+ decl in non-dependent scope.
+ * pt.c (type_dependent_expression_p): A TEMPLATE_ID_EXPR of an
+ identifier is dependent. Remove variable_template_p check.
+
PR c++/66260
PR c++/66596
PR c++/66649
diff --git a/gcc/cp/decl.c b/gcc/cp/decl.c
index 52584c5..208173a 100644
--- a/gcc/cp/decl.c
+++ b/gcc/cp/decl.c
@@ -6525,11 +6525,10 @@ cp_finish_decl (tree decl, tree init, bool init_const_expr_p,
then it can be used in future constant expressions, so its value
must be available. */
- if (!VAR_P (decl) || dependent_type_p (type))
+ if (!VAR_P (decl) || type_dependent_p)
/* We can't do anything if the decl has dependent type. */;
else if (init
&& init_const_expr_p
- && !type_dependent_p
&& TREE_CODE (type) != REFERENCE_TYPE
&& decl_maybe_constant_var_p (decl)
&& !type_dependent_init_p (init)
diff --git a/gcc/cp/pt.c b/gcc/cp/pt.c
index f8c123c..5f28f1b 100644
--- a/gcc/cp/pt.c
+++ b/gcc/cp/pt.c
@@ -21671,11 +21671,10 @@ type_dependent_expression_p (tree expression)
(TREE_OPERAND (expression, 1)))
return true;
expression = TREE_OPERAND (expression, 0);
+ if (identifier_p (expression))
+ return true;
}
- if (variable_template_p (expression))
- return dependent_type_p (TREE_TYPE (expression));
-
gcc_assert (TREE_CODE (expression) == OVERLOAD
|| TREE_CODE (expression) == FUNCTION_DECL);
diff --git a/gcc/cp/semantics.c b/gcc/cp/semantics.c
index d42838e..17b0a14 100644
--- a/gcc/cp/semantics.c
+++ b/gcc/cp/semantics.c
@@ -3362,7 +3362,7 @@ finish_id_expression (tree id_expression,
}
else
{
- bool dependent_p;
+ bool dependent_p = type_dependent_expression_p (decl);
/* If the declaration was explicitly qualified indicate
that. The semantics of `A::f(3)' are different than
@@ -3371,79 +3371,25 @@ finish_id_expression (tree id_expression,
? CP_ID_KIND_QUALIFIED
: (TREE_CODE (decl) == TEMPLATE_ID_EXPR
? CP_ID_KIND_TEMPLATE_ID
- : CP_ID_KIND_UNQUALIFIED));
-
-
- /* [temp.dep.expr]
-
- An id-expression is type-dependent if it contains an
- identifier that was declared with a dependent type.
-
- The standard is not very specific about an id-expression that
- names a set of overloaded functions. What if some of them
- have dependent types and some of them do not? Presumably,
- such a name should be treated as a dependent name. */
- /* Assume the name is not dependent. */
- dependent_p = false;
- if (!processing_template_decl)
- /* No names are dependent outside a template. */
- ;
- else if (TREE_CODE (decl) == CONST_DECL)
- /* We don't want to treat enumerators as dependent. */
- ;
- /* A template-id where the name of the template was not resolved
- is definitely dependent. */
- else if (TREE_CODE (decl) == TEMPLATE_ID_EXPR
- && (identifier_p (TREE_OPERAND (decl, 0))))
- dependent_p = true;
- /* For anything except an overloaded function, just check its
- type. */
- else if (!is_overloaded_fn (decl))
- dependent_p
- = dependent_type_p (TREE_TYPE (decl));
- /* For a set of overloaded functions, check each of the
- functions. */
- else
- {
- tree fns = decl;
-
- if (BASELINK_P (fns))
- fns = BASELINK_FUNCTIONS (fns);
-
- /* For a template-id, check to see if the template
- arguments are dependent. */
- if (TREE_CODE (fns) == TEMPLATE_ID_EXPR)
- {
- tree args = TREE_OPERAND (fns, 1);
- dependent_p = any_dependent_template_arguments_p (args);
- /* The functions are those referred to by the
- template-id. */
- fns = TREE_OPERAND (fns, 0);
- }
-
- /* If there are no dependent template arguments, go through
- the overloaded functions. */
- while (fns && !dependent_p)
- {
- tree fn = OVL_CURRENT (fns);
-
- /* Member functions of dependent classes are
- dependent. */
- if (TREE_CODE (fn) == FUNCTION_DECL
- && type_dependent_expression_p (fn))
- dependent_p = true;
- else if (TREE_CODE (fn) == TEMPLATE_DECL
- && dependent_template_p (fn))
- dependent_p = true;
-
- fns = OVL_NEXT (fns);
- }
- }
+ : (dependent_p
+ ? CP_ID_KIND_UNQUALIFIED_DEPENDENT
+ : CP_ID_KIND_UNQUALIFIED)));
/* If the name was dependent on a template parameter, we will
resolve the name at instantiation time. */
if (dependent_p)
{
+ /* If we found a variable, then name lookup during the
+ instantiation will always resolve to the same VAR_DECL
+ (or an instantiation thereof). */
+ if (VAR_P (decl)
+ || TREE_CODE (decl) == CONST_DECL
+ || TREE_CODE (decl) == PARM_DECL)
+ {
+ mark_used (decl);
+ return convert_from_reference (decl);
+ }
+
/* Create a SCOPE_REF for qualified names, if the scope is
dependent. */
if (scope)
@@ -3475,16 +3421,6 @@ finish_id_expression (tree id_expression,
need. */
if (TREE_CODE (id_expression) == TEMPLATE_ID_EXPR)
return id_expression;
- *idk = CP_ID_KIND_UNQUALIFIED_DEPENDENT;
- /* If we found a variable, then name lookup during the
- instantiation will always resolve to the same VAR_DECL
- (or an instantiation thereof). */
- if (VAR_P (decl)
- || TREE_CODE (decl) == PARM_DECL)
- {
- mark_used (decl);
- return convert_from_reference (decl);
- }
/* The same is true for FIELD_DECL, but we also need to
make sure that the syntax is correct. */
else if (TREE_CODE (decl) == FIELD_DECL)
diff --git a/gcc/cp/typeck.c b/gcc/cp/typeck.c
index a7a8844..5d754f1 100644
--- a/gcc/cp/typeck.c
+++ b/gcc/cp/typeck.c
@@ -2636,11 +2636,8 @@ finish_class_member_access_expr (tree object, tree name, bool template_p,
if (processing_template_decl)
{
- if (/* If OBJECT_TYPE is dependent, so is OBJECT.NAME. */
- dependent_type_p (object_type)
- /* If NAME is just an IDENTIFIER_NODE, then the expression
- is dependent. */
- || identifier_p (object)
+ if (/* If OBJECT is dependent, so is OBJECT.NAME. */
+ type_dependent_expression_p (object)
/* If NAME is "f<args>", where either 'f' or 'args' is
dependent, then the expression is dependent. */
|| (TREE_CODE (name) == TEMPLATE_ID_EXPR