GCC Wikia
Advertisement

このページを編集する際は,編集に関する方針に従ってください.[]

概要[]

  • gcc-4.1.0/gcc/tree.cにて定義
  • argかNULLを返すばあいがほとんど
    • falseを返すのと再帰呼び出しのパターンがある

引数[]

実装[]

 1784 /* If arg is static -- a reference to an object in static storage -- then
 1785    return the object.  This is not the same as the C meaning of `static'.
 1786    If arg isn't static, return NULL.  */
1787 
1788 tree
1789 staticp (tree arg)
1790 {
1791   switch (TREE_CODE (arg))
1792     {

~

1793     case [[FUNCTION_DECL>enum tree_code]]:
 1794       /* Nested functions are static, even though taking their address will
 1795          involve a trampoline as we unnest the nested function and create
 1796          the trampoline on the tree level.  */
1797       return arg;
1798 

~

1799     case [[VAR_DECL>enum tree_code]]:
1800       return ((TREE_STATIC (arg) || DECL_EXTERNAL (arg))
1801               && ! DECL_THREAD_LOCAL_P (arg)
1802               && ! DECL_DLLIMPORT_P (arg)
1803               ? arg : NULL);
1804 

~

1805     case [[CONST_DECL>enum tree_code]]:
1806       return ((TREE_STATIC (arg) || DECL_EXTERNAL (arg))
1807               ? arg : NULL);
1808 

~

1809     case [[CONSTRUCTOR>enum tree_code]]:
1810       return TREE_STATIC (arg) ? arg : NULL;
1811 

~

1812     case [[LABEL_DECL>enum tree_code]]:
1813     case [[STRING_CST>enum tree_code]]:
1814       return arg;
1815 

~

1816     case [[COMPONENT_REF>enum tree_code]]:
 1817       /* If the thing being referenced is not a field, then it is
 1818          something language specific.  */
1819       if (TREE_CODE (TREE_OPERAND (arg, 1)) != [[FIELD_DECL>enum tree_code]])
1820         return (*lang_hooks.staticp) (arg);
1821 
 1822       /* If we are referencing a bitfield, we can't evaluate an
 1823          ADDR_EXPR at compile time and so it isn't a constant.  */
1824       if (DECL_BIT_FIELD (TREE_OPERAND (arg, 1)))
1825         return NULL;
1826 
1827       return staticp(TREE_OPERAND (arg, 0));
1828 

~

1829     case [[BIT_FIELD_REF>enum tree_code]]:
1830       return NULL;
1831 

~

1832     case [[MISALIGNED_INDIRECT_REF>enum tree_code]]:
1833     case [[ALIGN_INDIRECT_REF>enum tree_code]]:
1834     case [[INDIRECT_REF>enum tree_code]]:
1835       return TREE_CONSTANT (TREE_OPERAND (arg, 0)) ? arg : NULL;
1836 

~

1837     case [[ARRAY_REF>enum tree_code]]:
1838     case [[ARRAY_RANGE_REF>enum tree_code]]:
1839       if (TREE_CODE (TYPE_SIZE (TREE_TYPE (arg))) == [[INTEGER_CST>enum tree_code]]
1840           && TREE_CODE (TREE_OPERAND (arg, 1)) == [[INTEGER_CST>enum tree_code]])
1841         return staticp (TREE_OPERAND (arg, 0));
1842       else
1843         return false;
1844 

~

1845     default:
1846       if (((unsigned int) TREE_CODE (arg)
1847           >= (unsigned int) [[LAST_AND_UNUSED_TREE_CODE>enum tree_code]])
1848         return lang_hooks.staticp (arg);
1849       else
1850         return NULL;
1851     }
1852 }


リンク元

Advertisement