]> granicus.if.org Git - clang/commitdiff
Fix rdar://5905347 a crash on invalid builtin, due to the
authorChris Lattner <sabre@nondot.org>
Mon, 5 May 2008 22:18:14 +0000 (22:18 +0000)
committerChris Lattner <sabre@nondot.org>
Mon, 5 May 2008 22:18:14 +0000 (22:18 +0000)
params not getting installed for builtins when synthesized.

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

lib/Sema/SemaDecl.cpp
test/Sema/builtins.c

index f583ad1606a3ed0a8cd8fdb76c4d5527aa1a495e..2624f5019db1630e2f897fb9114b1f37e6a44977 100644 (file)
@@ -143,8 +143,7 @@ Decl *Sema::LookupDecl(const IdentifierInfo *II, unsigned NSI,
   return 0;
 }
 
-void Sema::InitBuiltinVaListType()
-{
+void Sema::InitBuiltinVaListType() {
   if (!Context.getBuiltinVaListType().isNull())
     return;
   
@@ -161,8 +160,8 @@ ScopedDecl *Sema::LazilyCreateBuiltin(IdentifierInfo *II, unsigned bid,
   Builtin::ID BID = (Builtin::ID)bid;
 
   if (BID == Builtin::BI__builtin_va_start ||
-       BID == Builtin::BI__builtin_va_copy ||
-       BID == Builtin::BI__builtin_va_end)
+      BID == Builtin::BI__builtin_va_copy ||
+      BID == Builtin::BI__builtin_va_end)
     InitBuiltinVaListType();
     
   QualType R = Context.BuiltinInfo.GetBuiltinType(BID, Context);  
@@ -171,6 +170,19 @@ ScopedDecl *Sema::LazilyCreateBuiltin(IdentifierInfo *II, unsigned bid,
                                            SourceLocation(), II, R,
                                            FunctionDecl::Extern, false, 0);
   
+  // Create Decl objects for each parameter, adding them to the
+  // FunctionDecl.
+  if (FunctionTypeProto *FT = dyn_cast<FunctionTypeProto>(R)) {
+    llvm::SmallVector<ParmVarDecl*, 16> Params;
+    for (unsigned i = 0, e = FT->getNumArgs(); i != e; ++i)
+      Params.push_back(ParmVarDecl::Create(Context, New, SourceLocation(), 0,
+                                           FT->getArgType(i), VarDecl::None, 0,
+                                           0));
+    New->setParams(&Params[0], Params.size());
+  }
+  
+  
+  
   // TUScope is the translation-unit scope to insert this function into.
   TUScope->AddDecl(New);
   
index ca3cbaf8dcaf3f5c278d990ad11fa45dd0adee71..58cb92f5134b49a9212d2dc0133534e6e5d2cada 100644 (file)
@@ -30,3 +30,12 @@ void cfstring() {
   CFSTR("foo", "bar"); // expected-error {{ error: too many arguments to function }}
 }
 
+
+typedef __attribute__(( ext_vector_type(16) )) unsigned char uchar16;  // expected-warning {{extension}}
+
+// rdar://5905347
+unsigned char foo( short v ) {
+  uchar16 c;
+  return __builtin_ia32_vec_ext_v4si( c );  // expected-error {{too few arguments to function}}
+}
+