From 8be7ab5d48fe7798721464d797634301f33a85bc Mon Sep 17 00:00:00 2001 From: Nathan Sidwell Date: Wed, 15 Dec 1999 12:39:02 +0000 Subject: [PATCH] typeck.c (build_c_cast): Expand warning message. * typeck.c (build_c_cast): Expand warning message. Move pointer alignment warning to after the cast. Don't warn about pointer alignment when given a pointer to incomplete. fix cut-n-paste error on 1999-12-09 Andreas Jaeger and 1999-12-09 Mark Mitchell (was 11999 & 999) From-SVN: r30952 --- gcc/cp/ChangeLog | 11 +++++++++-- gcc/cp/typeck.c | 25 +++++++++++++++---------- 2 files changed, 24 insertions(+), 12 deletions(-) diff --git a/gcc/cp/ChangeLog b/gcc/cp/ChangeLog index 949e64a0183..ac432dc24a8 100644 --- a/gcc/cp/ChangeLog +++ b/gcc/cp/ChangeLog @@ -1,3 +1,9 @@ +1999-12-15 Nathan Sidwell + + * typeck.c (build_c_cast): Expand warning message. Move pointer + alignment warning to after the cast. Don't warn about pointer + alignment when given a pointer to incomplete. + 1999-12-15 Richard Henderson * cp-tree.h (make_aggr_type): Declare. @@ -61,6 +67,7 @@ (reinit_parse_for_expr): Use. (check_newline): Use. +>>>>>>> 1.1463 1999-12-13 Mark Mitchell * optimize.c (initialize_inlined_parameters): Take FN to which the @@ -89,7 +96,7 @@ * pt.c (for_each_template_parm_r): Add static prototype. -11999-12-09 Andreas Jaeger +1999-12-09 Andreas Jaeger * except.c (expand_throw): Add static attribute to match prototype. @@ -98,7 +105,7 @@ * semantics.c: Include output.h for declaration of make_function_rtl. -999-12-09 Mark Mitchell +1999-12-09 Mark Mitchell * decl.c (init_decl_processing): Reenable inlining on trees. (finish_function): Likewise. diff --git a/gcc/cp/typeck.c b/gcc/cp/typeck.c index 7325653c800..c99d153a953 100644 --- a/gcc/cp/typeck.c +++ b/gcc/cp/typeck.c @@ -5499,16 +5499,8 @@ build_c_cast (type, expr) && TREE_CODE (otype) == POINTER_TYPE && !at_least_as_qualified_p (TREE_TYPE (type), TREE_TYPE (otype))) - cp_warning ("cast discards qualifiers from pointer target type"); - - /* Warn about possible alignment problems. */ - if (STRICT_ALIGNMENT && warn_cast_align - && TREE_CODE (type) == POINTER_TYPE - && TREE_CODE (otype) == POINTER_TYPE - && TREE_CODE (TREE_TYPE (otype)) != VOID_TYPE - && TREE_CODE (TREE_TYPE (otype)) != FUNCTION_TYPE - && TYPE_ALIGN (TREE_TYPE (type)) > TYPE_ALIGN (TREE_TYPE (otype))) - warning ("cast increases required alignment of target type"); + cp_warning ("cast from `%T' to `%T' discards qualifiers from pointer target type", + otype, type); #if 0 /* We should see about re-enabling these, they seem useful to @@ -5549,6 +5541,19 @@ build_c_cast (type, expr) } } + /* Warn about possible alignment problems. Do this here when we will have + instantiated any necessary template types. */ + if (STRICT_ALIGNMENT && warn_cast_align + && TREE_CODE (type) == POINTER_TYPE + && TREE_CODE (otype) == POINTER_TYPE + && TREE_CODE (TREE_TYPE (otype)) != VOID_TYPE + && TREE_CODE (TREE_TYPE (otype)) != FUNCTION_TYPE + && TYPE_SIZE (TREE_TYPE (otype)) + && TYPE_SIZE (TREE_TYPE (type)) + && TYPE_ALIGN (TREE_TYPE (type)) > TYPE_ALIGN (TREE_TYPE (otype))) + cp_warning ("cast from `%T' to `%T' increases required alignment of target type", + otype, type); + /* Always produce some operator for an explicit cast, so we can tell (for -pedantic) that the cast is no lvalue. */ if (TREE_CODE (type) != REFERENCE_TYPE && value == expr -- 2.30.2