aboutsummaryrefslogtreecommitdiff
path: root/gcc
diff options
context:
space:
mode:
authorJason Merrill <jason@redhat.com>2018-04-03 13:41:06 -0400
committerJason Merrill <jason@gcc.gnu.org>2018-04-03 13:41:06 -0400
commit3f759575d3675150e665be997dd1e404e5c011f4 (patch)
tree7b0657845dab376aef31f53dd521a51bfb06a5a6 /gcc
parentb4231bf26e398d6799facf6bc93caeefd7d16d5a (diff)
downloadgcc-3f759575d3675150e665be997dd1e404e5c011f4.zip
gcc-3f759575d3675150e665be997dd1e404e5c011f4.tar.gz
gcc-3f759575d3675150e665be997dd1e404e5c011f4.tar.bz2
Fix noexcept merging with system headers.
* typeck.c (merge_types): Limit matching attribute shortcut to the default case. From-SVN: r259042
Diffstat (limited to 'gcc')
-rw-r--r--gcc/cp/ChangeLog5
-rw-r--r--gcc/cp/typeck.c12
-rw-r--r--gcc/testsuite/g++.dg/cpp1z/noexcept-type19.C14
-rw-r--r--gcc/testsuite/g++.dg/cpp1z/noexcept-type19.h4
4 files changed, 29 insertions, 6 deletions
diff --git a/gcc/cp/ChangeLog b/gcc/cp/ChangeLog
index ff3af26..405cf82 100644
--- a/gcc/cp/ChangeLog
+++ b/gcc/cp/ChangeLog
@@ -1,3 +1,8 @@
+2018-04-03 Jason Merrill <jason@redhat.com>
+
+ * typeck.c (merge_types): Limit matching attribute shortcut to
+ the default case.
+
2018-04-03 Jakub Jelinek <jakub@redhat.com>
PR c++/85147
diff --git a/gcc/cp/typeck.c b/gcc/cp/typeck.c
index d454c6c..e33f2c3 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 0000000..571c426
--- /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<class T> void f(T*);
+
+void *g(size_t);
+
+int main()
+{
+ f<decltype(malloc)>(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 0000000..33a2935
--- /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();