]> granicus.if.org Git - clang/commitdiff
[Sema] Check if a builtin is FunctionPrototype().
authorDavide Italiano <davide@freebsd.org>
Sat, 25 Apr 2015 20:20:04 +0000 (20:20 +0000)
committerDavide Italiano <davide@freebsd.org>
Sat, 25 Apr 2015 20:20:04 +0000 (20:20 +0000)
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

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@235806 91177308-0d34-0410-b5e6-96231b3b80d8

lib/Sema/SemaDecl.cpp
test/Sema/crash-invalid-builtin.c [new file with mode: 0644]

index 6916710036cdc0960018c2fba51cc44760824126..339280614ff9a68f6d992f2164b443ba81de8948 100644 (file)
@@ -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 (file)
index 0000000..1c5221f
--- /dev/null
@@ -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 ()'}}