[Sema] Check if a builtin is FunctionPrototype().
Don't assume it's always is. This prevents a crash in Sema while
trying to merge return type for a builtin w/out function prototype.
PR: 23086
Differential Revision: http://reviews.llvm.org/D9235
Reviewed by: rsmith
llvm-svn: 235806
diff --git a/clang/lib/Sema/SemaDecl.cpp b/clang/lib/Sema/SemaDecl.cpp
index 6916710..3392806 100644
--- a/clang/lib/Sema/SemaDecl.cpp
+++ b/clang/lib/Sema/SemaDecl.cpp
@@ -1749,7 +1749,7 @@
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/clang/test/Sema/crash-invalid-builtin.c b/clang/test/Sema/crash-invalid-builtin.c
new file mode 100644
index 0000000..1c5221f
--- /dev/null
+++ b/clang/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 ()'}}