From 3f759575d3675150e665be997dd1e404e5c011f4 Mon Sep 17 00:00:00 2001 From: Jason Merrill Date: Tue, 3 Apr 2018 13:41:06 -0400 Subject: [PATCH] Fix noexcept merging with system headers. * typeck.c (merge_types): Limit matching attribute shortcut to the default case. From-SVN: r259042 --- gcc/cp/ChangeLog | 5 +++++ gcc/cp/typeck.c | 12 ++++++------ gcc/testsuite/g++.dg/cpp1z/noexcept-type19.C | 14 ++++++++++++++ gcc/testsuite/g++.dg/cpp1z/noexcept-type19.h | 4 ++++ 4 files changed, 29 insertions(+), 6 deletions(-) create mode 100644 gcc/testsuite/g++.dg/cpp1z/noexcept-type19.C create mode 100644 gcc/testsuite/g++.dg/cpp1z/noexcept-type19.h diff --git a/gcc/cp/ChangeLog b/gcc/cp/ChangeLog index ff3af265c95..405cf82b5d2 100644 --- a/gcc/cp/ChangeLog +++ b/gcc/cp/ChangeLog @@ -1,3 +1,8 @@ +2018-04-03 Jason Merrill + + * typeck.c (merge_types): Limit matching attribute shortcut to + the default case. + 2018-04-03 Jakub Jelinek PR c++/85147 diff --git a/gcc/cp/typeck.c b/gcc/cp/typeck.c index d454c6c5a29..e33f2c34c7f 100644 --- a/gcc/cp/typeck.c +++ b/gcc/cp/typeck.c @@ -899,14 +899,14 @@ merge_types (tree t1, tree t2) return t1; default:; + if (attribute_list_equal (TYPE_ATTRIBUTES (t1), attributes)) + return t1; + else if (attribute_list_equal (TYPE_ATTRIBUTES (t2), attributes)) + return t2; + break; } - if (attribute_list_equal (TYPE_ATTRIBUTES (t1), attributes)) - return t1; - else if (attribute_list_equal (TYPE_ATTRIBUTES (t2), attributes)) - return t2; - else - return cp_build_type_attribute_variant (t1, attributes); + return cp_build_type_attribute_variant (t1, attributes); } /* Return the ARRAY_TYPE type without its domain. */ diff --git a/gcc/testsuite/g++.dg/cpp1z/noexcept-type19.C b/gcc/testsuite/g++.dg/cpp1z/noexcept-type19.C new file mode 100644 index 00000000000..571c426aa67 --- /dev/null +++ b/gcc/testsuite/g++.dg/cpp1z/noexcept-type19.C @@ -0,0 +1,14 @@ +// { dg-do compile { target c++11 } } + +#include "noexcept-type19.h" + +extern "C" void *malloc (size_t); + +template void f(T*); + +void *g(size_t); + +int main() +{ + f(g); +} diff --git a/gcc/testsuite/g++.dg/cpp1z/noexcept-type19.h b/gcc/testsuite/g++.dg/cpp1z/noexcept-type19.h new file mode 100644 index 00000000000..33a29357e7f --- /dev/null +++ b/gcc/testsuite/g++.dg/cpp1z/noexcept-type19.h @@ -0,0 +1,4 @@ +#pragma GCC system_header + +typedef decltype(sizeof(0)) size_t; +extern "C" void *malloc (size_t) throw(); -- 2.30.2