diff --git a/lib/Sema/SemaDecl.cpp b/lib/Sema/SemaDecl.cpp
index 6916710036cdc0960018c2fba51cc44760824126..339280614ff9a68f6d992f2164b443ba81de8948 100644
--- a/lib/Sema/SemaDecl.cpp
+++ b/lib/Sema/SemaDecl.cpp
@@ -1749,7 +1749,7 @@ NamedDecl *Sema::LazilyCreateBuiltin(IdentifierInfo *II, unsigned ID,
                                            Loc, Loc, II, R, /*TInfo=*/nullptr,
                                            SC_Extern,
                                            false,
-                                           /*hasPrototype=*/true);
+                                           R->isFunctionProtoType());
   New->setImplicit();
 
   // Create Decl objects for each parameter, adding them to the
diff --git a/test/Sema/crash-invalid-builtin.c b/test/Sema/crash-invalid-builtin.c
new file mode 100644
index 0000000000000000000000000000000000000000..1c5221fa40d634622e7a09647a1fd9950cf2f9da
--- /dev/null
+++ b/test/Sema/crash-invalid-builtin.c
@@ -0,0 +1,4 @@
+// RUN: %clang_cc1 -triple=x86_64-apple-darwin -fsyntax-only -verify %s
+// PR23086
+
+__builtin_isinf(...); // expected-warning {{type specifier missing, defaults to 'int'}} expected-error {{ISO C requires a named parameter before '...'}} // expected-error {{conflicting types for '__builtin_isinf'}} // expected-note {{'__builtin_isinf' is a builtin with type 'int ()'}}