aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--gcc/ChangeLog11
-rw-r--r--gcc/cp/ChangeLog9
-rw-r--r--gcc/cp/cp-tree.h2
-rw-r--r--gcc/cp/decl.c6
-rw-r--r--gcc/cp/decl2.c33
-rw-r--r--gcc/extend.texi50
6 files changed, 87 insertions, 24 deletions
diff --git a/gcc/ChangeLog b/gcc/ChangeLog
index a8aa1d7..6a72c03 100644
--- a/gcc/ChangeLog
+++ b/gcc/ChangeLog
@@ -1,12 +1,17 @@
+Fri Nov 19 10:41:15 GMT 1999 Nathan Sidwell <nathan@acm.org>
+
+ * extend.texi: Document C++ restricted pointers and references.
+
1999-11-19 Bernd Schmidt <bernds@cygnus.co.uk>
* cse.c (addr_affects_sp): No longer conditional on AUTO_INC_DEC.
(invalidate_skipped_set): Call it unconditionally.
(cse_set_around_loop): Likewise.
-Fri Nov 18 13:39:22 CET 1999 Jam Hubicka <hubicka@freesoft.cz>
- * i386.h (struct_processor_costs): New fileds int_load, int_store, fp_move,
- fp_load and fp_store
+Fri Nov 18 13:39:22 CET 1999 Jan Hubicka <hubicka@freesoft.cz>
+
+ * i386.h (struct_processor_costs): New fileds int_load, int_store,
+ fp_move, fp_load and fp_store
(REGISTER_MOVE_COST): Fix comment, calculate exactly the cost of
fp->int moves
(MEMORY_MOVE_COST): New macro.
diff --git a/gcc/cp/ChangeLog b/gcc/cp/ChangeLog
index a8598e8..284227d 100644
--- a/gcc/cp/ChangeLog
+++ b/gcc/cp/ChangeLog
@@ -1,3 +1,12 @@
+1999-11-19 Nathan Sidwell <nathan@acm.org>
+
+ * cp-tree.h (grok_method_quals): Return this pointer qualifiers.
+ * decl.c (grokdeclarator): Adjust calls to grok_method_quals.
+ * decl2.c (grok_method_quals): Accept `restrict' as applying to
+ the object pointer. Return such qualifiers.
+ (grokclassfn): Apply this pointer qualifiers. Cleanup unused
+ variables.
+
1999-11-18 Mark Mitchell <mark@codesourcery.com>
* except.c (expand_end_catch_block): Fix typo.
diff --git a/gcc/cp/cp-tree.h b/gcc/cp/cp-tree.h
index dfa934e..2e764c1 100644
--- a/gcc/cp/cp-tree.h
+++ b/gcc/cp/cp-tree.h
@@ -3529,7 +3529,7 @@ extern void make_rtl_for_local_static PROTO((tree));
extern void init_decl2 PROTO((void));
extern int check_java_method PROTO((tree));
extern int lang_decode_option PROTO((int, char **));
-extern tree grok_method_quals PROTO((tree, tree, tree));
+extern int grok_method_quals PROTO((tree, tree, tree));
extern void warn_if_unknown_interface PROTO((tree));
extern void grok_x_components PROTO((tree));
extern void maybe_retrofit_in_chrg PROTO((tree));
diff --git a/gcc/cp/decl.c b/gcc/cp/decl.c
index 38451dd..91b8552 100644
--- a/gcc/cp/decl.c
+++ b/gcc/cp/decl.c
@@ -8919,7 +8919,8 @@ create_array_type_for_decl (name, type, size)
is erroneous, NULL_TREE is returned.
QUALS is used only for FUNCDEF and MEMFUNCDEF cases. For a member
- function, these are the qualifiers to give to the `this' pointer.
+ function, these are the qualifiers to give to the `this' pointer. We
+ apply TYPE_QUAL_RESTRICT to the this ptr, not the object.
May return void_type_node if the declarator turned out to be a friend.
See grokfield for details. */
@@ -9836,8 +9837,9 @@ grokdeclarator (declarator, declspecs, decl_context, initialized, attrlist)
if (ctype != NULL_TREE)
{
tree dummy = build_decl (TYPE_DECL, NULL_TREE, type);
- ctype = grok_method_quals (ctype, dummy, quals);
+ grok_method_quals (ctype, dummy, quals);
type = TREE_TYPE (dummy);
+ ctype = TREE_TYPE (TREE_VALUE (TYPE_ARG_TYPES (type)));
quals = NULL_TREE;
}
}
diff --git a/gcc/cp/decl2.c b/gcc/cp/decl2.c
index 8c623fc..f4630b2 100644
--- a/gcc/cp/decl2.c
+++ b/gcc/cp/decl2.c
@@ -780,9 +780,11 @@ lang_decode_option (argc, argv)
/* Incorporate `const' and `volatile' qualifiers for member functions.
FUNCTION is a TYPE_DECL or a FUNCTION_DECL.
- QUALS is a list of qualifiers. */
+ QUALS is a list of qualifiers. Returns any explicit
+ top-level qualifiers of the method's this pointer, anything other than
+ TYPE_UNQUALIFIED will be an extension. */
-tree
+int
grok_method_quals (ctype, function, quals)
tree ctype, function, quals;
{
@@ -790,13 +792,16 @@ grok_method_quals (ctype, function, quals)
tree raises = TYPE_RAISES_EXCEPTIONS (fntype);
int type_quals = TYPE_UNQUALIFIED;
int dup_quals = TYPE_UNQUALIFIED;
+ int this_quals = TYPE_UNQUALIFIED;
do
{
int tq = cp_type_qual_from_rid (TREE_VALUE (quals));
- if (type_quals & tq)
+ if ((type_quals | this_quals) & tq)
dup_quals |= tq;
+ else if (tq & TYPE_QUAL_RESTRICT)
+ this_quals |= tq;
else
type_quals |= tq;
quals = TREE_CHAIN (quals);
@@ -817,7 +822,7 @@ grok_method_quals (ctype, function, quals)
fntype = build_exception_variant (fntype, raises);
TREE_TYPE (function) = fntype;
- return ctype;
+ return this_quals;
}
/* Warn when -fexternal-templates is used and #pragma
@@ -961,9 +966,7 @@ grokclassfn (ctype, function, flags, quals)
tree quals;
{
tree fn_name = DECL_NAME (function);
- tree arg_types;
- tree parm;
- tree qualtype;
+ int this_quals = TYPE_UNQUALIFIED;
if (fn_name == NULL_TREE)
{
@@ -973,26 +976,23 @@ grokclassfn (ctype, function, flags, quals)
}
if (quals)
- qualtype = grok_method_quals (ctype, function, quals);
- else
- qualtype = ctype;
+ this_quals = grok_method_quals (ctype, function, quals);
- arg_types = TYPE_ARG_TYPES (TREE_TYPE (function));
if (TREE_CODE (TREE_TYPE (function)) == METHOD_TYPE)
{
/* Must add the class instance variable up front. */
/* Right now we just make this a pointer. But later
we may wish to make it special. */
- tree type = TREE_VALUE (arg_types);
+ tree type = TREE_VALUE (TYPE_ARG_TYPES (TREE_TYPE (function)));
- parm = build_decl (PARM_DECL, this_identifier, type);
+ tree parm = build_decl (PARM_DECL, this_identifier,
+ cp_build_qualified_type (type, this_quals | TYPE_QUAL_CONST));
/* Mark the artificial `this' parameter as "artificial". */
SET_DECL_ARTIFICIAL (parm);
DECL_ARG_TYPE (parm) = type;
/* We can make this a register, so long as we don't
accidentally complain if someone tries to take its address. */
DECL_REGISTER (parm) = 1;
- TREE_READONLY (parm) = 1;
TREE_CHAIN (parm) = last_function_parms;
last_function_parms = parm;
}
@@ -1003,10 +1003,7 @@ grokclassfn (ctype, function, flags, quals)
DECL_CLASS_CONTEXT (function) = ctype;
if (flags == DTOR_FLAG || DECL_CONSTRUCTOR_P (function))
- {
- maybe_retrofit_in_chrg (function);
- arg_types = TYPE_ARG_TYPES (TREE_TYPE (function));
- }
+ maybe_retrofit_in_chrg (function);
if (flags == DTOR_FLAG)
{
diff --git a/gcc/extend.texi b/gcc/extend.texi
index 1a8f698..17f12c9 100644
--- a/gcc/extend.texi
+++ b/gcc/extend.texi
@@ -3219,6 +3219,7 @@ Predefined Macros,cpp.info,The C Preprocessor}).
* Naming Results:: Giving a name to C++ function return values.
* Min and Max:: C++ Minimum and maximum operators.
* Volatiles:: What constitutes an access to a volatile object.
+* Restricted Pointers:: C9X restricted pointers and references.
* C++ Interface:: You can use a single C++ header file for both
declarations and definitions.
* Template Instantiation:: Methods for ensuring that exactly one copy of
@@ -3466,6 +3467,55 @@ possible to ignore the return value from functions returning volatile
references. Again, if you wish to force a read, cast the reference to
an rvalue.
+@node Restricted Pointers
+@section Restricting Pointer Aliasing
+@cindex restricted pointers
+@cindex restricted references
+@cindex restricted this pointer
+
+As with gcc, g++ understands the C9X proposal of restricted pointers,
+specified with the @code{__restrict__}, or @code{__restrict} type
+qualifier. Because you cannot compile C++ by specifying the -flang-isoc9x
+language flag, @code{restrict} is not a keyword in C++.
+
+In addition to allowing restricted pointers, you can specify restricted
+references, which indicate that the reference is not aliased in the local
+context.
+
+@example
+void fn (int *__restrict__ rptr, int &__restrict__ rref)
+@{
+ @dots{}
+@}
+@end example
+
+@noindent
+In the body of @code{fn}, @var{rptr} points to an unaliased integer and
+@var{rref} refers to a (different) unaliased integer.
+
+You may also specify whether a member function's @var{this} pointer is
+unaliased by using @code{__restrict__} as a member function qualifier.
+
+@example
+void T::fn () __restrict__
+@{
+ @dots{}
+@}
+@end example
+
+@noindent
+Within the body of @code{T::fn}, @var{this} will have the effective
+definition @code{T *__restrict__ const this}. Notice that the
+interpretation of a @code{__restrict__} member function qualifier is
+different to that of @code{const} or @code{volatile} qualifier, in that it
+is applied to the pointer rather than the object. This is consistent with
+other compilers which implement restricted pointers.
+
+As with all outermost parameter qualifiers, @code{__restrict__} is
+ignored in function definition matching. This means you only need to
+specify @code{__restrict__} in a function definition, rather than
+in a function prototype as well.
+
@node C++ Interface
@section Declarations and Definitions in One Header