[cfe-commits] [Request for review] cast<ComplexType> is called on sugared types
Abramo Bagnara
abramo.bagnara at gmail.com
Sun Dec 26 03:59:30 PST 2010
$ cat t.c
typedef _Complex int ci;
typedef _Complex float cf;
int v() {
ci x;
cf y;
x = (int) y;
}
$ ~/llvm/Debug+Asserts/bin/clang -c t.c
clang: /space/home/abagnara/llvm/include/llvm/Support/Casting.h:202:
typename llvm::cast_retty<To, From>::ret_type llvm::cast(const Y&) [with
X = clang::ComplexType, Y = clang::QualType, typename
llvm::cast_retty<To, From>::ret_type = clang::ComplexType*]: Assertion
`isa<X>(Val) && "cast<Ty>() argument of incompatible type!"' failed.
0 clang 0x00000000020b3f11
1 clang 0x00000000020b3d04
2 libpthread.so.0 0x00000036aa80f0f0
3 libc.so.6 0x00000036a9c32f05 gsignal + 53
4 libc.so.6 0x00000036a9c34a73 abort + 387
5 libc.so.6 0x00000036a9c2bef9 __assert_fail + 233
6 clang 0x0000000001120e34
llvm::cast_retty<clang::ComplexType, clang::QualType>::ret_type
llvm::cast<clang::ComplexType, clang::QualType>(clang::QualType const&) + 62
7 clang 0x00000000013cbab7
8 clang 0x00000000013cc835
clang::Sema::CheckCastTypes(clang::SourceRange, clang::QualType,
clang::Expr*&, clang::CastKind&, clang::ExprValueKind&,
llvm::SmallVector<clang::CXXBaseSpecifier*, 4u>&, bool) + 2981
9 clang 0x00000000013ccf10
clang::Sema::BuildCStyleCastExpr(clang::SourceLocation,
clang::TypeSourceInfo*, clang::SourceLocation, clang::Expr*) + 192
10 clang 0x00000000013cce49
clang::Sema::ActOnCastExpr(clang::Scope*, clang::SourceLocation,
clang::OpaquePtr<clang::QualType>, clang::SourceLocation, clang::Expr*)
+ 253
11 clang 0x00000000012e096d
clang::Parser::ParseParenExpression(clang::Parser::ParenParseOption&,
bool, clang::OpaquePtr<clang::QualType>,
clang::OpaquePtr<clang::QualType>&, clang::SourceLocation&) + 2199
12 clang 0x00000000012dca33
clang::Parser::ParseCastExpression(bool, bool, bool&,
clang::OpaquePtr<clang::QualType>) + 355
13 clang 0x00000000012dc884
clang::Parser::ParseCastExpression(bool, bool,
clang::OpaquePtr<clang::QualType>) + 60
14 clang 0x00000000012dc47a
clang::Parser::ParseRHSOfBinaryExpression(clang::ActionResult<clang::Expr*,
true>, clang::prec::Level) + 1364
15 clang 0x00000000012dbe27
clang::Parser::ParseAssignmentExpression() + 207
16 clang 0x00000000012dbbf2 clang::Parser::ParseExpression() + 24
17 clang 0x00000000012b5f74
clang::Parser::ParseStatementOrDeclaration(clang::ASTOwningVector<clang::Stmt*,
32u>&, bool) + 924
18 clang 0x00000000012b6f00
clang::Parser::ParseCompoundStatementBody(bool) + 264
19 clang 0x00000000012ba880
clang::Parser::ParseFunctionStatementBody(clang::Decl*) + 146
20 clang 0x00000000012c0851
clang::Parser::ParseFunctionDefinition(clang::Parser::ParsingDeclarator&, clang::Parser::ParsedTemplateInfo
const&) + 1001
21 clang 0x00000000012c67d0
clang::Parser::ParseDeclGroup(clang::Parser::ParsingDeclSpec&, unsigned
int, bool, clang::SourceLocation*) + 522
22 clang 0x00000000012c03dd
clang::Parser::ParseDeclarationOrFunctionDefinition(clang::Parser::ParsingDeclSpec&,
clang::AttributeList*, clang::AccessSpecifier) + 1079
23 clang 0x00000000012c0449
clang::Parser::ParseDeclarationOrFunctionDefinition(clang::AttributeList*,
clang::AccessSpecifier) + 95
24 clang 0x00000000012bfda4
clang::Parser::ParseExternalDeclaration(clang::CXX0XAttributeList,
clang::Parser::ParsingDeclSpec*) + 2364
25 clang 0x00000000012bf3d9
clang::Parser::ParseTopLevelDecl(clang::OpaquePtr<clang::DeclGroupRef>&)
+ 343
26 clang 0x00000000012a97f0 clang::ParseAST(clang::Sema&,
bool) + 328
27 clang 0x000000000101d75d
clang::ASTFrontendAction::ExecuteAction() + 263
28 clang 0x000000000114790f
clang::CodeGenAction::ExecuteAction() + 969
29 clang 0x000000000101d3b0 clang::FrontendAction::Execute() + 320
30 clang 0x0000000001005f81
clang::CompilerInstance::ExecuteAction(clang::FrontendAction&) + 745
31 clang 0x0000000000fb566d
clang::ExecuteCompilerInvocation(clang::CompilerInstance*) + 878
32 clang 0x0000000000fa79bf cc1_main(char const**, char
const**, char const*, void*) + 990
33 clang 0x0000000000fb0c0c main + 484
34 libc.so.6 0x00000036a9c1e576 __libc_start_main + 230
35 clang 0x0000000000fa7059
Stack dump:
0. Program arguments: /space/home/abagnara/llvm/Debug+Asserts/bin/clang
-cc1 -triple x86_64-unknown-linux-gnu -emit-obj -mrelax-all
-disable-free -main-file-name t.c -mrelocation-model static
-mdisable-fp-elim -masm-verbose -mconstructor-aliases -munwind-tables
-target-cpu x86-64 -target-linker-version 2.18.50.0.9 -resource-dir
/space/home/abagnara/llvm/Debug+Asserts/bin/../lib/clang/2.9
-ferror-limit 19 -fmessage-length 80 -fgnu-runtime
-fdiagnostics-show-option -fcolor-diagnostics -o t.o -x c t.c
1. t.c:8:14: current parser token ';'
2. t.c:5:9: parsing function body 'v'
3. t.c:5:9: in compound statement ('{}')
clang: error: unable to execute command: Aborted
clang: error: clang frontend command failed due to signal 1 (use -v to
see invocation)
The problem is originated from PrepareScalarCast where we have some
lines like this:
S.ImpCastExprToType(Src, cast<ComplexType>(DestTy)->getElementType(),
CK_IntegralCast);
DestTy is not canonical and then the cast fails with a violated assertion.
-------------- next part --------------
An embedded and charset-unspecified text was scrubbed...
Name: patch
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20101226/d6cf3aa1/attachment.ksh>
More information about the cfe-commits
mailing list