Commit b77ba909 by Jason Merrill Committed by Jason Merrill

re PR c++/39608 ('expr' cannot appear in a constant-expression.)

        PR c++/39608
        * semantics.c (finish_id_expression): Don't assume a dependent
        member of the current instantiation isn't a valid integral
        constant expression.  Check dependent_scope_p.
        * pt.c (dependent_scope_p): Check TYPE_P.

From-SVN: r145508
parent 0c908ffc
2009-04-03 Jason Merrill <jason@redhat.com>
PR c++/39608
* semantics.c (finish_id_expression): Don't assume a dependent
member of the current instantiation isn't a valid integral
constant expression. Check dependent_scope_p.
* pt.c (dependent_scope_p): Check TYPE_P.
(tsubst_copy): If args is null, just return.
2009-04-02 Jason Merrill <jason@redhat.com> 2009-04-02 Jason Merrill <jason@redhat.com>
PR c++/25185 PR c++/25185
......
...@@ -9999,7 +9999,7 @@ tsubst_copy (tree t, tree args, tsubst_flags_t complain, tree in_decl) ...@@ -9999,7 +9999,7 @@ tsubst_copy (tree t, tree args, tsubst_flags_t complain, tree in_decl)
enum tree_code code; enum tree_code code;
tree r; tree r;
if (t == NULL_TREE || t == error_mark_node) if (t == NULL_TREE || t == error_mark_node || args == NULL_TREE)
return t; return t;
code = TREE_CODE (t); code = TREE_CODE (t);
...@@ -16168,7 +16168,8 @@ dependent_type_p (tree type) ...@@ -16168,7 +16168,8 @@ dependent_type_p (tree type)
bool bool
dependent_scope_p (tree scope) dependent_scope_p (tree scope)
{ {
return dependent_type_p (scope) && !currently_open_class (scope); return (scope && TYPE_P (scope) && dependent_type_p (scope)
&& !currently_open_class (scope));
} }
/* Returns TRUE if EXPRESSION is dependent, according to CRITERION. */ /* Returns TRUE if EXPRESSION is dependent, according to CRITERION. */
......
...@@ -2857,11 +2857,6 @@ finish_id_expression (tree id_expression, ...@@ -2857,11 +2857,6 @@ finish_id_expression (tree id_expression,
dependent. */ dependent. */
if (scope) if (scope)
{ {
/* Since this name was dependent, the expression isn't
constant -- yet. No error is issued because it might
be constant when things are instantiated. */
if (integral_constant_expression_p)
*non_integral_constant_expression_p = true;
if (TYPE_P (scope)) if (TYPE_P (scope))
{ {
if (address_p && done) if (address_p && done)
...@@ -2869,7 +2864,7 @@ finish_id_expression (tree id_expression, ...@@ -2869,7 +2864,7 @@ finish_id_expression (tree id_expression,
done, address_p, done, address_p,
template_p, template_p,
template_arg_p); template_arg_p);
else if (dependent_type_p (scope)) else if (dependent_scope_p (scope))
decl = build_qualified_name (/*type=*/NULL_TREE, decl = build_qualified_name (/*type=*/NULL_TREE,
scope, scope,
id_expression, id_expression,
......
2009-04-03 Jason Merrill <jason@redhat.com>
PR c++/39608
* g++.dg/template/const2.C: New test.
2009-04-03 Richard Guenther <rguenther@suse.de> 2009-04-03 Richard Guenther <rguenther@suse.de>
PR tree-optimization/2480 PR tree-optimization/2480
......
// PR c++/39608
// We were improperly considering dependent members of the current
// instantiation to be non-constant (and therefore invalid template
// non-type arguments).
template <int I>
struct C {};
template <class T>
struct A
{
static const T x = 1;
C<A<T>::x> c; // { dg-bogus "invalid" }
};
A<int> a;
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment