[PATCH] PR c++/26693

Dodji Seketeli dodji@redhat.com
Thu Dec 4 17:13:00 GMT 2008

Jason Merrill a écrit :
> Dodji Seketeli wrote:
>> The test case in the attached patch, in file 
>> gcc/testsuite/g++.dg/template/typedef14.C. The assert is hit when 
>> calling fold_non_dependent_expr on "~static_cast<mytype> (0)", which 
>> eventually calls tsubst on the mytype typedef.
>> When we tsubst the mytype typedef, we hit the line:
>> tree gen_args = tsubst (DECL_TI_ARGS (decl), args, complain, in_decl);
> Ah, OK.  So in this case we're still in the template, so what we want is 
> the template version of the typedef, so just adding
> if (args == NULL_TREE)
>   return t;
> to the top of tsubst, or the top of the typedef reuse bit, would give 
> the right answer.

Okay. I did it in the attached updated patch.

>> I changed this to actually put the code to append the type the list of 
>> access checks for the template into check_accessibility_of_qualified_id, 
> I thought about that possibility, but then you don't diagnose
> class A
> {
>  typedef int foo;
> };
> template <class T>
> class B: public A
> {
>   foo f;
> };

I think this case is diagnosed with the attached patch. The test 
gcc/testsuite/g++.dg/template/typedef13.C included in the patch is 
similar to the example you are mentioning and it seems to pass.

>>>> +append_type_to_template_for_access_check (tree type,
>>> Don't we need to do the same thing in function templates?
>> I am not sure to understand why this wouldn't work for typedef types 
>> referenced in function templates. Could you please tell me what I am 
>> missing ?
> I guess I was just confused by the parameter named "type".  Please 
> rename it to "tmpl" or some such.  :)

Yes "type" is not appropriate. I renamed it into templ.

The attached patch passes regtests and compiles libstdc++ on trunk for 
the x86_64 arch.


-------------- next part --------------
An embedded and charset-unspecified text was scrubbed...
Name: PR26693-patch-6.txt
URL: <http://gcc.gnu.org/pipermail/gcc-patches/attachments/20081204/2330d3ca/attachment.txt>

More information about the Gcc-patches mailing list