2003-08-01 Nathan Sidwell <nathan@codesourcery.com>
+ PR c++/11525
+ * parser.c (cp_parser_primary_expression): Do not set
+ non-constant-p merely because it is a dependent scope.
+
PR c++/9447
* decl2.c (do_class_using_decl): Set type to NULL_TREE.
* semantics.c (finish_expr_stmt): Do not convert to void in a
{
if (TYPE_P (TREE_OPERAND (decl, 0)))
*qualifying_class = TREE_OPERAND (decl, 0);
- /* 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 (parser->constant_expression_p)
- parser->non_constant_expression_p = true;
return decl;
}
/* Check to see if DECL is a local variable in a context
2003-08-01 Nathan Sidwell <nathan@codesourcery.com>
+ PR c++/11525
+ * g++.dg/parse/constant4.C: New test.
+
PR c++/9447
* g++.dg/template/using5.C: New test.
--- /dev/null
+// { dg-do compile }
+
+// Copyright (C) 2003 Free Software Foundation, Inc.
+// Contributed by Nathan Sidwell 31 Jul 2003 <nathan@codesourcery.com>
+
+// PR c++/11525 incorrect error about non-constant initalizer
+
+template<typename> class X;
+template<unsigned> class Y {};
+
+
+template<typename T>
+void Foo ()
+{
+ static const unsigned I = X<T>::I;
+
+ Y<I> i;
+
+ static const unsigned J = X<T>::J;
+
+ Y<J> j; // { dg-error "non-constant" "" }
+}
+
+struct A
+{
+ operator unsigned () const;
+};
+
+template <typename> struct X
+{
+ enum {I};
+ static A const J;
+};
+
+void Baz ()
+{
+ Foo<int> (); // { dg-error "instantiated" "" }
+}
+
+