[cfe-commits] [PATCH] Preserve FunctionType::ExtInfo across template instantiation

Eli Friedman eli.friedman at gmail.com
Sat Jul 24 17:06:53 PDT 2010


On Sat, Jul 24, 2010 at 4:55 PM, Eli Friedman <eli.friedman at gmail.com> wrote:
> Patch attached.  Fixes Sema handling of constructs like
> "template<typename T> void p(T (__attribute__((fastcall)) *f)(void));"
>
> Does this look like the right thing to do?

Erm, that version has some extra junk; right version attached.

-Eli
-------------- next part --------------
Index: lib/Sema/Sema.h
===================================================================
--- lib/Sema/Sema.h	(revision 109357)
+++ lib/Sema/Sema.h	(working copy)
@@ -742,7 +745,8 @@
   QualType BuildFunctionType(QualType T,
                              QualType *ParamTypes, unsigned NumParamTypes,
                              bool Variadic, unsigned Quals,
-                             SourceLocation Loc, DeclarationName Entity);
+                             SourceLocation Loc, DeclarationName Entity,
+                             const FunctionType::ExtInfo &Info);
   QualType BuildMemberPointerType(QualType T, QualType Class,
                                   SourceLocation Loc,
                                   DeclarationName Entity);
Index: lib/Sema/TreeTransform.h
===================================================================
--- lib/Sema/TreeTransform.h	(revision 109357)
+++ lib/Sema/TreeTransform.h	(working copy)
@@ -468,7 +468,8 @@
   QualType RebuildFunctionProtoType(QualType T,
                                     QualType *ParamTypes,
                                     unsigned NumParamTypes,
-                                    bool Variadic, unsigned Quals);
+                                    bool Variadic, unsigned Quals,
+                                    const FunctionType::ExtInfo &Info);
 
   /// \brief Build a new unprototyped function type.
   QualType RebuildFunctionNoProtoType(QualType ResultType);
@@ -2932,7 +2933,8 @@
                                                    ParamTypes.data(),
                                                    ParamTypes.size(),
                                                    T->isVariadic(),
-                                                   T->getTypeQuals());
+                                                   T->getTypeQuals(),
+                                                   T->getExtInfo());
     if (Result.isNull())
       return QualType();
   }
@@ -6258,7 +6260,8 @@
                                                         ParamTypes.data(),
                                                         ParamTypes.size(),
                                                         BD->isVariadic(),
-                                                        0);
+                                                        0,
+                                               BExprFunctionType->getExtInfo());
   
   CurBlock->FunctionType = FunctionType;
   return SemaRef.ActOnBlockStmtExpr(CaretLoc, move(Body), /*Scope=*/0);
@@ -6435,11 +6438,13 @@
                                                           QualType *ParamTypes,
                                                         unsigned NumParamTypes,
                                                           bool Variadic,
-                                                          unsigned Quals) {
+                                                          unsigned Quals,
+                                            const FunctionType::ExtInfo &Info) {
   return SemaRef.BuildFunctionType(T, ParamTypes, NumParamTypes, Variadic,
                                    Quals,
                                    getDerived().getBaseLocation(),
-                                   getDerived().getBaseEntity());
+                                   getDerived().getBaseEntity(),
+                                   Info);
 }
 
 template<typename Derived>
Index: lib/Sema/SemaTemplateDeduction.cpp
===================================================================
--- lib/Sema/SemaTemplateDeduction.cpp	(revision 109357)
+++ lib/Sema/SemaTemplateDeduction.cpp	(working copy)
@@ -1245,7 +1245,8 @@
                                       Proto->isVariadic(),
                                       Proto->getTypeQuals(),
                                       Function->getLocation(),
-                                      Function->getDeclName());
+                                      Function->getDeclName(),
+                                      Proto->getExtInfo());
     if (FunctionType->isNull() || Trap.hasErrorOccurred())
       return TDK_SubstitutionFailure;
   }
Index: lib/Sema/SemaType.cpp
===================================================================
--- lib/Sema/SemaType.cpp	(revision 109357)
+++ lib/Sema/SemaType.cpp	(working copy)
@@ -810,7 +810,8 @@
                                  QualType *ParamTypes,
                                  unsigned NumParamTypes,
                                  bool Variadic, unsigned Quals,
-                                 SourceLocation Loc, DeclarationName Entity) {
+                                 SourceLocation Loc, DeclarationName Entity,
+                                 const FunctionType::ExtInfo &Info) {
   if (T->isArrayType() || T->isFunctionType()) {
     Diag(Loc, diag::err_func_returning_array_function) 
       << T->isFunctionType() << T;
@@ -832,8 +833,7 @@
     return QualType();
 
   return Context.getFunctionType(T, ParamTypes, NumParamTypes, Variadic,
-                                 Quals, false, false, 0, 0,
-                                 FunctionType::ExtInfo());
+                                 Quals, false, false, 0, 0, Info);
 }
 
 /// \brief Build a member pointer type \c T Class::*.


More information about the cfe-commits mailing list