From 0213a355281c1ce387d9fae4061d18f6b9bcd54e Mon Sep 17 00:00:00 2001 From: Jason Merrill Date: Fri, 24 Aug 2001 08:07:46 -0400 Subject: c-common.c (c_alignof, [...]): Move here... * c-common.c (c_alignof, c_alignof_expr): Move here... * c-typeck.c: ...from here. * c-tree.h, c-common.h: Adjust. * tree.c (cp_build_qualified_type_real): Use get_qualified_type. (build_cplus_array_type): Use cp_build_qualified_type, not TYPE_MAIN_VARIANT, to get an unqualified version. * decl2.c (grok_alignof): Lose. (build_expr_from_tree): Use expr_sizeof and c_alignof_expr. * typeck.c (c_alignof): Lose. * semantics.c (finish_sizeof, finish_alignof): New. * parse.y: Use them. * cp-tree.h: Declare them. From-SVN: r45145 --- gcc/cp/semantics.c | 28 ++++++++++++++++++++++++++++ 1 file changed, 28 insertions(+) (limited to 'gcc/cp/semantics.c') diff --git a/gcc/cp/semantics.c b/gcc/cp/semantics.c index c295bde..fbfd756 100644 --- a/gcc/cp/semantics.c +++ b/gcc/cp/semantics.c @@ -2165,6 +2165,9 @@ check_multiple_declarators () cp_error ("multiple declarators in template declaration"); } +/* Implement the __typeof keyword: Return the type of EXPR, suitable for + use as a type-specifier. */ + tree finish_typeof (expr) tree expr; @@ -2185,6 +2188,31 @@ finish_typeof (expr) return TREE_TYPE (expr); } +/* Compute the value of the `sizeof' operator. */ + +tree +finish_sizeof (t) + tree t; +{ + if (processing_template_decl) + return build_min (SIZEOF_EXPR, sizetype, t); + + return TYPE_P (t) ? c_sizeof (t) : expr_sizeof (t); +} + +/* Implement the __alignof keyword: Return the minimum required + alignment of T, measured in bytes. */ + +tree +finish_alignof (t) + tree t; +{ + if (processing_template_decl) + return build_min (ALIGNOF_EXPR, sizetype, t); + + return TYPE_P (t) ? c_alignof (t) : c_alignof_expr (t); +} + /* Generate RTL for the statement T, and its substatements, and any other statements at its nesting level. */ -- cgit v1.1