llvm / llvm-project

The LLVM Project is a collection of modular and reusable compiler and toolchain technologies.
http://llvm.org
Other
26.82k stars 11k forks source link

Comparison between altivec vector bool types are not allowed by clang #32699

Open llvmbot opened 7 years ago

llvmbot commented 7 years ago
Bugzilla Link 33352
Version trunk
OS Linux
Reporter LLVM Bugzilla Contributor

Extended Description

It seems that AST parsing is not correct.

int main(){ vector long long op_median = { 1, 4 }; vector long long op_less = { 0, 3 }; if ( ++op_less == op_median ) return 1; return 0; }

clang -maltivec -Xclang -ast-dump -fsyntax-only b.c

\TranslationUnitDecl 0x100173218b0 <> |-TypedefDecl 0x10017321e00 <> implicit int128_t 'int128' | `-BuiltinType 0x10017321b20 'int128' |-TypedefDecl 0x10017321e70 <> implicit __uint128_t 'unsigned int128' | -BuiltinType 0x10017321b40 'unsigned __int128' |-TypedefDecl 0x10017322148 <<invalid sloc>> <invalid sloc> implicit __NSConstantString 'struct __NSConstantString_tag' |-RecordType 0x10017321f50 'struct NSConstantString_tag' | `-Record 0x10017321ec8 '__NSConstantString_tag' |-TypedefDecl 0x100173221e0 <> implicit builtin_va_list 'char ' | `-PointerType 0x100173221a0 'char ' | -BuiltinType 0x10017321940 'char' -FunctionDecl 0x10017322290 <b.c:1:1, line:6:1> line:1:5 main 'int ()' -CompoundStmt 0x10017361a90 <col:11, line:6:1> |-DeclStmt 0x10017322518 <line:2:3, col:40> |-VarDecl 0x100173223a8 <col:3, col:39> col:20 used op_median 'vector long long' cinit | `-InitListExpr 0x10017322498 <col:32, col:39> 'vector long long' | |-ImplicitCastExpr 0x100173224e8 'long long' | | -IntegerLiteral 0x10017322408 <col:34> 'int' 1 |-ImplicitCastExpr 0x10017322500 'long long' | -IntegerLiteral 0x10017322428 <col:37> 'int' 4 |-DeclStmt 0x10017361920 <line:3:3, col:38> |-VarDecl 0x10017322540 <col:3, col:37> col:20 used op_less 'vector long long' cinit | `-InitListExpr 0x100173618a0 <col:30, col:37> 'vector long long' | |-ImplicitCastExpr 0x100173618f0 'long long' | | -IntegerLiteral 0x100173225a0 <col:32> 'int' 0 |-ImplicitCastExpr 0x10017361908 'long long' | -IntegerLiteral 0x100173225c0 <col:35> 'int' 3 |-IfStmt 0x10017361a20 <line:4:3, col:40> | |-<<<NULL>>> | |-<<<NULL>>> | |-BinaryOperator 0x100173619c0 <col:8, col:21> 'int' '==' | | |-UnaryOperator 0x10017361960 <col:8, col:10> '__vector long long' prefix '++' | | |-DeclRefExpr 0x10017361938 'vector long long' lvalue Var 0x10017322540 'op_less' 'vector long long' | | `-ImplicitCastExpr 0x100173619a8 'vector long long' | | `-DeclRefExpr 0x10017361980 '__vector long long' lvalue Var 0x100173223a8 'op_median' 'vector long long' | |-ReturnStmt 0x10017361a08 <col:33, col:40> | | -IntegerLiteral 0x100173619e8 <col:40> 'int' 1 |-<<>> -ReturnStmt 0x10017361a78 <line:5:3, col:10> -IntegerLiteral 0x10017361a58 'int' 0

int main(){ vector bool long long op_median = { 1, 4 }; vector bool long long op_less = { 0, 3 }; if ( ++op_less == op_median ) return 1; return 0; }

FunctionDecl 0x10015bb2290 <a.c:1:1, line:6:1> line:1:5 main 'int ()' -CompoundStmt 0x10015bf1f08 <col:11, line:6:1> |-DeclStmt 0x10015bb2518 <line:2:3, col:45> |-VarDecl 0x10015bb23a8 <col:3, col:44> col:25 used op_median 'vector bool unsigned long long' cinit | -InitListExpr 0x10015bb2498 <col:37, col:44> '__vector __bool unsigned long long' | |-ImplicitCastExpr 0x10015bb24e8 <col:39> 'unsigned long long' <IntegralCast> | |-IntegerLiteral 0x10015bb2408 'int' 1 | -ImplicitCastExpr 0x10015bb2500 <col:42> 'unsigned long long' <IntegralCast> |-IntegerLiteral 0x10015bb2428 'int' 4 |-DeclStmt 0x10015bf1930 <line:3:3, col:43> | -VarDecl 0x10015bb2540 <col:3, col:42> col:25 used op_less '__vector __bool unsigned long long' cinit |-InitListExpr 0x10015bf18b0 <col:35, col:42> 'vector bool unsigned long long' | |-ImplicitCastExpr 0x10015bf1900 'unsigned long long' | | -IntegerLiteral 0x10015bb25a0 <col:37> 'int' 0 |-ImplicitCastExpr 0x10015bf1918 'unsigned long long' | -IntegerLiteral 0x10015bb25c0 <col:40> 'int' 3 |-IfStmt 0x10015bf1e98 <line:4:3, col:40> | |-<<<NULL>>> | |-<<<NULL>>> | |-OpaqueValueExpr 0x10015bf1e78 <<invalid sloc>> '_Bool' | |-ReturnStmt 0x10015bf1e60 <col:33, col:40> | |-IntegerLiteral 0x10015bf1e40 'int' 1 | -<<<NULL>>> -ReturnStmt 0x10015bf1ef0 <line:5:3, col:10> `-IntegerLiteral 0x10015bf1ed0 'int' 0

llvmbot commented 7 years ago

The step to reproduce error.

int main(){ vector bool long long op_median = { 1, 4 }; vector bool long long op_less = { 0, 3 }; if ( ++op_less == op_median ) return 1; return 0; }

clang -maltivec a.c a.c:4:3: error: statement requires expression of scalar type ('attribute((__vector_size__(2 * sizeof(long long)))) long long' (vector of 2 'long long' values) invalid) if ( ++op_less == op_median ) return 1; ^ ~~~~~~ 1 error generated.