summaryrefslogtreecommitdiff
path: root/gcc/doc/extend.texi
diff options
context:
space:
mode:
authorrth <rth@138bc75d-0d04-0410-961f-82ee72b054a4>2004-06-01 15:12:23 +0000
committerrth <rth@138bc75d-0d04-0410-961f-82ee72b054a4>2004-06-01 15:12:23 +0000
commit43bf5d72a08229da09c59460922275147fe59e48 (patch)
treebfb9b2da79e35521eae05ac845e476d726baa281 /gcc/doc/extend.texi
parent825f1d8bb31e4a398ca99ca16f90de14e6f06703 (diff)
downloadgcc-43bf5d72a08229da09c59460922275147fe59e48.tar.gz
* c-parse.in (OFFSETOF, offsetof_member_designator): New.
(primary): Handle offsetof. Add error productions for faux functions. Move component_ref objc checking to build_component_ref. (reswords): Add offsetof. (rid_to_yy): Add offsetof. * c-tree.h (build_offsetof): Declare. * c-common.h (objc_is_public): Declare. * c-typeck.c (build_component_ref): Check objc_is_public. (build_offsetof): New. * stub-objc.c (objc_is_public): New. * objc/objc-act.c, objc/objc-act.h (objc_is_public): Rename from is_public. * ginclude/stddef.h (offsetof): Use __builtin_offsetof. * doc/extend.texi (Offsetof): Move from C++ section to C section and rewrite for __builtin_offsetof. cp/ * lex.c (reswords): Rename "__offsetof" to "__builtin_offsetof". * parser.c (struct cp_parser): Remove in_offsetof. (cp_parser_new): Don't set it. (cp_parser_unary_expression): Don't check it. (cp_parser_postfix_open_square_expression): Split out from ... (cp_parser_postfix_expression): ... here. (cp_parser_postfix_dot_deref_expression): Likewise. (cp_parser_builtin_offsetof): New. (cp_parser_primary_expression): Use it. testsuite/ * g++.dg/template/dependent-expr4.C: Use __builtin_offsetof. git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@82549 138bc75d-0d04-0410-961f-82ee72b054a4
Diffstat (limited to 'gcc/doc/extend.texi')
-rw-r--r--gcc/doc/extend.texi48
1 files changed, 28 insertions, 20 deletions
diff --git a/gcc/doc/extend.texi b/gcc/doc/extend.texi
index 22f5f29efd1..204c64b1006 100644
--- a/gcc/doc/extend.texi
+++ b/gcc/doc/extend.texi
@@ -469,6 +469,7 @@ extensions, accepted by GCC in C89 mode and in C++.
function.
* Return Address:: Getting the return or frame address of a function.
* Vector Extensions:: Using vector instructions through built-in functions.
+* Offsetof:: Special syntax for implementing @code{offsetof}.
* Other Builtins:: Other built-in functions.
* Target Builtins:: Built-in functions specific to particular targets.
* Pragmas:: Pragmas accepted by GCC.
@@ -4704,6 +4705,33 @@ v4si f (v4si a, v4si b, v4si c)
@end smallexample
+@node Offsetof
+@section Offsetof
+@findex __builtin_offsetof
+
+GCC implements for both C and C++ a syntactic extension to implement
+the @code{offsetof} macro.
+
+@smallexample
+primary:
+ "__builtin_offsetof" "(" @code{typename} "," offsetof_member_designator ")"
+
+offsetof_member_designator:
+ @code{identifier}
+ | offsetof_member_designator "." @code{identifier}
+ | offsetof_member_designator "[" @code{expr} "]"
+@end smallexample
+
+This extension is sufficient such that
+
+@smallexample
+#define offsetof(@var{type}, @var{member}) __builtin_offsetof (@var{type}, @var{member})
+@end smallexample
+
+is a suitable definition of the @code{offsetof} macro. In C++, @var{type}
+may be dependent. In either case, @var{member} may consist of a single
+identifier, or a sequence of member accesses and array references.
+
@node Other Builtins
@section Other built-in functions provided by GCC
@cindex built-in functions
@@ -7620,7 +7648,6 @@ Predefined Macros,cpp,The GNU C Preprocessor}).
method denoted by a @samp{->*} or @samp{.*} expression.
* C++ Attributes:: Variable, function, and type attributes for C++ only.
* Strong Using:: Strong using-directives for namespace composition.
-* Offsetof:: Special syntax for implementing @code{offsetof}.
* Java Exceptions:: Tweaking exception handling to work with Java.
* Deprecated Features:: Things will disappear from g++.
* Backwards Compatibility:: Compatibilities with earlier definitions of C++.
@@ -8265,25 +8292,6 @@ int main()
@}
@end smallexample
-@node Offsetof
-@section Offsetof
-
-G++ uses a syntactic extension to implement the @code{offsetof} macro.
-
-In particular:
-
-@smallexample
- __offsetof__ (expression)
-@end smallexample
-
-is equivalent to the parenthesized expression, except that the
-expression is considered an integral constant expression even if it
-contains certain operators that are not normally permitted in an
-integral constant expression. Users should never use
-@code{__offsetof__} directly; the only valid use of
-@code{__offsetof__} is to implement the @code{offsetof} macro in
-@code{<stddef.h>}.
-
@node Java Exceptions
@section Java Exceptions