* [C++ Patch] Fix grokbitfield location @ 2018-12-05 12:46 Paolo Carlini 2018-12-05 19:31 ` Jason Merrill 0 siblings, 1 reply; 4+ messages in thread From: Paolo Carlini @ 2018-12-05 12:46 UTC (permalink / raw) To: gcc-patches; +Cc: Jason Merrill [-- Attachment #1: Type: text/plain, Size: 305 bytes --] Hi, as mentioned in one of my last patches, we can now improve this location. Note: in the same function there are a few further issues which I mean to incrementally fix (eg, the diagnostics for warn_if_not_aligned ICEs for unnamed bit-fields). Tested x86_64-linux. Thanks, Paolo. //////////////// [-- Attachment #2: CL_grokbitfield1 --] [-- Type: text/plain, Size: 231 bytes --] /cp 2018-12-05 Paolo Carlini <paolo.carlini@oracle.com> * decl2.c (grokbitfield): USe DECL_SOURCE_LOCATION in error message. /testsuite 2018-12-05 Paolo Carlini <paolo.carlini@oracle.com> * g++.dg/parse/bitfield6b.C: New. [-- Attachment #3: patch_grokbitfield1 --] [-- Type: text/plain, Size: 868 bytes --] Index: cp/decl2.c =================================================================== --- cp/decl2.c (revision 266818) +++ cp/decl2.c (working copy) @@ -1027,7 +1027,8 @@ grokbitfield (const cp_declarator *declarator, && (INDIRECT_TYPE_P (value) || !dependent_type_p (TREE_TYPE (value)))) { - error ("bit-field %qD with non-integral type", value); + error_at (DECL_SOURCE_LOCATION (value), + "bit-field %qD with non-integral type", value); return error_mark_node; } Index: testsuite/g++.dg/parse/bitfield6b.C =================================================================== --- testsuite/g++.dg/parse/bitfield6b.C (nonexistent) +++ testsuite/g++.dg/parse/bitfield6b.C (working copy) @@ -0,0 +1,4 @@ +typedef void a(); +struct A { +a a1: 1; // { dg-error "3:bit-field .void A::a1\\(\\). with non-integral type" } +}; ^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [C++ Patch] Fix grokbitfield location 2018-12-05 12:46 [C++ Patch] Fix grokbitfield location Paolo Carlini @ 2018-12-05 19:31 ` Jason Merrill 2018-12-05 22:34 ` Paolo Carlini 0 siblings, 1 reply; 4+ messages in thread From: Jason Merrill @ 2018-12-05 19:31 UTC (permalink / raw) To: Paolo Carlini, gcc-patches On 12/5/18 7:45 AM, Paolo Carlini wrote: > Hi, > > as mentioned in one of my last patches, we can now improve this > location. Note: in the same function there are a few further issues > which I mean to incrementally fix (eg, the diagnostics for > warn_if_not_aligned ICEs for unnamed bit-fields). Tested x86_64-linux. As long as we're messing with this diagnostic, let's also print the type in question. Jason ^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [C++ Patch] Fix grokbitfield location 2018-12-05 19:31 ` Jason Merrill @ 2018-12-05 22:34 ` Paolo Carlini 2018-12-05 22:52 ` Jason Merrill 0 siblings, 1 reply; 4+ messages in thread From: Paolo Carlini @ 2018-12-05 22:34 UTC (permalink / raw) To: Jason Merrill, gcc-patches [-- Attachment #1: Type: text/plain, Size: 557 bytes --] Hi, On 05/12/18 20:31, Jason Merrill wrote: > On 12/5/18 7:45 AM, Paolo Carlini wrote: >> Hi, >> >> as mentioned in one of my last patches, we can now improve this >> location. Note: in the same function there are a few further issues >> which I mean to incrementally fix (eg, the diagnostics for >> warn_if_not_aligned ICEs for unnamed bit-fields). Tested x86_64-linux. > As long as we're messing with this diagnostic, let's also print the > type in question. Agreed. Thus I tested on x86_64-linux the below. Thanks, Paolo. ///////////////////// [-- Attachment #2: patch_grokbitfield1_2 --] [-- Type: text/plain, Size: 2248 bytes --] Index: cp/decl2.c =================================================================== --- cp/decl2.c (revision 266818) +++ cp/decl2.c (working copy) @@ -1016,7 +1016,9 @@ grokbitfield (const cp_declarator *declarator, if (value == error_mark_node) return NULL_TREE; /* friends went bad. */ - if (TREE_TYPE (value) == error_mark_node) + + tree type = TREE_TYPE (value); + if (type == error_mark_node) return value; /* Pass friendly classes back. */ @@ -1023,11 +1025,12 @@ grokbitfield (const cp_declarator *declarator, if (VOID_TYPE_P (value)) return void_type_node; - if (!INTEGRAL_OR_ENUMERATION_TYPE_P (TREE_TYPE (value)) - && (INDIRECT_TYPE_P (value) - || !dependent_type_p (TREE_TYPE (value)))) + if (!INTEGRAL_OR_ENUMERATION_TYPE_P (type) + && (INDIRECT_TYPE_P (value) || !dependent_type_p (type))) { - error ("bit-field %qD with non-integral type", value); + error_at (DECL_SOURCE_LOCATION (value), + "bit-field %qD with non-integral type %qT", + value, type); return error_mark_node; } @@ -1048,7 +1051,7 @@ grokbitfield (const cp_declarator *declarator, return NULL_TREE; } - if (width && TYPE_WARN_IF_NOT_ALIGN (TREE_TYPE (value))) + if (width && TYPE_WARN_IF_NOT_ALIGN (type)) { error ("cannot declare bit-field %qD with %<warn_if_not_aligned%> type", DECL_NAME (value)); Index: testsuite/g++.dg/parse/bitfield3.C =================================================================== --- testsuite/g++.dg/parse/bitfield3.C (revision 266818) +++ testsuite/g++.dg/parse/bitfield3.C (working copy) @@ -5,5 +5,5 @@ typedef void (func_type)(); struct A { - friend func_type f : 2; /* { dg-error "with non-integral type" } */ + friend func_type f : 2; /* { dg-error "20:bit-field .void f\\(\\). with non-integral type .func_type." } */ }; Index: testsuite/g++.dg/parse/bitfield6b.C =================================================================== --- testsuite/g++.dg/parse/bitfield6b.C (nonexistent) +++ testsuite/g++.dg/parse/bitfield6b.C (working copy) @@ -0,0 +1,4 @@ +typedef void a(); +struct A { +a a1: 1; // { dg-error "3:bit-field .void A::a1\\(\\). with non-integral type .void \\(A::\\)\\(\\)." } +}; ^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [C++ Patch] Fix grokbitfield location 2018-12-05 22:34 ` Paolo Carlini @ 2018-12-05 22:52 ` Jason Merrill 0 siblings, 0 replies; 4+ messages in thread From: Jason Merrill @ 2018-12-05 22:52 UTC (permalink / raw) To: Paolo Carlini, gcc-patches On 12/5/18 5:34 PM, Paolo Carlini wrote: > Hi, > > On 05/12/18 20:31, Jason Merrill wrote: >> On 12/5/18 7:45 AM, Paolo Carlini wrote: >>> Hi, >>> >>> as mentioned in one of my last patches, we can now improve this >>> location. Note: in the same function there are a few further issues >>> which I mean to incrementally fix (eg, the diagnostics for >>> warn_if_not_aligned ICEs for unnamed bit-fields). Tested x86_64-linux. >> As long as we're messing with this diagnostic, let's also print the >> type in question. > > Agreed. Thus I tested on x86_64-linux the below. > > Thanks, Paolo. > > ///////////////////// > > > - if (!INTEGRAL_OR_ENUMERATION_TYPE_P (TREE_TYPE (value)) > - && (INDIRECT_TYPE_P (value) > - || !dependent_type_p (TREE_TYPE (value)))) > + if (!INTEGRAL_OR_ENUMERATION_TYPE_P (type) > + && (INDIRECT_TYPE_P (value) || !dependent_type_p (type))) Hmm, surely this should be INDIRECT_TYPE_P (type). OK with that change. Jason ^ permalink raw reply [flat|nested] 4+ messages in thread
end of thread, other threads:[~2018-12-05 22:52 UTC | newest] Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed) -- links below jump to the message on this page -- 2018-12-05 12:46 [C++ Patch] Fix grokbitfield location Paolo Carlini 2018-12-05 19:31 ` Jason Merrill 2018-12-05 22:34 ` Paolo Carlini 2018-12-05 22:52 ` 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).