aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--gcc/cp/ChangeLog8
-rw-r--r--gcc/cp/NEWS17
-rw-r--r--gcc/cp/tree.c3
-rw-r--r--gcc/cp/typeck.c24
-rw-r--r--gcc/testsuite/g++.old-deja/g++.other/sizeof2.C15
5 files changed, 55 insertions, 12 deletions
diff --git a/gcc/cp/ChangeLog b/gcc/cp/ChangeLog
index f9469a4..b2e6c07 100644
--- a/gcc/cp/ChangeLog
+++ b/gcc/cp/ChangeLog
@@ -1,3 +1,11 @@
+1999-07-26 Mark Mitchell <mark@codesourcery.com>
+
+ * tree.c (build_cplus_new): Adjust call to abstract_virtuals_error
+ as per 1999-07-26 change.
+
+ * typeck.c (c_sizeof): Don't allow non-static data members.
+ (expr_sizeof): Likewise.
+
1999-07-26 Jason Merrill <jason@yorick.cygnus.com>
* input.c (feed_input): Only touch lineno and input_filename
diff --git a/gcc/cp/NEWS b/gcc/cp/NEWS
index 1a242ab..8944797 100644
--- a/gcc/cp/NEWS
+++ b/gcc/cp/NEWS
@@ -1,3 +1,20 @@
+*** Changes in GCC 3.0:
+
+* Certain invalid conversions that were previously accepted will now
+ be rejected. For example, assigning function pointers of one type
+ to function pointers of another type now requires a cast, whereas
+ previously g++ would sometimes accept the code even without the
+ cast.
+
+* G++ previously allowed `sizeof (X::Y)' where Y was a non-static
+ member of X, even if the `sizeof' expression occurred outside
+ of a non-static member function of X (or one of its derived classes,
+ or a member-initializer for X or one of its derived classes.) This
+ extension has been removed.
+
+* G++ no longer allows you to overload the conditional operator (i.e.,
+ the `?:' operator.)
+
*** Changes in GCC 2.95:
* Messages about non-conformant code that we can still handle ("pedwarns")
diff --git a/gcc/cp/tree.c b/gcc/cp/tree.c
index c32bf8f..a84a9ba 100644
--- a/gcc/cp/tree.c
+++ b/gcc/cp/tree.c
@@ -226,8 +226,7 @@ build_cplus_new (type, init)
/* Make sure that we're not trying to create an instance of an
abstract class. */
- if (CLASSTYPE_ABSTRACT_VIRTUALS (type))
- abstract_virtuals_error (NULL_TREE, type);
+ abstract_virtuals_error (NULL_TREE, type);
if (TREE_CODE (init) != CALL_EXPR && TREE_CODE (init) != AGGR_INIT_EXPR)
return convert (type, init);
diff --git a/gcc/cp/typeck.c b/gcc/cp/typeck.c
index 64a6dad..905b3e3 100644
--- a/gcc/cp/typeck.c
+++ b/gcc/cp/typeck.c
@@ -1603,16 +1603,6 @@ c_sizeof (type)
if (code == REFERENCE_TYPE)
type = TREE_TYPE (type);
- /* We couldn't find anything in the ARM or the draft standard that says,
- one way or the other, if doing sizeof on something that doesn't have
- an object associated with it is correct or incorrect. For example, if
- you declare `struct S { char str[16]; };', and in your program do
- a `sizeof (S::str)', should we flag that as an error or should we give
- the size of it? Since it seems like a reasonable thing to do, we'll go
- with giving the value. */
- if (code == OFFSET_TYPE)
- type = TREE_TYPE (type);
-
/* @@ This also produces an error for a signature ref.
In that case we should be able to do better. */
if (IS_SIGNATURE (type))
@@ -1620,6 +1610,11 @@ c_sizeof (type)
error ("`sizeof' applied to a signature type");
return size_int (0);
}
+ else if (code == OFFSET_TYPE)
+ {
+ cp_error ("`sizeof' applied to non-static member");
+ return size_int (0);
+ }
if (TYPE_SIZE (complete_type (type)) == 0)
{
@@ -1665,6 +1660,15 @@ expr_sizeof (e)
incomplete_type_error (e, TREE_TYPE (e));
return size_int (1);
}
+ /* It's illegal to say `sizeof (X::i)' for `i' a non-static data
+ member unless you're in a non-static member of X. But, we used
+ to support this usage, so we still permit it unless we're being
+ pedantic. */
+ else if (TREE_CODE (e) == OFFSET_REF)
+ e = resolve_offset_ref (e);
+
+ if (e == error_mark_node)
+ return e;
return c_sizeof (TREE_TYPE (e));
}
diff --git a/gcc/testsuite/g++.old-deja/g++.other/sizeof2.C b/gcc/testsuite/g++.old-deja/g++.other/sizeof2.C
new file mode 100644
index 0000000..c597844
--- /dev/null
+++ b/gcc/testsuite/g++.old-deja/g++.other/sizeof2.C
@@ -0,0 +1,15 @@
+// Build don't link:
+// Origin: Mark Mitchell <mark@codesourcery.com>
+
+struct S
+{
+ int j; // ERROR - member
+ int i[2]; // ERROR - member
+};
+
+void f ()
+{
+ sizeof (S::j); // ERROR - non-static data member
+ sizeof (S::i[0]); // ERROR - non-static data member
+}
+