mirror of
https://github.com/eclipse-cdt/cdt
synced 2025-07-24 01:15:29 +02:00
Array to pointer conversion for typedefs, bug 239931.
This commit is contained in:
parent
87a573a38e
commit
7f6536f4e0
2 changed files with 21 additions and 2 deletions
|
@ -5921,4 +5921,21 @@ public class AST2CPPTests extends AST2BaseTest {
|
|||
public void testTypeid_Bug209578() throws Exception {
|
||||
parseAndCheckBindings(getAboveComment(), ParserLanguage.CPP);
|
||||
}
|
||||
|
||||
|
||||
// typedef char* t1;
|
||||
// typedef char t2[8];
|
||||
// void test(char * x) {}
|
||||
// int main(void) {
|
||||
// char x[12];
|
||||
// t1 y;
|
||||
// t2 z;
|
||||
// test(x);
|
||||
// test(y);
|
||||
// test(z);
|
||||
// }
|
||||
public void testArrayToPtrConversionForTypedefs_Bug239931() throws Exception {
|
||||
parseAndCheckBindings(getAboveComment(), ParserLanguage.CPP);
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -68,15 +68,17 @@ public class Conversions {
|
|||
Cost cost;
|
||||
|
||||
allowUDC &= !isImpliedObject;
|
||||
target= getUltimateTypeViaTypedefs(target);
|
||||
source= getUltimateTypeViaTypedefs(source);
|
||||
|
||||
if (target instanceof ICPPReferenceType) {
|
||||
// [13.3.3.3.1] Reference binding
|
||||
IType cv1T1= ((ICPPReferenceType)target).getType();
|
||||
IType cv1T1= getUltimateTypeViaTypedefs(((ICPPReferenceType)target).getType());
|
||||
cost= new Cost(source, cv1T1);
|
||||
cost.targetHadReference= true;
|
||||
|
||||
boolean lvalue= sourceExp == null || !CPPVisitor.isRValue(sourceExp);
|
||||
IType T2= source instanceof IQualifierType ? ((IQualifierType)source).getType() : source;
|
||||
IType T2= source instanceof IQualifierType ? getUltimateTypeViaTypedefs(((IQualifierType)source).getType()) : source;
|
||||
|
||||
if (lvalue && isReferenceCompatible(cv1T1, source)) {
|
||||
/* Direct reference binding */
|
||||
|
|
Loading…
Add table
Reference in a new issue