From 3f3d6a6fa343d0c2af623559122a29cb21b7aa6c Mon Sep 17 00:00:00 2001 From: Marek Polacek Date: Fri, 21 Jun 2019 14:41:22 +0000 Subject: [PATCH] PR c++/90953 - ICE with -Wmissing-format-attribute. * c-common.c (check_function_arguments_recurse): Use get_attribute_name. (check_missing_format_attribute): Likewise. * g++.dg/warn/miss-format-7.C: New test. From-SVN: r272552 --- gcc/c-family/ChangeLog | 7 +++++++ gcc/c-family/c-common.c | 6 +++--- gcc/testsuite/ChangeLog | 5 +++++ gcc/testsuite/g++.dg/warn/miss-format-7.C | 29 +++++++++++++++++++++++++++++ 4 files changed, 44 insertions(+), 3 deletions(-) create mode 100644 gcc/testsuite/g++.dg/warn/miss-format-7.C diff --git a/gcc/c-family/ChangeLog b/gcc/c-family/ChangeLog index e744561..c1522b2 100644 --- a/gcc/c-family/ChangeLog +++ b/gcc/c-family/ChangeLog @@ -1,3 +1,10 @@ +2019-06-21 Marek Polacek + + PR c++/90953 - ICE with -Wmissing-format-attribute. + * c-common.c (check_function_arguments_recurse): Use + get_attribute_name. + (check_missing_format_attribute): Likewise. + 2019-06-19 Marek Polacek PR c++/60364 - noreturn after first decl not diagnosed. diff --git a/gcc/c-family/c-common.c b/gcc/c-family/c-common.c index 4057be3..f562704 100644 --- a/gcc/c-family/c-common.c +++ b/gcc/c-family/c-common.c @@ -5753,7 +5753,7 @@ check_function_arguments_recurse (void (*callback) for (attrs = TYPE_ATTRIBUTES (type); attrs; attrs = TREE_CHAIN (attrs)) - if (is_attribute_p ("format_arg", TREE_PURPOSE (attrs))) + if (is_attribute_p ("format_arg", get_attribute_name (attrs))) { tree inner_arg; tree format_num_expr; @@ -7601,13 +7601,13 @@ check_missing_format_attribute (tree ltype, tree rtype) tree ra; for (ra = TYPE_ATTRIBUTES (ttr); ra; ra = TREE_CHAIN (ra)) - if (is_attribute_p ("format", TREE_PURPOSE (ra))) + if (is_attribute_p ("format", get_attribute_name (ra))) break; if (ra) { tree la; for (la = TYPE_ATTRIBUTES (ttl); la; la = TREE_CHAIN (la)) - if (is_attribute_p ("format", TREE_PURPOSE (la))) + if (is_attribute_p ("format", get_attribute_name (la))) break; return !la; } diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog index 21eef28..55ca5ab 100644 --- a/gcc/testsuite/ChangeLog +++ b/gcc/testsuite/ChangeLog @@ -1,3 +1,8 @@ +2019-06-21 Marek Polacek + + PR c++/90953 - ICE with -Wmissing-format-attribute. + * g++.dg/warn/miss-format-7.C: New test. + 2019-06-21 Richard Biener PR debug/90914 diff --git a/gcc/testsuite/g++.dg/warn/miss-format-7.C b/gcc/testsuite/g++.dg/warn/miss-format-7.C new file mode 100644 index 0000000..ac892dc --- /dev/null +++ b/gcc/testsuite/g++.dg/warn/miss-format-7.C @@ -0,0 +1,29 @@ +// PR c++/90953 - ICE with -Wmissing-format-attribute. +// { dg-do compile { target c++11 } } +// { dg-options "-Wmissing-format-attribute" } + +namespace std { +union [[gnu::may_alias]] _Any_data{}; +enum _Manager_operation { __get_type_info }; +template class A; +class B { + typedef bool (*_Manager_type)(_Any_data, const _Any_data &, + _Manager_operation); +public: + _Any_data _M_functor; + _Manager_type _M_manager; +}; + +struct type_info { } t; + +template +class A<_Res(_ArgTypes...)> : B { + const type_info &target_type() const noexcept; +}; +template +const type_info &A<_Res(_ArgTypes...)>::target_type() const noexcept { + _Any_data __typeinfo_result; + _M_manager(__typeinfo_result, _M_functor, __get_type_info); + return t; +} +} // namespace std -- 2.7.4