* C++ PATCH for c++/60872 (bogus error converting pointer to restricted pointer)
@ 2014-04-18 18:13 Jason Merrill
0 siblings, 0 replies; only message in thread
From: Jason Merrill @ 2014-04-18 18:13 UTC (permalink / raw)
To: gcc-patches List
[-- Attachment #1: Type: text/plain, Size: 181 bytes --]
When building up the internal representation of a conversion, G++ was
trying to apply 'restrict' to void, which doesn't make sense.
Tested x86_64-pc-linux-gnu, applying to trunk.
[-- Attachment #2: 60872.patch --]
[-- Type: text/x-patch, Size: 1216 bytes --]
commit 53c6cb04ee081b959788da69d36b8d4db1e3d442
Author: Jason Merrill <jason@redhat.com>
Date: Thu Apr 17 09:22:15 2014 -0400
PR c++/60872
* call.c (standard_conversion): Don't try to apply restrict to void.
diff --git a/gcc/cp/call.c b/gcc/cp/call.c
index 7dbe935..fbd2f83 100644
--- a/gcc/cp/call.c
+++ b/gcc/cp/call.c
@@ -1196,9 +1196,10 @@ standard_conversion (tree to, tree from, tree expr, bool c_cast_p,
&& TREE_CODE (TREE_TYPE (from)) != FUNCTION_TYPE)
{
tree nfrom = TREE_TYPE (from);
+ /* Don't try to apply restrict to void. */
+ int quals = cp_type_quals (nfrom) & ~TYPE_QUAL_RESTRICT;
from = build_pointer_type
- (cp_build_qualified_type (void_type_node,
- cp_type_quals (nfrom)));
+ (cp_build_qualified_type (void_type_node, quals));
conv = build_conv (ck_ptr, from, conv);
}
else if (TYPE_PTRDATAMEM_P (from))
diff --git a/gcc/testsuite/g++.dg/ext/restrict2.C b/gcc/testsuite/g++.dg/ext/restrict2.C
new file mode 100644
index 0000000..f053210
--- /dev/null
+++ b/gcc/testsuite/g++.dg/ext/restrict2.C
@@ -0,0 +1,8 @@
+// PR c++/60872
+// { dg-options "" }
+
+typedef double *__restrict T;
+void f(T* p)
+{
+ void *p2 = p;
+}
^ permalink raw reply [flat|nested] only message in thread
only message in thread, other threads:[~2014-04-18 18:11 UTC | newest]
Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2014-04-18 18:13 C++ PATCH for c++/60872 (bogus error converting pointer to restricted pointer) Jason Merrill
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).