mirror of
https://github.com/eclipse-cdt/cdt
synced 2025-04-29 19:45:01 +02:00
fix bug 69798
This commit is contained in:
parent
993b0299f4
commit
610efadb58
2 changed files with 46 additions and 35 deletions
|
@ -1974,12 +1974,12 @@ public class CompleteParseASTTest extends CompleteParseBaseTest
|
||||||
|
|
||||||
public void testUnaryAmperCast() throws Exception{
|
public void testUnaryAmperCast() throws Exception{
|
||||||
Writer writer = new StringWriter();
|
Writer writer = new StringWriter();
|
||||||
writer.write( "void f( char * ); \n ");
|
writer.write( "void f( char * ); \r\n "); //$NON-NLS-1$
|
||||||
writer.write( "void f( char ); \n ");
|
writer.write( "void f( char ); \n "); //$NON-NLS-1$
|
||||||
writer.write( "void main() { \n ");
|
writer.write( "void main() { \n "); //$NON-NLS-1$
|
||||||
writer.write( " char * t = new char [ 5 ]; \n ");
|
writer.write( " char * t = new char [ 5 ]; \n "); //$NON-NLS-1$
|
||||||
writer.write( " f( &t[1] ); \n ");
|
writer.write( " f( &t[1] ); \n "); //$NON-NLS-1$
|
||||||
writer.write( "} \n ");
|
writer.write( "} \n "); //$NON-NLS-1$
|
||||||
|
|
||||||
Iterator i = parse( writer.toString() ).getDeclarations();
|
Iterator i = parse( writer.toString() ).getDeclarations();
|
||||||
IASTFunction f1 = (IASTFunction) i.next();
|
IASTFunction f1 = (IASTFunction) i.next();
|
||||||
|
@ -1993,10 +1993,10 @@ public class CompleteParseASTTest extends CompleteParseBaseTest
|
||||||
|
|
||||||
public void testBug68235() throws Exception{
|
public void testBug68235() throws Exception{
|
||||||
Writer writer = new StringWriter();
|
Writer writer = new StringWriter();
|
||||||
writer.write( " struct xTag { int x; }; ");
|
writer.write( " struct xTag { int x; }; "); //$NON-NLS-1$
|
||||||
writer.write( " typedef xTag xType; ");
|
writer.write( " typedef xTag xType; "); //$NON-NLS-1$
|
||||||
writer.write( " typedef struct yTag { int x; } yType; ");
|
writer.write( " typedef struct yTag { int x; } yType; "); //$NON-NLS-1$
|
||||||
writer.write( " class C1 { xType x; yType y; }; ");
|
writer.write( " class C1 { xType x; yType y; }; "); //$NON-NLS-1$
|
||||||
|
|
||||||
Iterator i = parse( writer.toString() ).getDeclarations();
|
Iterator i = parse( writer.toString() ).getDeclarations();
|
||||||
|
|
||||||
|
@ -2025,34 +2025,34 @@ public class CompleteParseASTTest extends CompleteParseBaseTest
|
||||||
public void testBug60407() throws Exception
|
public void testBug60407() throws Exception
|
||||||
{
|
{
|
||||||
Writer writer = new StringWriter();
|
Writer writer = new StringWriter();
|
||||||
writer.write( "struct ZZZ { int x, y, z; };\n" );
|
writer.write( "struct ZZZ { int x, y, z; };\r\n" ); //$NON-NLS-1$
|
||||||
writer.write( "typedef struct ZZZ _FILE;\n" );
|
writer.write( "typedef struct ZZZ _FILE;\n" ); //$NON-NLS-1$
|
||||||
writer.write( "typedef _FILE FILE;\n" );
|
writer.write( "typedef _FILE FILE;\n" ); //$NON-NLS-1$
|
||||||
writer.write( "static void static_function(FILE * lcd){}\n" );
|
writer.write( "static void static_function(FILE * lcd){}\n" ); //$NON-NLS-1$
|
||||||
writer.write( "int main(int argc, char **argv) {\n" );
|
writer.write( "int main(int argc, char **argv) {\n" ); //$NON-NLS-1$
|
||||||
writer.write( "FILE * file = 0;\n" );
|
writer.write( "FILE * file = 0;\n" ); //$NON-NLS-1$
|
||||||
writer.write( "static_function( file );\n" );
|
writer.write( "static_function( file );\n" ); //$NON-NLS-1$
|
||||||
writer.write( "return 0;\n" );
|
writer.write( "return 0;\n" ); //$NON-NLS-1$
|
||||||
writer.write( "}\n" );
|
writer.write( "}\n" ); //$NON-NLS-1$
|
||||||
parse( writer.toString() );
|
parse( writer.toString() );
|
||||||
}
|
}
|
||||||
|
|
||||||
public void testBug68623() throws Exception{
|
public void testBug68623() throws Exception{
|
||||||
Writer writer = new StringWriter();
|
Writer writer = new StringWriter();
|
||||||
writer.write( "class A { \n" );
|
writer.write( "class A { \n" ); //$NON-NLS-1$
|
||||||
writer.write( " A(); \n" );
|
writer.write( " A(); \n" ); //$NON-NLS-1$
|
||||||
writer.write( " class sub{}; \n" );
|
writer.write( " class sub{}; \n" ); //$NON-NLS-1$
|
||||||
writer.write( " sub * x; \n" );
|
writer.write( " sub * x; \n" ); //$NON-NLS-1$
|
||||||
writer.write( "}; \n" );
|
writer.write( "}; \n" ); //$NON-NLS-1$
|
||||||
writer.write( "A::A() : x( (sub *) 0 ) {} \n" );
|
writer.write( "A::A() : x( (sub *) 0 ) {} \n" ); //$NON-NLS-1$
|
||||||
|
|
||||||
parse( writer.toString() );
|
parse( writer.toString() );
|
||||||
|
|
||||||
writer = new StringWriter();
|
writer = new StringWriter();
|
||||||
writer.write( "class A { \n" );
|
writer.write( "class A { \n" ); //$NON-NLS-1$
|
||||||
writer.write( " A() : x (0) {} \n" );
|
writer.write( " A() : x (0) {} \n" ); //$NON-NLS-1$
|
||||||
writer.write( " int x; \n" );
|
writer.write( " int x; \n" ); //$NON-NLS-1$
|
||||||
writer.write( "}; \n" );
|
writer.write( "}; \n" ); //$NON-NLS-1$
|
||||||
|
|
||||||
Iterator i = parse( writer.toString() ).getDeclarations();
|
Iterator i = parse( writer.toString() ).getDeclarations();
|
||||||
IASTClassSpecifier A = (IASTClassSpecifier) ((IASTAbstractTypeSpecifierDeclaration)i.next()).getTypeSpecifier();
|
IASTClassSpecifier A = (IASTClassSpecifier) ((IASTAbstractTypeSpecifierDeclaration)i.next()).getTypeSpecifier();
|
||||||
|
@ -2063,4 +2063,12 @@ public class CompleteParseASTTest extends CompleteParseBaseTest
|
||||||
|
|
||||||
assertAllReferences( 1, createTaskList( new Task( x ) ) );
|
assertAllReferences( 1, createTaskList( new Task( x ) ) );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public void testBug69798() throws Exception{
|
||||||
|
Writer writer = new StringWriter();
|
||||||
|
writer.write( "enum Flags { FLAG1, FLAG2 }; \n" ); //$NON-NLS-1$
|
||||||
|
writer.write( "int f() { int a, b; b = ( a ? FLAG1 : 0 ) | FLAG2; } \n" ); //$NON-NLS-1$
|
||||||
|
|
||||||
|
parse( writer.toString() );
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -1724,7 +1724,7 @@ public class ParserSymbolTable {
|
||||||
|
|
||||||
int mask = ITypeInfo.isShort | ITypeInfo.isLong | ITypeInfo.isUnsigned | ITypeInfo.isLongLong | ITypeInfo.isSigned;
|
int mask = ITypeInfo.isShort | ITypeInfo.isLong | ITypeInfo.isUnsigned | ITypeInfo.isLongLong | ITypeInfo.isSigned;
|
||||||
|
|
||||||
if( (src.isType( ITypeInfo.t__Bool, ITypeInfo.t_float ) || src.isType( ITypeInfo.t_enumeration )) &&
|
if( src.isType( ITypeInfo.t__Bool, ITypeInfo.t_float ) &&
|
||||||
(trg.isType( ITypeInfo.t_int ) || trg.isType( ITypeInfo.t_double )) )
|
(trg.isType( ITypeInfo.t_int ) || trg.isType( ITypeInfo.t_double )) )
|
||||||
{
|
{
|
||||||
if( src.getType() == trg.getType() && (( src.getTypeBits() & mask) == (trg.getTypeBits() & mask)) ){
|
if( src.getType() == trg.getType() && (( src.getTypeBits() & mask) == (trg.getTypeBits() & mask)) ){
|
||||||
|
@ -1821,9 +1821,9 @@ public class ParserSymbolTable {
|
||||||
} else if( !src.hasPtrOperators() ) {
|
} else if( !src.hasPtrOperators() ) {
|
||||||
//4.7 An rvalue of an integer type can be converted to an rvalue of another integer type.
|
//4.7 An rvalue of an integer type can be converted to an rvalue of another integer type.
|
||||||
//An rvalue of an enumeration type can be converted to an rvalue of an integer type.
|
//An rvalue of an enumeration type can be converted to an rvalue of an integer type.
|
||||||
if( src.isType( ITypeInfo.t__Bool, ITypeInfo.t_int ) ||
|
if( src.isType( ITypeInfo.t__Bool, ITypeInfo.t_int ) || src.isType( ITypeInfo.t_float, ITypeInfo.t_double ) ||
|
||||||
src.isType( ITypeInfo.t_float, ITypeInfo.t_double ) ||
|
src.isType( ITypeInfo.t_enumeration ) || ( src.isType( ITypeInfo.t_type ) && src.getTypeSymbol() != null
|
||||||
src.isType( ITypeInfo.t_enumeration ) )
|
&& src.getTypeSymbol().isType( ITypeInfo.t_enumeration ) ) )
|
||||||
{
|
{
|
||||||
if( trg.isType( ITypeInfo.t__Bool, ITypeInfo.t_int ) ||
|
if( trg.isType( ITypeInfo.t__Bool, ITypeInfo.t_int ) ||
|
||||||
trg.isType( ITypeInfo.t_float, ITypeInfo.t_double ) )
|
trg.isType( ITypeInfo.t_float, ITypeInfo.t_double ) )
|
||||||
|
@ -2099,9 +2099,12 @@ public class ParserSymbolTable {
|
||||||
|
|
||||||
info = typeSymbol.getTypeInfo();
|
info = typeSymbol.getTypeInfo();
|
||||||
int j = 0;
|
int j = 0;
|
||||||
while( (info.getTypeSymbol() != null && info.getType() == ITypeInfo.t_type) ||
|
while( (info.getTypeSymbol() != null && ( info.isType( ITypeInfo.t_type ) || info.isType( ITypeInfo.t_enumerator ) ) ) ||
|
||||||
(typeSymbol != null && typeSymbol.isForwardDeclaration() && typeSymbol.getForwardSymbol() != null ) ){
|
(typeSymbol != null && typeSymbol.isForwardDeclaration() && typeSymbol.getForwardSymbol() != null ) ){
|
||||||
typeSymbol = info.isType( ITypeInfo.t_type) ? info.getTypeSymbol() : typeSymbol.getForwardSymbol();
|
|
||||||
|
typeSymbol = (info.isType( ITypeInfo.t_type) || info.isType(ITypeInfo.t_enumerator))
|
||||||
|
? info.getTypeSymbol()
|
||||||
|
: typeSymbol.getForwardSymbol();
|
||||||
|
|
||||||
returnInfo.addPtrOperator( info.getPtrOperators() );
|
returnInfo.addPtrOperator( info.getPtrOperators() );
|
||||||
returnInfo.setTypeBits( ( returnInfo.getTypeBits() | info.getTypeBits() ) & ~ITypeInfo.isTypedef & ~ITypeInfo.isForward );
|
returnInfo.setTypeBits( ( returnInfo.getTypeBits() | info.getTypeBits() ) & ~ITypeInfo.isTypedef & ~ITypeInfo.isForward );
|
||||||
|
|
Loading…
Add table
Reference in a new issue