aboutsummaryrefslogtreecommitdiff
path: root/gcc
diff options
context:
space:
mode:
authorMark Mitchell <mmitchel@gcc.gnu.org>1998-10-27 22:25:05 +0000
committerMark Mitchell <mmitchel@gcc.gnu.org>1998-10-27 22:25:05 +0000
commit950ad3c380028795a85da9e841dc9cc52a06118a (patch)
tree1a94ee29d383df80c9e3fe40847b9e047d3ba848 /gcc
parent2a5307b1a9ac135b951d60cf98a37fc78fbfbb14 (diff)
downloadgcc-950ad3c380028795a85da9e841dc9cc52a06118a.zip
gcc-950ad3c380028795a85da9e841dc9cc52a06118a.tar.gz
gcc-950ad3c380028795a85da9e841dc9cc52a06118a.tar.bz2
decl.c (grokdeclarator): Use type_quals, rather than constp, consistently.
* decl.c (grokdeclarator): Use type_quals, rather than constp, consistently. From-SVN: r23372
Diffstat (limited to 'gcc')
-rw-r--r--gcc/cp/decl.c11
-rw-r--r--gcc/testsuite/g++.old-deja/g++.other/const2.C5
2 files changed, 11 insertions, 5 deletions
diff --git a/gcc/cp/decl.c b/gcc/cp/decl.c
index 87b8d50..4252c20 100644
--- a/gcc/cp/decl.c
+++ b/gcc/cp/decl.c
@@ -9396,7 +9396,7 @@ grokdeclarator (declarator, declspecs, decl_context, initialized, attrlist)
{
/* It's common practice (and completely valid) to have a const
be initialized and declared extern. */
- if (! constp)
+ if (!(type_quals & TYPE_QUAL_CONST))
warning ("`%s' initialized and declared `extern'", name);
}
else
@@ -10651,8 +10651,7 @@ grokdeclarator (declarator, declspecs, decl_context, initialized, attrlist)
the rest of the compiler does not correctly
handle the initialization unless the member is
static so we make it static below. */
- cp_pedwarn ("ANSI C++ forbids initialization of %s `%D'",
- constp ? "const member" : "member",
+ cp_pedwarn ("ANSI C++ forbids initialization of member `%D'",
declarator);
cp_pedwarn ("making `%D' static", declarator);
staticp = 1;
@@ -10677,7 +10676,7 @@ grokdeclarator (declarator, declspecs, decl_context, initialized, attrlist)
ignore this declaration. */
return void_type_node;
}
- else if (!constp)
+ else if (!(type_quals & TYPE_QUAL_CONST))
cp_error ("ANSI C++ forbids in-class initialization of non-const static member `%D'",
declarator);
else if (pedantic && ! INTEGRAL_TYPE_P (type)
@@ -10808,7 +10807,9 @@ grokdeclarator (declarator, declspecs, decl_context, initialized, attrlist)
/* An uninitialized decl with `extern' is a reference. */
decl = grokvardecl (type, declarator, &specbits,
- initialized, constp, in_namespace);
+ initialized,
+ (type_quals & TYPE_QUAL_CONST) != 0,
+ in_namespace);
bad_specifiers (decl, "variable", virtualp, quals != NULL_TREE,
inlinep, friendp, raises != NULL_TREE);
diff --git a/gcc/testsuite/g++.old-deja/g++.other/const2.C b/gcc/testsuite/g++.old-deja/g++.other/const2.C
new file mode 100644
index 0000000..90b70d1
--- /dev/null
+++ b/gcc/testsuite/g++.old-deja/g++.other/const2.C
@@ -0,0 +1,5 @@
+// Build don't link:
+
+struct S {
+ static const char* cp = "abc"; // ERROR - initialization of non-const
+};