Re: [pushed] Objective-C/C++ (parsers) : Update @property attribute parsing.
Martin Liška wrote: On 11/16/20 10:00 AM, Iain Sandoe wrote: ../../gcc/c-family/stub-objc.c:30: note: an enum with different value name is defined in another translation unit 30 | enum rid { DUMMY }; I’m not disagreeing, of course (and will sort it out).. .. but I don’t see this warning in my builds on either Linux or Darwin - what are the build conditions you use to get it? You can see it with: ./configure --with-build-config=bootstrap-lto && make .. thanks, should be fixed by: https://gcc.gnu.org/pipermail/gcc-patches/2020-November/559278.html thanks Iain
Re: [pushed] Objective-C/C++ (parsers) : Update @property attribute parsing.
On 11/16/20 10:00 AM, Iain Sandoe wrote: Hi Martin, Martin Liška wrote: On 11/6/20 8:54 PM, Iain Sandoe wrote: +/* Provide a dummy type for the RID enum used as an argument to + objc_prop_attr_kind_for_rid () */ +enum rid { DUMMY }; + I've noticed the hunk caused the following -Wodr warning: ../libdecnumber/libdecnumber.a -lmpc -lmpfr -lgmp -rdynamic -ldl -L./../zlib -lz ../../gcc/c-family/c-common.h:63: warning: type ‘rid’ violates the C++ One Definition Rule [-Wodr] 63 | enum rid | ../../gcc/c-family/stub-objc.c:30: note: an enum with different value name is defined in another translation unit 30 | enum rid { DUMMY }; I’m not disagreeing, of course (and will sort it out).. .. but I don’t see this warning in my builds on either Linux or Darwin - what are the build conditions you use to get it? You can see it with: ./configure --with-build-config=bootstrap-lto && make .. Martin thanks Iain
Re: [pushed] Objective-C/C++ (parsers) : Update @property attribute parsing.
Hi Martin, Martin Liška wrote: On 11/6/20 8:54 PM, Iain Sandoe wrote: +/* Provide a dummy type for the RID enum used as an argument to + objc_prop_attr_kind_for_rid () */ +enum rid { DUMMY }; + I've noticed the hunk caused the following -Wodr warning: ../libdecnumber/libdecnumber.a -lmpc -lmpfr -lgmp -rdynamic -ldl -L./../zlib -lz ../../gcc/c-family/c-common.h:63: warning: type ‘rid’ violates the C++ One Definition Rule [-Wodr] 63 | enum rid | ../../gcc/c-family/stub-objc.c:30: note: an enum with different value name is defined in another translation unit 30 | enum rid { DUMMY }; I’m not disagreeing, of course (and will sort it out).. .. but I don’t see this warning in my builds on either Linux or Darwin - what are the build conditions you use to get it? thanks Iain
Re: [pushed] Objective-C/C++ (parsers) : Update @property attribute parsing.
On 11/6/20 8:54 PM, Iain Sandoe wrote: +/* Provide a dummy type for the RID enum used as an argument to + objc_prop_attr_kind_for_rid () */ +enum rid { DUMMY }; + Hello. I've noticed the hunk caused the following -Wodr warning: /home/mliska/Programming/gcc/objdir/./prev-gcc/xg++ -B/home/mliska/Programming/gcc/objdir/./prev-gcc/ -B/usr/local/x86_64-pc-linux-gnu/bin/ -nostdinc++ -B/home/mliska/Programming/gcc/objdir/prev-x86_64-pc-linux-gnu/libstdc++-v3/src/.libs -B/home/mliska/Programming/gcc/objdir/prev-x86_64-pc-linux-gnu/libstdc++-v3/libsupc++/.libs -I/home/mliska/Programming/gcc/objdir/prev-x86_64-pc-linux-gnu/libstdc++-v3/include/x86_64-pc-linux-gnu -I/home/mliska/Programming/gcc/objdir/prev-x86_64-pc-linux-gnu/libstdc++-v3/include -I/home/mliska/Programming/gcc/libstdc++-v3/libsupc++ -L/home/mliska/Programming/gcc/objdir/prev-x86_64-pc-linux-gnu/libstdc++-v3/src/.libs -L/home/mliska/Programming/gcc/objdir/prev-x86_64-pc-linux-gnu/libstdc++-v3/libsupc++/.libs -no-pie -g -O2 -fchecking=1 -flto=jobserver -frandom-seed=1 -DIN_GCC -fno-exceptions -fno-rtti -fasynchronous-unwind-tables -W -Wall -Wno-narrowing -Wwrite-strings -Wcast-qual -Wno-error=format-diag -Wmissing-format-attribute -Woverloaded-virtual -pedantic -Wno-long-long -Wno-variadic-macros -Wno-overlength-strings -fno-common -DHAVE_CONFIG_H -static-libstdc++ -static-libgcc -o cc1plus \ cp/cp-lang.o c-family/stub-objc.o cp/call.o cp/class.o cp/constexpr.o cp/constraint.o cp/coroutines.o cp/cp-gimplify.o cp/cp-objcp-common.o cp/cp-ubsan.o cp/cvt.o cp/cxx-pretty-print.o cp/decl.o cp/decl2.o cp/dump.o cp/error.o cp/except.o cp/expr.o cp/friend.o cp/init.o cp/lambda.o cp/lex.o cp/logic.o cp/mangle.o cp/method.o cp/name-lookup.o cp/optimize.o cp/parser.o cp/pt.o cp/ptree.o cp/rtti.o cp/search.o cp/semantics.o cp/tree.o cp/typeck.o cp/typeck2.o cp/vtable-class-hierarchy.o attribs.o incpath.o c-family/c-common.o c-family/c-cppbuiltin.o c-family/c-dump.o c-family/c-format.o c-family/c-gimplify.o c-family/c-indentation.o c-family/c-lex.o c-family/c-omp.o c-family/c-opts.o c-family/c-pch.o c-family/c-ppoutput.o c-family/c-pragma.o c-family/c-pretty-print.o c-family/c-semantics.o c-family/c-ada-spec.o c-family/c-ubsan.o c-family/known-headers.o c-family/c-attribs.o c-family/c-warn.o c-family/c-spellcheck.o i386-c.o glibc-c.o cc1plus-checksum.o libbackend.a main.o libcommon-target.a libcommon.a ../libcpp/libcpp.a ../libdecnumber/libdecnumber.a libcommon.a ../libcpp/libcpp.a ../libbacktrace/.libs/libbacktrace.a ../libiberty/libiberty.a ../libdecnumber/libdecnumber.a -lmpc -lmpfr -lgmp -rdynamic -ldl -L./../zlib -lz ../../gcc/c-family/c-common.h:63: warning: type ‘rid’ violates the C++ One Definition Rule [-Wodr] 63 | enum rid | ../../gcc/c-family/stub-objc.c:30: note: an enum with different value name is defined in another translation unit 30 | enum rid { DUMMY }; | ../../gcc/c-family/c-common.h:67: note: name ‘RID_STATIC’ differs from name ‘DUMMY’ defined in another translation unit 67 | RID_STATIC = 0, | ../../gcc/c-family/stub-objc.c:30: note: mismatching definition 30 | enum rid { DUMMY }; | ../../gcc/c-family/c-common.h:63: warning: type ‘rid’ violates the C++ One Definition Rule [-Wodr] 63 | enum rid | ../../gcc/c-family/stub-objc.c:30: note: an enum with different value name is defined in another translation unit 30 | enum rid { DUMMY }; | ../../gcc/c-family/c-common.h:67: note: name ‘RID_STATIC’ differs from name ‘DUMMY’ defined in another translation unit 67 | RID_STATIC = 0, | ../../gcc/c-family/stub-objc.c:30: note: mismatching definition 30 | enum rid { DUMMY }; | Can you please take a look? Thanks, Martin
[pushed] Objective-C/C++ (parsers) : Update @property attribute parsing.
Hi This is preparatory work for bringing at least one aspect of the Objective-C implementation up to date. Tested on a number of Darwin revisions, and x86_64-linux-gnu pushed to master, thanks Iain --- At present, we are missing parsing and checking for around half of the property attributes in use. The existing ad hoc scheme for the parser's communication with the Objective C validation is not suitable for extending to cover all the missing cases. Additionally: 1/ We were declaring errors in two cases that the reference implementation warns (or is silent). I've elected to warn for both those cases, (Wattributes) it could be that we should implement Wobjc-xxx-property warning masks (TODO). 2/ We were emitting spurious complaints about missing property attributes when these were not being parsed because we gave up on the first syntax error. 3/ The quality of the diagnostic locations was poor (that's true for much of Objective-C, we will have to improve it as we modernise areas). We continue to attempt to keep the code, warning and error output similar (preferably identical output) between the C and C++ front ends. The interface to the Objective-C-specific parts of the parsing is simplified to a vector of parsed (but not fully-checked) property attributes, this will simplify the addition of new attributes. gcc/c-family/ChangeLog: * c-objc.h (enum objc_property_attribute_group): New (enum objc_property_attribute_kind): New. (OBJC_PROPATTR_GROUP_MASK): New. (struct property_attribute_info): Small class encapsulating parser output from property attributes. (objc_prop_attr_kind_for_rid): New (objc_add_property_declaration): Simplify interface. * stub-objc.c (enum rid): Dummy type. (objc_add_property_declaration): Simplify interface. (objc_prop_attr_kind_for_rid): New. gcc/c/ChangeLog: * c-parser.c (c_parser_objc_at_property_declaration): Improve parsing fidelity. Associate better location info with @property attributes. Clean up the interface to objc_add_property_declaration (). gcc/cp/ChangeLog: * parser.c (cp_parser_objc_at_property_declaration): Improve parsing fidelity. Associate better location info with @property attributes. Clean up the interface to objc_add_property_declaration (). gcc/objc/ChangeLog: * objc-act.c (objc_prop_attr_kind_for_rid): New. (objc_add_property_declaration): Adjust to consume the parser output using a vector of parsed attributes. gcc/testsuite/ChangeLog: * obj-c++.dg/property/at-property-1.mm: Adjust expected diagnostics. * obj-c++.dg/property/at-property-29.mm: Likewise. * obj-c++.dg/property/at-property-4.mm: Likewise. * obj-c++.dg/property/property-neg-2.mm: Likewise. * objc.dg/property/at-property-1.m: Likewise. * objc.dg/property/at-property-29.m: Likewise. * objc.dg/property/at-property-4.m: Likewise. * objc.dg/property/at-property-5.m: Likewise. * objc.dg/property/property-neg-2.m: Likewise. --- gcc/c-family/c-objc.h | 65 +++- gcc/c-family/stub-objc.c | 21 +- gcc/c/c-parser.c | 280 ++--- gcc/cp/parser.c | 266 +--- gcc/objc/objc-act.c | 295 +++--- .../obj-c++.dg/property/at-property-1.mm | 12 +- .../obj-c++.dg/property/at-property-29.mm | 8 +- .../obj-c++.dg/property/at-property-4.mm | 10 +- .../obj-c++.dg/property/property-neg-2.mm | 2 +- .../objc.dg/property/at-property-1.m | 12 +- .../objc.dg/property/at-property-29.m | 7 +- .../objc.dg/property/at-property-4.m | 10 +- .../objc.dg/property/at-property-5.m | 2 +- .../objc.dg/property/property-neg-2.m | 2 +- 14 files changed, 598 insertions(+), 394 deletions(-) diff --git a/gcc/c-family/c-objc.h b/gcc/c-family/c-objc.h index 4577e4f1c7f..a2ca112dcc6 100644 --- a/gcc/c-family/c-objc.h +++ b/gcc/c-family/c-objc.h @@ -28,6 +28,67 @@ enum GTY(()) objc_ivar_visibility_kind { OBJC_IVAR_VIS_PACKAGE = 3 }; +/* ObjC property attribute kinds. + These have two fields; a unique value (that identifies which attribute) + and a group key that indicates membership of an exclusion group. + Only one member may be present from an exclusion group in a given attribute + list. + getters and setters have additional rules, since they are excluded from + non-overlapping group sets. */ + +enum objc_property_attribute_group +{ + OBJC_PROPATTR_GROUP_UNKNOWN = 0, + OBJC_PROPATTR_GROUP_GETTER, + OBJC_PROPATTR_GROUP_SETTER, + OBJC_PROPATTR_GROUP_READWRITE, + OBJC_PROPATTR_GROUP_ASSIGN, + OBJC_PROPATTR_GROUP_ATOMIC, + OBJC_PROPATTR_GROUP_MAX +}; + +enum objc_property_attribute_ki