Indexed accessor property not supported correctly in clang "4.2.1 Compatible Clang 3.8.0 (trunk)" ------------------------------------------------- // See: https://msdn.microsoft.com/en-us/library/yhfk0thd.aspx // __declspec(property(get=GetX, put=PutX)) int x[]; // The above statement indicates that x[] can be used with one or more // array indices. In this case, i=p->x[a][b] will be turned into // i=p->GetX(a, b), and p->x[a][b] = i will be turned into p->PutX(a, b, i); Output from MSVC is as follows: 1>------ Rebuild All started: Project: LlvmMsVcProperties, Configuration: Debug Win32 ------ 1> LlvmMsVcProperties.cpp 1> LlvmMsVcProperties.vcxproj -> LlvmMsVcProperties.exe ========== Rebuild All: 1 succeeded, 0 failed, 0 skipped ========== < PropertyTest::PropertyTest(10) >x=10 >this->Y[1] : 1 >this->Y[2][3] : 6 < set_a_y as Y[4]=5 : 20 >this->Y[4]=5 : 20 < set_a_b_y as Y[6][7]=8: 336 >this->Y[6][7]=8 : 336 ================================================= ================================================= clang/clang-cl version: ... #define __VERSION__ "4.2.1 Compatible Clang 3.8.0 (trunk)" -fms-compatibility REPORTS: lvmMsVcProperties.cpp(32,56): error : no matching member function for call to 'get_index_y' printf(">this->Y[1] : %d\n", this->Y[1]); ~~~~~~^ LlvmMsVcProperties.cpp(13,9) : note: candidate function not viable: requires single argument 'a', but no arguments were provided int get_index_y(int a) { return a; } ^ LlvmMsVcProperties.cpp(14,9) : note: candidate function not viable: requires 2 arguments, but 0 were provided int get_index_y(int a, int b) { return a*b; } ^ lvmMsVcProperties.cpp(33,56): error : no matching member function for call to 'get_index_y' printf(">this->Y[2][3] : %d\n", this->Y[2][3]); ~~~~~~^ LlvmMsVcProperties.cpp(13,9) : note: candidate function not viable: requires single argument 'a', but no arguments were provided int get_index_y(int a) { return a; } ^ LlvmMsVcProperties.cpp(14,9) : note: candidate function not viable: requires 2 arguments, but 0 were provided int get_index_y(int a, int b) { return a*b; } ^ lvmMsVcProperties.cpp(34,57): error : no matching member function for call to 'get_index_y' printf(">this->Y[4]=5 : %d\n", (this->Y[4]=5)); ~~~~~~^ LlvmMsVcProperties.cpp(13,9) : note: candidate function not viable: requires single argument 'a', but no arguments were provided int get_index_y(int a) { return a; } ^ LlvmMsVcProperties.cpp(14,9) : note: candidate function not viable: requires 2 arguments, but 0 were provided int get_index_y(int a, int b) { return a*b; } ^ lvmMsVcProperties.cpp(35,57): error : no matching member function for call to 'get_index_y' printf(">this->Y[6][7]=8 : %d\n", (this->Y[6][7]=8)); ~~~~~~^ LlvmMsVcProperties.cpp(13,9) : note: candidate function not viable: requires single argument 'a', but no arguments were provided int get_index_y(int a) { return a; } ^ LlvmMsVcProperties.cpp(14,9) : note: candidate function not viable: requires 2 arguments, but 0 were provided int get_index_y(int a, int b) { return a*b; } ^ 4 errors generated.
in clang "4.2.1 Compatible Clang 3.8.0 (trunk)" ------------------------------------------------- // See: https://msdn.microsoft.com/en-us/library/yhfk0thd.aspx // __declspec(property(get=GetX, put=PutX)) int x[]; // The above statement indicates that x[] can be used with one or more // array indices. In this case, i=p->x[a][b] will be turned into // i=p->GetX(a, b), and p->x[a][b] = i will be turned into p->PutX(a, b, i);
Created attachment 15354 [details] Repro - somehow it was dropped from original submission Repro for bug 25636: Somehow it was dropped from original submission
This is the incompatibility: __declspec(property(get = get_index_y, put = put_index_y)) /* ==> */ int Y[];
*** Bug 25635 has been marked as a duplicate of this bug. ***
Thank for the report, be aware this functionality is pretty new.
1. Update your compiler to the latest version. I could not reproduce your error messages. Seems to me you're using version before the commit with indexed properties support. 2. I saw just 2 error messages with the indexed properties LlvmMsVcProperties.cpp:35:50: error: cannot pass expression of type 'void' to variadic function printf(">this->Y[4]=5 : %d\n", (this->Y[4]=5)); ^ LlvmMsVcProperties.cpp:36:50: error: cannot pass expression of type 'void' to variadic function printf(">this->Y[6][7]=8 : %d\n", (this->Y[6][7]=8)); ^ 2 errors generated. 'put' property for assignment does not return value by default. Shall we support this?
Hi Alexey, it half works now in SVN r254298 (30 November 2015). With the code sample I originally posted, it now generates the following errors. 3>LlvmMsVcProperties.cpp(34,50): error : cannot pass expression of type 'void' to variadic function; expected type from format string was 'int' 3> printf(">this->Y[4]=5 : %d\n", (this->Y[4]=5)); 3> ^~~~~~~~~~~~~~ 3>LlvmMsVcProperties.cpp(35,50): error : cannot pass expression of type 'void' to variadic function; expected type from format string was 'int' 3> printf(">this->Y[6][7]=8 : %d\n", (this->Y[6][7]=8)); 3> ^~~~~~~~~~~~~~~~~ ----------- WHICH CAN BE MORE CLEARLY SEEN BY DOING -----------> 3>LlvmMsVcProperties.cpp(34,14): error : variable has incomplete type 'void' 3> auto r0 = this->Y[4]=5; 3> ^ 3>LlvmMsVcProperties.cpp(36,14): error : variable has incomplete type 'void' 3> auto r1 = this->Y[6][7]=8; 3> ^ 3> 2 errors generated.
(In reply to comment #7) > Hi Alexey, it half works now in SVN r254298 (30 November 2015). > > With the code sample I originally posted, it now generates the following > errors. > > 3>LlvmMsVcProperties.cpp(34,50): error : cannot pass expression of type > 'void' to variadic function; expected type from format string was 'int' > 3> printf(">this->Y[4]=5 : %d\n", (this->Y[4]=5)); > 3> ^~~~~~~~~~~~~~ > 3>LlvmMsVcProperties.cpp(35,50): error : cannot pass expression of type > 'void' to variadic function; expected type from format string was 'int' > 3> printf(">this->Y[6][7]=8 : %d\n", (this->Y[6][7]=8)); > 3> ^~~~~~~~~~~~~~~~~ > > ----------- WHICH CAN BE MORE CLEARLY SEEN BY DOING -----------> > 3>LlvmMsVcProperties.cpp(34,14): error : variable has incomplete type 'void' > 3> auto r0 = this->Y[4]=5; > 3> ^ > 3>LlvmMsVcProperties.cpp(36,14): error : variable has incomplete type 'void' > 3> auto r1 = this->Y[6][7]=8; > 3> ^ > 3> 2 errors generated. Yes, this is known problem. Patch that fixes this is under review
Committed revision 255218.