]> andersk Git - splint.git/blobdiff - src/ctype.c
Merged this branch with the one in the splint.sf.net repository.
[splint.git] / src / ctype.c
index 7fc16c481bef2841d0c72adcb6db297c3b9fac9f..ce52abafe25f79676d34b08eabf49ecf6f65b3eb 100644 (file)
@@ -236,8 +236,7 @@ ctype_realishType (ctype c)
 bool
 ctype_isUA (ctype c)
 {
-  return (!ctype_isUnknown (c) 
-         && ctbase_isUA (ctype_getCtbase (c)));
+  return (!ctype_isUnknown (c) && ctbase_isUA (ctype_getCtbase (c)));
 }
 
 bool
@@ -718,7 +717,7 @@ ctype ctype_makeRawFunction (ctype base, uentryList p)
 bool
 ctype_isFunction (ctype c)
 {
-  if (ctype_isKnown (c) && ctype_isDefined (c))
+  if ( ( ctype_isKnown (c) && (!ctype_isElips(c) ) ) && ctype_isDefined (c))
     {
       return (ctbase_isFunction (ctype_getCtbase (c)));
     }
@@ -728,6 +727,18 @@ ctype_isFunction (ctype c)
     }
 }
 
+/*
+  drl added 04-2-2002
+  trying to make up or ambiguity if ctype_isFunction
+*/
+bool ctype_isFunctionPointer (ctype c)
+{
+  if (ctype_isFunction(c) && ctype_isPointer(c) )
+    return TRUE;
+  else
+    return FALSE;    
+}
+
 bool
 ctype_isExpFcn (ctype c)
 {
@@ -1817,6 +1828,25 @@ ctype_typeId (ctype c)
   return (ctbase_typeId (ctype_getCtbase (c)));
 }
 
+
+cstring
+ctype_unparseFunctionPointer (ctype c, cstring quals,  /*@only@*/ cstring name)
+{
+  ctbase base;
+  ctype ctTmp;
+  
+  base = ctype_getCtbaseSafe (c);
+  ctTmp = base->contents.base;
+  
+  return (ctbase_doUnparseFunctionPointer (ctype_getCtbaseSafe(ctTmp), name, quals) );
+}
+
+cstring
+ctype_unparseFunction (ctype c, /*@only@*/ cstring name)
+{
+  return (ctbase_unparseFunction (ctype_getCtbaseSafe (c), name) );
+}
+
 cstring
 ctype_unparseDeclaration (ctype c, /*@only@*/ cstring name)
 {
@@ -1998,14 +2028,13 @@ ctype_getBaseType (ctype c)
 }
 
 ctype
-ctype_adjustPointers (pointers p, ctype c)
+ctype_adjustPointers (int np, ctype c)
 {
-  int np = pointers_depth (p);
-
+  
   if (ctype_isFunction (c))
     {
       c = ctype_makeParamsFunction
-        (ctype_adjustPointers (p, ctype_getReturnType (c)),
+        (ctype_adjustPointers (np, ctype_getReturnType (c)),
         uentryList_copy (ctype_argsFunction (c)));
     }
   else
@@ -2213,16 +2242,6 @@ ctype_createForwardUnion (cstring n)
   return (ct);
 }
 
-ctype
-ctype_createForwardEnum (cstring n)
-{
-  uentry ue  = uentry_makeEnumTag (n, ctype_unknown, fileloc_undefined);
-  ctype ct = usymtab_supForwardTypeEntry (ue);
-
-  cstring_free (n);
-  return (ct);
-}
-
 ctype
 ctype_removePointers (ctype c)
 {
@@ -2691,7 +2710,8 @@ ctype_widest (ctype c1, ctype c2)
     }
 }
 
-static /*@observer@*/ ctbase ctype_getCtbase (ctype c)
+//static
+/*@observer@*/ ctbase ctype_getCtbase (ctype c)
 {
   /*@+enumint@*/
   if (c >= 0 && c < cttab.size)
@@ -2716,7 +2736,8 @@ static /*@observer@*/ ctbase ctype_getCtbase (ctype c)
   /*@=enumint@*/
 }
 
-static /*@notnull@*/ /*@observer@*/ ctbase
+//static
+/*@notnull@*/ /*@observer@*/ ctbase
 ctype_getCtbaseSafe (ctype c)
 {
   ctbase res = ctype_getCtbase (c);
@@ -2796,3 +2817,118 @@ size_t ctype_getArraySize (ctype c)
   return size;
 }
 
+/*drl added 04-22-2002 */
+
+/*This is an ugly and hopefuly temporary function to
+  print a function pointer.
+  It assumes that ctype_unparse will give it something like
+  [function (int, float) returns void *]
+
+  to extract information from.
+  
+ */
+
+/*
+cstring ctype_unparseFunctionPointer (ctype type, cstring quals, cstring name)
+{
+  cstring up, params, tmp, returns, ret;
+
+  up = ctype_unparse(type);
+
+  tmp = cstring_beforeChar(up, ')');
+  params = cstring_afterChar(tmp, '(');
+
+  params = cstring_concat (params, cstring_makeLiteral(")") );
+  
+  returns = cstring_afterChar(up, ')');
+  returns = cstring_afterChar(returns, 's');
+  returns = cstring_beforeChar(returns, ']');
+  returns = cstring_afterChar(returns, ' ');
+  ret = message("%s %s (* %s) %s", quals, returns, name, params);
+
+  return ret;
+}
+*/
+
+/*drl added */
+cstring qtypetryToPrintStruct(qtype q)
+{
+  ctentry ct;
+  ctbase base;
+  uentry ue;
+  
+  cstring ret;
+  
+  ct = ctype_getCtentry(qtype_getType(q) );
+
+  llassert (ct != NULL );
+
+  base = ctentry_getCtbase(ct); 
+
+  //evil abstraction violation fix
+  /*@i232@*/
+  /*@access ctbase@*/
+
+  llassert(ctbase_isDefined(base) );
+
+  if (base->type == CT_USER) 
+
+    {
+      ue = usymtab_getTypeEntry(base->contents.tid);
+      
+      base = ctentry_getCtbase( ctype_getCtentry(uentry_getType (ue) ) );
+
+      llassert(ctbase_isDefined(base) );
+    }
+  
+  switch(base->type)
+    {
+    case CT_ENUM:
+      if (isFakeTag(base->contents.cenum->tag) )
+       {
+         ret = message ("enum { %s } ",
+                        enumNameList_unparse(base->contents.cenum->members) );
+       }
+      else
+       {
+         ret = message ("enum %s { %s } ",base->contents.cenum->tag, enumNameList_unparse(base->contents.cenum->members) );
+       }
+      break;
+    case CT_STRUCT:
+      if (isFakeTag(base->contents.su->name) )
+       {
+         ret = message ("struct { %s } ",
+                        uentryList_unparse(base->contents.su->fields) );
+       }
+      else
+       {
+         ret = message ("struct %s { %s } ",
+                        base->contents.su->name, uentryList_unparse(base->contents.su->fields) );
+       }
+
+      break;
+    case CT_UNION:
+      if (isFakeTag(base->contents.su->name) )
+       {
+         ret = message ("union { %s } ",
+                        uentryList_unparse(base->contents.su->fields) );
+       }
+      else
+       {
+         ret = message ("union %s { %s } ",
+                        base->contents.su->name, uentryList_unparse(base->contents.su->fields) );
+       }
+      /*@noaccess ctbase@*/
+      break;
+       case CT_UNKNOWN:
+        //      ret = message("%s", uentry_unparse(ue) );
+        //      break;
+    case CT_PRIM:
+    default:
+      ret = message ("%s", qtype_unparse(q) );
+      break;
+   
+      //   BADDEFAULT;
+          }
+  return ret;
+}
This page took 0.050516 seconds and 4 git commands to generate.