From 79a2c4281c7dcaa6a138d24fd037c62453a12bde Mon Sep 17 00:00:00 2001 From: Martin Sebor Date: Fri, 9 Nov 2018 17:32:52 +0000 Subject: PR middle-end/81824 - Warn for missing attributes with function aliases gcc/c-family/ChangeLog: PR middle-end/81824 * c-attribs.c (handle_copy_attribute): New function. gcc/cp/ChangeLog: PR middle-end/81824 * pt.c (warn_spec_missing_attributes): Move code to attribs.c. Call decls_mismatched_attributes. gcc/ChangeLog: PR middle-end/81824 * attribs.c (has_attribute): New helper function. (decls_mismatched_attributes, maybe_diag_alias_attributes): Same. * attribs.h (decls_mismatched_attributes): Declare. * cgraphunit.c (handle_alias_pairs): Call maybe_diag_alias_attributes. (maybe_diag_incompatible_alias): Use OPT_Wattribute_alias_. * common.opt (-Wattribute-alias): Take an argument. (-Wno-attribute-alias): New option. * doc/extend.texi (Common Function Attributes): Document copy. (Common Variable Attributes): Same. * doc/invoke.texi (-Wmissing-attributes): Document enhancement. (-Wattribute-alias): Document new option argument. gcc/testsuite/ChangeLog: PR middle-end/81824 * gcc.dg/Wattribute-alias.c: New test. * gcc.dg/Wmissing-attributes.c: New test. * gcc.dg/attr-copy.c: New test. * gcc.dg/attr-copy-2.c: New test. * gcc.dg/attr-copy-3.c: New test. * gcc.dg/attr-copy-4.c: New test. From-SVN: r265980 --- gcc/cgraphunit.c | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) (limited to 'gcc/cgraphunit.c') diff --git a/gcc/cgraphunit.c b/gcc/cgraphunit.c index cb84954..2f0b70f 100644 --- a/gcc/cgraphunit.c +++ b/gcc/cgraphunit.c @@ -1364,7 +1364,7 @@ maybe_diag_incompatible_alias (tree alias, tree target) auto_diagnostic_group d; if (warning_at (DECL_SOURCE_LOCATION (target), - OPT_Wattribute_alias, + OPT_Wattribute_alias_, "% resolver for %qD should return %qT", alias, funcptr)) inform (DECL_SOURCE_LOCATION (alias), @@ -1374,11 +1374,11 @@ maybe_diag_incompatible_alias (tree alias, tree target) { auto_diagnostic_group d; if (warning_at (DECL_SOURCE_LOCATION (alias), - OPT_Wattribute_alias, + OPT_Wattribute_alias_, "%qD alias between functions of incompatible " "types %qT and %qT", alias, altype, targtype)) inform (DECL_SOURCE_LOCATION (target), - "aliased declaration here"); + "aliased declaration here"); } } } @@ -1441,6 +1441,8 @@ handle_alias_pairs (void) { maybe_diag_incompatible_alias (p->decl, target_node->decl); + maybe_diag_alias_attributes (p->decl, target_node->decl); + cgraph_node *src_node = cgraph_node::get (p->decl); if (src_node && src_node->definition) src_node->reset (); -- cgit v1.1