Merge function types in C.
Among other differences, GCC accepts typedef int IA[]; typedef int A10[10]; static A10 *f(void); static IA *f(void); void g(void) { (void)sizeof(*f()); } but clang used to reject it with: invalid application of 'sizeof' to an incomplete type 'IA' (aka 'int []') The intention of c99's 6.2.7 seems to be that we should use the composite type and accept as gcc does. Doing the type merging required some extra fixes: * Use the type from the function type in initializations, even if an parameter is available. * Fix the merging of the noreturn attribute in function types. * Make CodeGen handle the fact that an parameter type can be different from the corresponding type in the function type. llvm-svn: 168895
Showing
- clang/include/clang/Sema/Initialization.h 11 additions, 3 deletionsclang/include/clang/Sema/Initialization.h
- clang/lib/AST/ASTContext.cpp 5 additions, 5 deletionsclang/lib/AST/ASTContext.cpp
- clang/lib/CodeGen/CGCall.cpp 9 additions, 1 deletionclang/lib/CodeGen/CGCall.cpp
- clang/lib/Sema/SemaDecl.cpp 6 additions, 0 deletionsclang/lib/Sema/SemaDecl.cpp
- clang/lib/Sema/SemaExpr.cpp 4 additions, 4 deletionsclang/lib/Sema/SemaExpr.cpp
- clang/test/Sema/merge-decls.c 43 additions, 0 deletionsclang/test/Sema/merge-decls.c
Loading
Please register or sign in to comment