RE: r351495 - Make integral-o-pointer conversions in SFINAE illegal.
Thanks for the heads up! Looking now. -Original Message- From: Peter Smith [mailto:peter.sm...@linaro.org] Sent: Friday, January 18, 2019 2:33 AM To: Keane, Erich Cc: cfe-commits cfe Subject: Re: r351495 - Make integral-o-pointer conversions in SFINAE illegal. Hello Erich, The test added in this commit is failing on the Arm and Hexagon builders. I think that this is because the expected type "long" in the warning text is "int" on these platforms (possibly other 32-bit host platforms). The raw output from an Arm machine is: llvm-project/clang/test/SemaCXX/int-ptr-cast-SFINAE.cpp:5:5: warning: incompatible integer to pointer conversion assigning to 'int *' from 'int'; take the address with & a -= b; // expected-warning {{incompatible integer to pointer conversion assigning to 'int *' from 'long'}} ^ ~ & Could you take a look and update the test? Thanks in advance Peter On Thu, 17 Jan 2019 at 23:14, Erich Keane via cfe-commits wrote: > > Author: erichkeane > Date: Thu Jan 17 15:11:15 2019 > New Revision: 351495 > > URL: http://llvm.org/viewvc/llvm-project?rev=351495=rev > Log: > Make integral-o-pointer conversions in SFINAE illegal. > > As reported in PR40362, allowing the conversion from an integral to a > pointer type (despite being illegal in the C++ standard) will cause > surprsing results when testing for certain behaviors in SFINAE. This > patch converts the error to a SFINAE Error and adds a test to ensure > that it is still a warning in non-SFINAE but an error in it. > > Change-Id: I1f475637fa4d83217ae37dc6b5dbf653e118fae4 > > Added: > cfe/trunk/test/SemaCXX/int-ptr-cast-SFINAE.cpp (with props) > Modified: > cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td > > Modified: cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td > URL: > http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Basic/Diag > nosticSemaKinds.td?rev=351495=351494=351495=diff > == > > --- cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td (original) > +++ cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td Thu Jan 17 > +++ 15:11:15 2019 > @@ -6817,7 +6817,7 @@ def ext_typecheck_convert_int_pointer : >"; take the address with &|" >"; remove *|" >"; remove &}3">, > - InGroup; > + InGroup, SFINAEFailure; > def ext_typecheck_convert_pointer_void_func : Extension< >"%select{%diff{assigning to $ from $|assigning to different types}0,1" >"|%diff{passing $ to parameter of type $|" > > Added: cfe/trunk/test/SemaCXX/int-ptr-cast-SFINAE.cpp > URL: > http://llvm.org/viewvc/llvm-project/cfe/trunk/test/SemaCXX/int-ptr-cas > t-SFINAE.cpp?rev=351495=auto > == > > --- cfe/trunk/test/SemaCXX/int-ptr-cast-SFINAE.cpp (added) > +++ cfe/trunk/test/SemaCXX/int-ptr-cast-SFINAE.cpp Thu Jan 17 15:11:15 > +++ 2019 > @@ -0,0 +1,22 @@ > +// RUN: %clang_cc1 -fsyntax-only -verify %s // RUN: %clang_cc1 > +-fsyntax-only -verify %s -std=c++17 > + > +void foo(int* a, int *b) { > + a -= b; // expected-warning {{incompatible integer to pointer > +conversion assigning to 'int *' from 'long'}} } > + > +template T declval(); > +struct true_type { static const bool value = true; }; struct > +false_type { static const bool value = false; }; template +typename T, typename U> struct select { using type = T; }; > +template struct select { using > +type = U; }; > + > + > +template > +typename select<(sizeof(declval() -= declval(), 1) != 1), > +true_type, false_type>::type test(...); template > +false_type test(...); > + > +template > +static const auto has_minus_assign = decltype(test())::value; > + > +static_assert(has_minus_assign, "failed"); // expected-error > +{{static_assert failed due to requirement 'has_minus_assign' > +"failed"}} > > Propchange: cfe/trunk/test/SemaCXX/int-ptr-cast-SFINAE.cpp > -- > svn:eol-style = native > > Propchange: cfe/trunk/test/SemaCXX/int-ptr-cast-SFINAE.cpp > -- > svn:keywords = "Author Date Id Rev URL" > > Propchange: cfe/trunk/test/SemaCXX/int-ptr-cast-SFINAE.cpp > -- > svn:mime-type = text/plain > > > ___ > cfe-commits mailing list > cfe-commits@lists.llvm.org > http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
Re: r351495 - Make integral-o-pointer conversions in SFINAE illegal.
Hello Erich, The test added in this commit is failing on the Arm and Hexagon builders. I think that this is because the expected type "long" in the warning text is "int" on these platforms (possibly other 32-bit host platforms). The raw output from an Arm machine is: llvm-project/clang/test/SemaCXX/int-ptr-cast-SFINAE.cpp:5:5: warning: incompatible integer to pointer conversion assigning to 'int *' from 'int'; take the address with & a -= b; // expected-warning {{incompatible integer to pointer conversion assigning to 'int *' from 'long'}} ^ ~ & Could you take a look and update the test? Thanks in advance Peter On Thu, 17 Jan 2019 at 23:14, Erich Keane via cfe-commits wrote: > > Author: erichkeane > Date: Thu Jan 17 15:11:15 2019 > New Revision: 351495 > > URL: http://llvm.org/viewvc/llvm-project?rev=351495=rev > Log: > Make integral-o-pointer conversions in SFINAE illegal. > > As reported in PR40362, allowing the conversion from an integral to a > pointer type (despite being illegal in the C++ standard) will cause > surprsing results when testing for certain behaviors in SFINAE. This > patch converts the error to a SFINAE Error and adds a test to ensure > that it is still a warning in non-SFINAE but an error in it. > > Change-Id: I1f475637fa4d83217ae37dc6b5dbf653e118fae4 > > Added: > cfe/trunk/test/SemaCXX/int-ptr-cast-SFINAE.cpp (with props) > Modified: > cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td > > Modified: cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td > URL: > http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td?rev=351495=351494=351495=diff > == > --- cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td (original) > +++ cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td Thu Jan 17 15:11:15 > 2019 > @@ -6817,7 +6817,7 @@ def ext_typecheck_convert_int_pointer : >"; take the address with &|" >"; remove *|" >"; remove &}3">, > - InGroup; > + InGroup, SFINAEFailure; > def ext_typecheck_convert_pointer_void_func : Extension< >"%select{%diff{assigning to $ from $|assigning to different types}0,1" >"|%diff{passing $ to parameter of type $|" > > Added: cfe/trunk/test/SemaCXX/int-ptr-cast-SFINAE.cpp > URL: > http://llvm.org/viewvc/llvm-project/cfe/trunk/test/SemaCXX/int-ptr-cast-SFINAE.cpp?rev=351495=auto > == > --- cfe/trunk/test/SemaCXX/int-ptr-cast-SFINAE.cpp (added) > +++ cfe/trunk/test/SemaCXX/int-ptr-cast-SFINAE.cpp Thu Jan 17 15:11:15 2019 > @@ -0,0 +1,22 @@ > +// RUN: %clang_cc1 -fsyntax-only -verify %s > +// RUN: %clang_cc1 -fsyntax-only -verify %s -std=c++17 > + > +void foo(int* a, int *b) { > + a -= b; // expected-warning {{incompatible integer to pointer conversion > assigning to 'int *' from 'long'}} > +} > + > +template T declval(); > +struct true_type { static const bool value = true; }; > +struct false_type { static const bool value = false; }; > +template struct select { using type = T; }; > +template struct select { using type = > U; }; > + > + > +template > +typename select<(sizeof(declval() -= declval(), 1) != 1), true_type, > false_type>::type test(...); > +template false_type test(...); > + > +template > +static const auto has_minus_assign = decltype(test())::value; > + > +static_assert(has_minus_assign, "failed"); // expected-error > {{static_assert failed due to requirement 'has_minus_assign' "failed"}} > > Propchange: cfe/trunk/test/SemaCXX/int-ptr-cast-SFINAE.cpp > -- > svn:eol-style = native > > Propchange: cfe/trunk/test/SemaCXX/int-ptr-cast-SFINAE.cpp > -- > svn:keywords = "Author Date Id Rev URL" > > Propchange: cfe/trunk/test/SemaCXX/int-ptr-cast-SFINAE.cpp > -- > svn:mime-type = text/plain > > > ___ > cfe-commits mailing list > cfe-commits@lists.llvm.org > http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
r351495 - Make integral-o-pointer conversions in SFINAE illegal.
Author: erichkeane Date: Thu Jan 17 15:11:15 2019 New Revision: 351495 URL: http://llvm.org/viewvc/llvm-project?rev=351495=rev Log: Make integral-o-pointer conversions in SFINAE illegal. As reported in PR40362, allowing the conversion from an integral to a pointer type (despite being illegal in the C++ standard) will cause surprsing results when testing for certain behaviors in SFINAE. This patch converts the error to a SFINAE Error and adds a test to ensure that it is still a warning in non-SFINAE but an error in it. Change-Id: I1f475637fa4d83217ae37dc6b5dbf653e118fae4 Added: cfe/trunk/test/SemaCXX/int-ptr-cast-SFINAE.cpp (with props) Modified: cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td Modified: cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td?rev=351495=351494=351495=diff == --- cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td (original) +++ cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td Thu Jan 17 15:11:15 2019 @@ -6817,7 +6817,7 @@ def ext_typecheck_convert_int_pointer : "; take the address with &|" "; remove *|" "; remove &}3">, - InGroup; + InGroup, SFINAEFailure; def ext_typecheck_convert_pointer_void_func : Extension< "%select{%diff{assigning to $ from $|assigning to different types}0,1" "|%diff{passing $ to parameter of type $|" Added: cfe/trunk/test/SemaCXX/int-ptr-cast-SFINAE.cpp URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/SemaCXX/int-ptr-cast-SFINAE.cpp?rev=351495=auto == --- cfe/trunk/test/SemaCXX/int-ptr-cast-SFINAE.cpp (added) +++ cfe/trunk/test/SemaCXX/int-ptr-cast-SFINAE.cpp Thu Jan 17 15:11:15 2019 @@ -0,0 +1,22 @@ +// RUN: %clang_cc1 -fsyntax-only -verify %s +// RUN: %clang_cc1 -fsyntax-only -verify %s -std=c++17 + +void foo(int* a, int *b) { + a -= b; // expected-warning {{incompatible integer to pointer conversion assigning to 'int *' from 'long'}} +} + +template T declval(); +struct true_type { static const bool value = true; }; +struct false_type { static const bool value = false; }; +template struct select { using type = T; }; +template struct select { using type = U; }; + + +template +typename select<(sizeof(declval() -= declval(), 1) != 1), true_type, false_type>::type test(...); +template false_type test(...); + +template +static const auto has_minus_assign = decltype(test())::value; + +static_assert(has_minus_assign, "failed"); // expected-error {{static_assert failed due to requirement 'has_minus_assign' "failed"}} Propchange: cfe/trunk/test/SemaCXX/int-ptr-cast-SFINAE.cpp -- svn:eol-style = native Propchange: cfe/trunk/test/SemaCXX/int-ptr-cast-SFINAE.cpp -- svn:keywords = "Author Date Id Rev URL" Propchange: cfe/trunk/test/SemaCXX/int-ptr-cast-SFINAE.cpp -- svn:mime-type = text/plain ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits