diff options
author | Eli Friedman <eli.friedman@gmail.com> | 2012-08-30 00:44:15 +0000 |
---|---|---|
committer | Eli Friedman <eli.friedman@gmail.com> | 2012-08-30 00:44:15 +0000 |
commit | 448ce40426f227e25856f90534cae4fc47c22ee5 (patch) | |
tree | 1be0d4148595ea2f41f43d5d212ee6b9f6f4174a | |
parent | 271f11b57185eb371fd65a437816b1fdb26a65ed (diff) | |
download | bcm5719-llvm-448ce40426f227e25856f90534cae4fc47c22ee5.tar.gz bcm5719-llvm-448ce40426f227e25856f90534cae4fc47c22ee5.zip |
Fix a crash in type merging with enum types.
llvm-svn: 162886
-rw-r--r-- | clang/lib/AST/ASTContext.cpp | 9 | ||||
-rw-r--r-- | clang/test/Sema/function-redecl.c | 4 |
2 files changed, 10 insertions, 3 deletions
diff --git a/clang/lib/AST/ASTContext.cpp b/clang/lib/AST/ASTContext.cpp index 0c2cc1c6171..33846019810 100644 --- a/clang/lib/AST/ASTContext.cpp +++ b/clang/lib/AST/ASTContext.cpp @@ -6413,10 +6413,13 @@ QualType ASTContext::mergeFunctionTypes(QualType lhs, QualType rhs, for (unsigned i = 0; i < proto_nargs; ++i) { QualType argTy = proto->getArgType(i); - // Look at the promotion type of enum types, since that is the type used + // Look at the converted type of enum types, since that is the type used // to pass enum values. - if (const EnumType *Enum = argTy->getAs<EnumType>()) - argTy = Enum->getDecl()->getPromotionType(); + if (const EnumType *Enum = argTy->getAs<EnumType>()) { + argTy = Enum->getDecl()->getIntegerType(); + if (argTy.isNull()) + return QualType(); + } if (argTy->isPromotableIntegerType() || getCanonicalType(argTy).getUnqualifiedType() == FloatTy) diff --git a/clang/test/Sema/function-redecl.c b/clang/test/Sema/function-redecl.c index 7076bdf3bd1..ff8e003cd72 100644 --- a/clang/test/Sema/function-redecl.c +++ b/clang/test/Sema/function-redecl.c @@ -129,3 +129,7 @@ void test_x() { enum e0 {one}; void f3(); void f3(enum e0 x) {} + +enum incomplete_enum; +void f4(); // expected-note {{previous declaration is here}} +void f4(enum incomplete_enum); // expected-error {{conflicting types for 'f4'}} |