aboutsummaryrefslogtreecommitdiff
path: root/gcc
diff options
context:
space:
mode:
authorMark Mitchell <mark@codesourcery.com>2005-02-22 21:43:55 +0000
committerMark Mitchell <mmitchel@gcc.gnu.org>2005-02-22 21:43:55 +0000
commitb671e5a4993a4658274fb359e6acd69b613fa5f6 (patch)
tree05b8ffe13e98f3d8142bddd8e3236b9f33c5ffc8 /gcc
parent245b65adcc2aa73201624a4ab09612f6acc8dc56 (diff)
downloadgcc-b671e5a4993a4658274fb359e6acd69b613fa5f6.zip
gcc-b671e5a4993a4658274fb359e6acd69b613fa5f6.tar.gz
gcc-b671e5a4993a4658274fb359e6acd69b613fa5f6.tar.bz2
parser.c (cp_parser_direct_declarator): Always complain about non-constant array bounds when in a function scope.
* parser.c (cp_parser_direct_declarator): Always complain about non-constant array bounds when in a function scope. * semantics.c (finish_id_expression): Do not mark dependent names as non-constant. From-SVN: r95417
Diffstat (limited to 'gcc')
-rw-r--r--gcc/cp/ChangeLog8
-rw-r--r--gcc/cp/parser.c11
-rw-r--r--gcc/cp/semantics.c5
-rw-r--r--gcc/testsuite/ChangeLog5
-rw-r--r--gcc/testsuite/g++.dg/parse/constant6.C23
5 files changed, 38 insertions, 14 deletions
diff --git a/gcc/cp/ChangeLog b/gcc/cp/ChangeLog
index ae75f8f..4abda48 100644
--- a/gcc/cp/ChangeLog
+++ b/gcc/cp/ChangeLog
@@ -1,3 +1,11 @@
+2005-02-22 Mark Mitchell <mark@codesourcery.com>
+
+ PR c++/19883
+ * parser.c (cp_parser_direct_declarator): Always complain about
+ non-constant array bounds when in a function scope.
+ * semantics.c (finish_id_expression): Do not mark dependent names
+ as non-constant.
+
2005-02-21 Douglas Gregor <dgregor@cs.indiana.edu>
PR c++/19076
diff --git a/gcc/cp/parser.c b/gcc/cp/parser.c
index f38f6fb..b52ba95 100644
--- a/gcc/cp/parser.c
+++ b/gcc/cp/parser.c
@@ -11107,15 +11107,8 @@ cp_parser_direct_declarator (cp_parser* parser,
bounds = fold_non_dependent_expr (bounds);
/* Normally, the array bound must be an integral constant
expression. However, as an extension, we allow VLAs
- in function scopes. And, we allow type-dependent
- expressions in templates; sometimes we don't know for
- sure whether or not something is a valid integral
- constant expression until instantiation time. (It
- doesn't make sense to check for value-dependency, as
- an expression is only value-dependent when it is a
- constant expression.) */
- else if (!type_dependent_expression_p (bounds)
- && !at_function_scope_p ())
+ in function scopes. */
+ else if (!at_function_scope_p ())
{
error ("array bound is not an integer constant");
bounds = error_mark_node;
diff --git a/gcc/cp/semantics.c b/gcc/cp/semantics.c
index fcffb3dd..4ff333b 100644
--- a/gcc/cp/semantics.c
+++ b/gcc/cp/semantics.c
@@ -2629,11 +2629,6 @@ finish_id_expression (tree id_expression,
need. */
if (TREE_CODE (id_expression) == TEMPLATE_ID_EXPR)
return id_expression;
- /* 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;
*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
diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog
index e8661bf..86857d2 100644
--- a/gcc/testsuite/ChangeLog
+++ b/gcc/testsuite/ChangeLog
@@ -1,3 +1,8 @@
+2005-02-22 Mark Mitchell <mark@codesourcery.com>
+
+ PR c++/19883
+ * g++.dg/parse/constant6.C: New test.
+
2005-02-22 Uros Bizjak <uros@kss-loka.si>
* g++.dg/charset/asm1.c: Check for IBM1047 code set, not IBM-1047.
diff --git a/gcc/testsuite/g++.dg/parse/constant6.C b/gcc/testsuite/g++.dg/parse/constant6.C
new file mode 100644
index 0000000..dae01d4
--- /dev/null
+++ b/gcc/testsuite/g++.dg/parse/constant6.C
@@ -0,0 +1,23 @@
+// PR c++/19883
+
+template<typename T> struct A
+{
+ static const T i = 1;
+ char a[int(i)];
+};
+
+template<int> struct B {};
+
+template<typename T> struct C
+{
+ static const T i = 2;
+ B<int(i)> a;
+};
+
+template< typename T, T N >
+struct integral_c
+{
+ static const T value = N;
+
+ typedef integral_c< T, static_cast<T>((value + 1)) > next;
+};