diff options
| author | Reid Kleckner <reid@kleckner.net> | 2014-07-11 23:54:29 +0000 |
|---|---|---|
| committer | Reid Kleckner <reid@kleckner.net> | 2014-07-11 23:54:29 +0000 |
| commit | f392ec6ecc249a34731951baacf8ccf99f1a732d (patch) | |
| tree | 60b5e549d680c99d54508c7c184b0b90b0b5bf55 /clang/lib/Sema | |
| parent | cb314ceaa9bb803f1c77e6bb32f9c74686f1d876 (diff) | |
| download | bcm5719-llvm-f392ec6ecc249a34731951baacf8ccf99f1a732d.tar.gz bcm5719-llvm-f392ec6ecc249a34731951baacf8ccf99f1a732d.zip | |
Form a CallExpr from __noop without parens
MSVC accepts __noop without any trailing parens and treats it like a
literal zero. We don't treat __noop as an integer literal, but now at
least we can parse a naked __noop expression.
Reviewers: rsmith
Differential Revision: http://reviews.llvm.org/D4476
llvm-svn: 212860
Diffstat (limited to 'clang/lib/Sema')
| -rw-r--r-- | clang/lib/Sema/SemaExpr.cpp | 15 |
1 files changed, 14 insertions, 1 deletions
diff --git a/clang/lib/Sema/SemaExpr.cpp b/clang/lib/Sema/SemaExpr.cpp index 67e839c7e59..8db782a7e20 100644 --- a/clang/lib/Sema/SemaExpr.cpp +++ b/clang/lib/Sema/SemaExpr.cpp @@ -13477,9 +13477,22 @@ ExprResult Sema::CheckPlaceholderExpr(Expr *E) { case BuiltinType::PseudoObject: return checkPseudoObjectRValue(E); - case BuiltinType::BuiltinFn: + case BuiltinType::BuiltinFn: { + // Accept __noop without parens by implicitly converting it to a call expr. + auto *DRE = dyn_cast<DeclRefExpr>(E->IgnoreParenImpCasts()); + if (DRE) { + auto *FD = cast<FunctionDecl>(DRE->getDecl()); + if (FD->getBuiltinID() == Builtin::BI__noop) { + E = ImpCastExprToType(E, Context.getPointerType(FD->getType()), + CK_BuiltinFnToFnPtr).get(); + return new (Context) CallExpr(Context, E, None, Context.IntTy, + VK_RValue, SourceLocation()); + } + } + Diag(E->getLocStart(), diag::err_builtin_fn_use); return ExprError(); + } // Everything else should be impossible. #define BUILTIN_TYPE(Id, SingletonId) \ |

