diff options
| author | Chris Lattner <sabre@nondot.org> | 2008-12-12 05:05:20 +0000 | 
|---|---|---|
| committer | Chris Lattner <sabre@nondot.org> | 2008-12-12 05:05:20 +0000 | 
| commit | f45c5ecb3bbd4183b0675689f4cdf6884e7e269f (patch) | |
| tree | ec9de74f858c31e543a61c708de5f8c97f55c0ac /clang/lib/Sema/SemaExpr.cpp | |
| parent | 81ed6805db67b5b435650334df4bf97ca2cc55f7 (diff) | |
| download | bcm5719-llvm-f45c5ecb3bbd4183b0675689f4cdf6884e7e269f.tar.gz bcm5719-llvm-f45c5ecb3bbd4183b0675689f4cdf6884e7e269f.zip | |
fix rdar://6097892 - gcc incompat: clang rejects __func__, __FUNCTION__, and __PRETTY_FUNCTION__ outside func
Yeah, this is "useful".
llvm-svn: 60921
Diffstat (limited to 'clang/lib/Sema/SemaExpr.cpp')
| -rw-r--r-- | clang/lib/Sema/SemaExpr.cpp | 14 | 
1 files changed, 8 insertions, 6 deletions
| diff --git a/clang/lib/Sema/SemaExpr.cpp b/clang/lib/Sema/SemaExpr.cpp index ba5d28a6334..264b85b69cb 100644 --- a/clang/lib/Sema/SemaExpr.cpp +++ b/clang/lib/Sema/SemaExpr.cpp @@ -597,17 +597,19 @@ Sema::ExprResult Sema::ActOnPredefinedExpr(SourceLocation Loc,    case tok::kw___PRETTY_FUNCTION__: IT = PredefinedExpr::PrettyFunction; break;    } -  // Verify that this is in a function context. -  if (getCurFunctionOrMethodDecl() == 0) -    return Diag(Loc, diag::err_predef_outside_function); -      // Pre-defined identifiers are of type char[x], where x is the length of the    // string.    unsigned Length;    if (FunctionDecl *FD = getCurFunctionDecl())      Length = FD->getIdentifier()->getLength(); -  else -    Length = getCurMethodDecl()->getSynthesizedMethodSize(); +  else if (ObjCMethodDecl *MD = getCurMethodDecl()) +    Length = MD->getSynthesizedMethodSize(); +  else { +    Diag(Loc, diag::ext_predef_outside_function); +    // __PRETTY_FUNCTION__ -> "top level", the others produce an empty string. +    Length = IT == PredefinedExpr::PrettyFunction ? strlen("top level") : 0; +  } +      llvm::APInt LengthI(32, Length + 1);    QualType ResTy = Context.CharTy.getQualifiedType(QualType::Const); | 

