#include <objc/Object.h> @interface Test : Object -(void) test2: (volatile int )a; @end @implementation Test -(void) test2: (volatile int) a { a = 1; } @end void f(volatile int a) { a = 1; }
This is just like PR 18971. If we fix all of the problems related to that PR, we are going replacate all of grokdeclarator inside the objc front-end which just makes the objc front-end bigger and makes us have more and more duplicated code which is just wrong. Note -[Test test:] and the function f should have the same assembly at -O1 or above but right now we don't keep the store to a because we loose volatile in argument.
I'll take this; there is also a problem with encoding 'const' parameters, already fixed in apple-ppc- branch. I'll tackle the const and volatile issue together.
Ok, I was wrong. :-) The bug described herein is unrelated to the const encoding issue. What is more, I'm dumbfounded as to how the anomaly comes to be. Stepping through objc_start_function() and friends, one can see that the volatile-ness of the argument is preserved all the way through. I did notice some discrepancies between how ObjC synthesizes C functions vs. how such functions get constructed in C itself, and have created a patch to minimize them. Alas, this does not fix the problem. :-(
Created attachment 7923 [details] Patch to make objc_start_function() closer in spirit to C's start_function()/grokdeclarator() As noted above, this does NOT fix the problem at hand, but may nevertheless be useful. At this point, it would probably be best if this PR were assigned to someone with intimate knowledge of C's start_function()/grokdeclarator(), who could tell us where objc_start_function()/objc_push_parm()/etc. are going wrong. Better yet, they could break off portions of start_function()/grokdeclarator()/etc. into separate routines that ObjC can then call.
(In reply to comment #3) And this is why I wrote comment #1.
Alas, comment #1 is a non-starter for ObjC++ reasons, plus it is factually wrong (since we _do_ preserve the volatile on the function argument, which is why this is mysterious).
(In reply to comment #6) Well consider the following code (which is basically PR 14050 which is suspended as we don't know if it is valid code or not): @interface Foo -(void) quux: (int [__restrict])a; @end With the mainline we get only two error messages: t.m:2: error: static or type qualifiers in abstract declarator t.m:2: error: static or type qualifiers in non-parameter array declarator But with 3.3.2, we get only one: t.m:2: error: static or type qualifiers in abstract declarator which is correct if this is consider invalid code. If this in later versions of gcc, we decide this is valid code and we don't use grokdeclarator in the objc front-end, we will be still rejecting this instead of getting this for free.
Subject: Bug 19321 CVSROOT: /cvs/gcc Module name: gcc Changes by: zlaski@gcc.gnu.org 2005-01-15 21:18:59 Modified files: gcc/testsuite : ChangeLog gcc/objc : ChangeLog objc-act.c Added files: gcc/testsuite/objc.dg: func-ptr-2.m volatile-1.m Log message: [gcc/objc/ChangeLog] 2005-01-15 Ziemowit Laski <zlaski@apple.com> PR objc/19321 * objc-act.c (get_arg_type_list): Decay function arguments into pointers. (objc_push_parm): Likewise; bring PARM_DECL construction closer in line with what the C front-end does. (objc_get_parm_info): Call pushdecl() and finish_decl() on each PARM_DECL, like the C front-end does. (start_method_def): Remove redundant ARRAY_TYPE decay. (objc_start_function): Bring closer in line with what the C front-end does for functions. [gcc/testsuite/ChangeLog] 2005-01-15 Ziemowit Laski <zlaski@apple.com> PR objc/19321 * objc.dg/func-ptr-2.m: New. * objc.dg/volatile-1.m: New. Patches: http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/gcc/testsuite/ChangeLog.diff?cvsroot=gcc&r1=1.4891&r2=1.4892 http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/gcc/testsuite/objc.dg/func-ptr-2.m.diff?cvsroot=gcc&r1=NONE&r2=1.1 http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/gcc/testsuite/objc.dg/volatile-1.m.diff?cvsroot=gcc&r1=NONE&r2=1.1 http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/gcc/objc/ChangeLog.diff?cvsroot=gcc&r1=1.23&r2=1.24 http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/gcc/objc/objc-act.c.diff?cvsroot=gcc&r1=1.260&r2=1.261
Committed fix.
Subject: Bug 19321 CVSROOT: /cvs/gcc Module name: gcc Branch: apple-ppc-branch Changes by: zlaski@gcc.gnu.org 2005-01-17 23:46:57 Modified files: gcc : ChangeLog.apple-ppc c-common.h stub-objc.c gcc/cp : ChangeLog.apple-ppc parser.c gcc/objc : ChangeLog.apple-ppc objc-act.c gcc/testsuite : ChangeLog.apple-ppc Added files: gcc/testsuite/obj-c++.dg: cxx-scope-1.mm cxx-scope-2.mm try-catch-1.mm try-catch-2.mm try-catch-3.mm try-catch-4.mm try-catch-5.mm try-catch-6.mm gcc/testsuite/objc.dg: func-ptr-2.m volatile-1.m Log message: [gcc/ChangeLog.apple-ppc] 2005-01-17 Ziemowit Laski <zlaski@apple.com> Radar 3951689 * c-common.h (objc_finish_try_stmt, objc_build_synchronized): Return 'tree' instead of 'void'. * stub-objc.c (objc_build_throw_stmt, objc_begin_try_stmt, objc_finish_try_stmt, objc_begin_catch_clause, objc_finish_catch_clause, objc_build_finally_clause, objc_build_synchronized: New stubs. [gcc/cp/ChangeLog.apple-ppc] 2005-01-17 Ziemowit Laski <zlaski@apple.com> Radar 3955336 * parser.c (cp_parser_objc_message_receiver): Try parsing receiver as an expression first; failing that, as a nested type. 2005-01-17 Ziemowit Laski <zlaski@apple.com> Radar 3951689 * parser.c (cp_parser_objc_try_catch_finally_statement, cp_parser_objc_synchronized_statement, cp_parser_objc_throw_statement cp_parser_objc_statement): New functions. (cp_parser_statement): Call cp_parser_objc_statement() to parse Objective-C statements. [gcc/objc/ChangeLog.apple-ppc] 2005-01-17 Ziemowit Laski <zlaski@apple.com> Radar 3955336 * objc-act.c (objc_get_class_reference): In Objective-C++, make sure a type is declared in the global namespace before looking it up as an ObjC class. 2005-01-17 Ziemowit Laski <zlaski@apple.com> Radar 3953044 (PR objc/19321) * objc-act.c (get_arg_type_list): Decay function arguments into pointers. (objc_push_parm): Likewise; bring PARM_DECL construction closer in line with what the C front-end does. (objc_get_parm_info): Call pushdecl() and finish_decl() on each PARM_DECL, like the C front-end does. (start_method_def): Remove redundant ARRAY_TYPE decay. (objc_start_function): Bring closer in line with what the C front-end does for functions. 2005-01-17 Ziemowit Laski <zlaski@apple.com> Radar 3951689 * objc-act.c (next_sjlj_build_enter_and_setjmp): For Objective-C++, convert _setjmp() argument to type the function expects. (objc_finish_try_stmt, objc_build_synchronized): Return the resulting statement node. [gcc/testsuite/ChangeLog.apple-ppc] 2005-01-17 Ziemowit Laski <zlaski@apple.com> Radar 3955336 * obj-c++.dg/cxx-scope-1.mm: New. * obj-c++.dg/cxx-scope-2.mm: New. 2005-01-17 Ziemowit Laski <zlaski@apple.com> Radar 3953044 (PR objc/19321) * objc.dg/func-ptr-2.m: New. * objc.dg/volatile-1.m: New. 2005-01-17 Ziemowit Laski <zlaski@apple.com> Radar 3951689 * obj-c++.dg/try-catch-1.mm: New. * obj-c++.dg/try-catch-2.mm: New. * obj-c++.dg/try-catch-3.mm: New. * obj-c++.dg/try-catch-4.mm: New. * obj-c++.dg/try-catch-5.mm: New. * obj-c++.dg/try-catch-6.mm: New. Patches: http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/gcc/ChangeLog.apple-ppc.diff?cvsroot=gcc&only_with_tag=apple-ppc-branch&r1=1.1.2.271&r2=1.1.2.272 http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/gcc/c-common.h.diff?cvsroot=gcc&only_with_tag=apple-ppc-branch&r1=1.141.2.48.2.24&r2=1.141.2.48.2.25 http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/gcc/stub-objc.c.diff?cvsroot=gcc&only_with_tag=apple-ppc-branch&r1=2.1.4.1.6.5&r2=2.1.4.1.6.6 http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/gcc/cp/ChangeLog.apple-ppc.diff?cvsroot=gcc&only_with_tag=apple-ppc-branch&r1=1.1.2.29&r2=1.1.2.30 http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/gcc/cp/parser.c.diff?cvsroot=gcc&only_with_tag=apple-ppc-branch&r1=1.32.2.23.2.25&r2=1.32.2.23.2.26 http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/gcc/objc/ChangeLog.apple-ppc.diff?cvsroot=gcc&only_with_tag=apple-ppc-branch&r1=1.1.2.12&r2=1.1.2.13 http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/gcc/objc/objc-act.c.diff?cvsroot=gcc&only_with_tag=apple-ppc-branch&r1=1.137.2.33.2.24&r2=1.137.2.33.2.25 http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/gcc/testsuite/ChangeLog.apple-ppc.diff?cvsroot=gcc&only_with_tag=apple-ppc-branch&r1=1.1.2.83&r2=1.1.2.84 http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/gcc/testsuite/obj-c++.dg/cxx-scope-1.mm.diff?cvsroot=gcc&only_with_tag=apple-ppc-branch&r1=NONE&r2=1.1.2.1 http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/gcc/testsuite/obj-c++.dg/cxx-scope-2.mm.diff?cvsroot=gcc&only_with_tag=apple-ppc-branch&r1=NONE&r2=1.1.2.1 http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/gcc/testsuite/obj-c++.dg/try-catch-1.mm.diff?cvsroot=gcc&only_with_tag=apple-ppc-branch&r1=NONE&r2=1.1.2.1 http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/gcc/testsuite/obj-c++.dg/try-catch-2.mm.diff?cvsroot=gcc&only_with_tag=apple-ppc-branch&r1=NONE&r2=1.1.2.1 http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/gcc/testsuite/obj-c++.dg/try-catch-3.mm.diff?cvsroot=gcc&only_with_tag=apple-ppc-branch&r1=NONE&r2=1.1.2.1 http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/gcc/testsuite/obj-c++.dg/try-catch-4.mm.diff?cvsroot=gcc&only_with_tag=apple-ppc-branch&r1=NONE&r2=1.1.2.1 http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/gcc/testsuite/obj-c++.dg/try-catch-5.mm.diff?cvsroot=gcc&only_with_tag=apple-ppc-branch&r1=NONE&r2=1.1.2.1 http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/gcc/testsuite/obj-c++.dg/try-catch-6.mm.diff?cvsroot=gcc&only_with_tag=apple-ppc-branch&r1=NONE&r2=1.1.2.1 http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/gcc/testsuite/objc.dg/func-ptr-2.m.diff?cvsroot=gcc&only_with_tag=apple-ppc-branch&r1=NONE&r2=1.1.2.1 http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/gcc/testsuite/objc.dg/volatile-1.m.diff?cvsroot=gcc&only_with_tag=apple-ppc-branch&r1=NONE&r2=1.1.2.1