enums and ints are compatible
This commit is contained in:
		
							parent
							
								
									c0368604e1
								
							
						
					
					
						commit
						b1a906b970
					
				
					 2 changed files with 10 additions and 0 deletions
				
			
		
							
								
								
									
										8
									
								
								tccgen.c
									
										
									
									
									
								
							
							
						
						
									
										8
									
								
								tccgen.c
									
										
									
									
									
								
							| 
						 | 
					@ -2565,6 +2565,14 @@ static int compare_types(CType *type1, CType *type2, int unqualified)
 | 
				
			||||||
        t1 &= ~VT_DEFSIGN;
 | 
					        t1 &= ~VT_DEFSIGN;
 | 
				
			||||||
        t2 &= ~VT_DEFSIGN;
 | 
					        t2 &= ~VT_DEFSIGN;
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
 | 
					    if ((t1 & VT_BTYPE) == VT_ENUM) {
 | 
				
			||||||
 | 
						/* An enum is compatible with (unsigned) int.  */
 | 
				
			||||||
 | 
						t1 = VT_INT | (t1 & ~VT_BTYPE);
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
 | 
					    if ((t2 & VT_BTYPE) == VT_ENUM) {
 | 
				
			||||||
 | 
						/* An enum is compatible with (unsigned) int.  */
 | 
				
			||||||
 | 
						t2 = VT_INT | (t2 & ~VT_BTYPE);
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
    /* XXX: bitfields ? */
 | 
					    /* XXX: bitfields ? */
 | 
				
			||||||
    if (t1 != t2)
 | 
					    if (t1 != t2)
 | 
				
			||||||
        return 0;
 | 
					        return 0;
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -590,6 +590,8 @@ enum test {
 | 
				
			||||||
void enum_test()
 | 
					void enum_test()
 | 
				
			||||||
{
 | 
					{
 | 
				
			||||||
    enum test b1;
 | 
					    enum test b1;
 | 
				
			||||||
 | 
					    /* The following should give no warning */
 | 
				
			||||||
 | 
					    int *p = &b1;
 | 
				
			||||||
    printf("enum:\n%d %d %d %d %d %d\n",
 | 
					    printf("enum:\n%d %d %d %d %d %d\n",
 | 
				
			||||||
           E0, E1, E2, E3, E4, E5);
 | 
					           E0, E1, E2, E3, E4, E5);
 | 
				
			||||||
    b1 = 1;
 | 
					    b1 = 1;
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
		Loading…
	
	Add table
		
		Reference in a new issue