diff options
| author | Aaron Ballman <aaron@aaronballman.com> | 2017-02-11 17:49:53 +0000 |
|---|---|---|
| committer | Aaron Ballman <aaron@aaronballman.com> | 2017-02-11 17:49:53 +0000 |
| commit | 3dcb85b01f2d4ecbd1616579e9f96391e509aa38 (patch) | |
| tree | eaa7544ec0340209414c51f96e902d93f67d7f47 /clang/lib | |
| parent | 9df26d330fd53a8a81cc68d8e7aa0a0f3e1a456a (diff) | |
| download | bcm5719-llvm-3dcb85b01f2d4ecbd1616579e9f96391e509aa38.tar.gz bcm5719-llvm-3dcb85b01f2d4ecbd1616579e9f96391e509aa38.zip | |
Attributes on K&R C functions should not cause incompatible function type with a redeclaration having the same attribute. Fixing this introduced a secondary problem where we were assuming that K&R functions could not be attributed types when reporting old-style function definitions that are not preceded by a prototype.
This patch fixes PR31020.
llvm-svn: 294861
Diffstat (limited to 'clang/lib')
| -rw-r--r-- | clang/lib/Sema/SemaDecl.cpp | 9 |
1 files changed, 5 insertions, 4 deletions
diff --git a/clang/lib/Sema/SemaDecl.cpp b/clang/lib/Sema/SemaDecl.cpp index 5f98d4505f1..bc4611cb067 100644 --- a/clang/lib/Sema/SemaDecl.cpp +++ b/clang/lib/Sema/SemaDecl.cpp @@ -7564,11 +7564,12 @@ static FunctionDecl* CreateNewFunctionDecl(Sema &SemaRef, Declarator &D, // Determine whether the function was written with a // prototype. This true when: // - there is a prototype in the declarator, or - // - the type R of the function is some kind of typedef or other reference - // to a type name (which eventually refers to a function type). + // - the type R of the function is some kind of typedef or other non- + // attributed reference to a type name (which eventually refers to a + // function type). bool HasPrototype = (D.isFunctionDeclarator() && D.getFunctionTypeInfo().hasPrototype) || - (!isa<FunctionType>(R.getTypePtr()) && R->isFunctionProtoType()); + (!R->getAsAdjusted<FunctionType>() && R->isFunctionProtoType()); NewFD = FunctionDecl::Create(SemaRef.Context, DC, D.getLocStart(), NameInfo, R, @@ -12104,7 +12105,7 @@ Decl *Sema::ActOnFinishFunctionBody(Decl *dcl, Stmt *Body, !LangOpts.CPlusPlus) { TypeSourceInfo *TI = FD->getTypeSourceInfo(); TypeLoc TL = TI->getTypeLoc(); - FunctionTypeLoc FTL = TL.castAs<FunctionTypeLoc>(); + FunctionTypeLoc FTL = TL.getAsAdjusted<FunctionTypeLoc>(); Diag(FTL.getLParenLoc(), diag::warn_strict_prototypes) << 1; } } |

