X-Git-Url: http://git.sourceforge.jp/view?a=blobdiff_plain;f=gcc%2Fc-common.c;h=3089e5dbed8ab40b0bc393e558771111f172d20e;hb=821960c78df37188d9dc47e55e9d0d4d6eb3339b;hp=c579b16f37c3377470f62e7cbb81ec68f89573dc;hpb=aa267cf692d8164823858115027a41f20eb35b46;p=pf3gnuchains%2Fgcc-fork.git diff --git a/gcc/c-common.c b/gcc/c-common.c index c579b16f37c..3089e5dbed8 100644 --- a/gcc/c-common.c +++ b/gcc/c-common.c @@ -187,10 +187,6 @@ tree c_global_trees[CTI_MAX]; langhook should take care of initialization of this array. */ bool statement_code_p[MAX_TREE_CODES]; - -/* Nonzero if we can read a PCH file now. */ - -int allow_pch = 1; /* Switches common to the C front ends. */ @@ -376,11 +372,6 @@ int flag_isoc99; int flag_hosted = 1; -/* Nonzero means add default format_arg attributes for functions not - in ISO C. */ - -int flag_noniso_default_format_attributes = 1; - /* Nonzero means warn when casting a function call to a type that does not match the return type (e.g. (float)sqrt() or (anything*)malloc() when there is no previous declaration of sqrt or malloc. */ @@ -421,6 +412,11 @@ int warn_main; int warn_sequence_point; +/* Nonzero means warn about uninitialized variable when it is initialized with itself. + For example: int i = i;, GCC will not warn about this when warn_init_self is nonzero. */ + +int warn_init_self; + /* Nonzero means to warn about compile-time division by zero. */ int warn_div_by_zero = 1; @@ -568,15 +564,18 @@ int flag_new_for_scope = 1; int flag_weak = 1; +/* 0 means we want the preprocessor to not emit line directives for + the current working directory. 1 means we want it to do it. -1 + means we should decide depending on whether debugging information + is being emitted or not. */ + +int flag_working_directory = -1; + /* Nonzero to use __cxa_atexit, rather than atexit, to register destructors for local statics and global objects. */ int flag_use_cxa_atexit = DEFAULT_USE_CXA_ATEXIT; -/* Nonzero means output .vtable_{entry,inherit} for use in doing vtable gc. */ - -int flag_vtable_gc; - /* Nonzero means make the default pedwarns warnings instead of errors. The value of this flag is ignored if -pedantic is specified. */ @@ -2214,10 +2213,12 @@ shorten_compare (tree *op0_ptr, tree *op1_ptr, tree *restype_ptr, type = c_common_signed_or_unsigned_type (unsignedp0, TREE_TYPE (primop0)); - /* If TYPE is an enumeration, then we need to get its min/max - values from it's underlying integral type, not the enumerated - type itself. */ - if (TREE_CODE (type) == ENUMERAL_TYPE) + /* In C, if TYPE is an enumeration, then we need to get its + min/max values from it's underlying integral type, not the + enumerated type itself. In C++, TYPE_MAX_VALUE and + TYPE_MIN_VALUE have already been set correctly on the + enumeration type. */ + if (!c_dialect_cxx() && TREE_CODE (type) == ENUMERAL_TYPE) type = c_common_type_for_size (TYPE_PRECISION (type), unsignedp0); maxval = TYPE_MAX_VALUE (type); @@ -2963,20 +2964,16 @@ enum built_in_attribute #define DEF_ATTR_INT(ENUM, VALUE) ENUM, #define DEF_ATTR_IDENT(ENUM, STRING) ENUM, #define DEF_ATTR_TREE_LIST(ENUM, PURPOSE, VALUE, CHAIN) ENUM, -#define DEF_FN_ATTR(NAME, ATTRS, PREDICATE) /* No entry needed in enum. */ #include "builtin-attrs.def" #undef DEF_ATTR_NULL_TREE #undef DEF_ATTR_INT #undef DEF_ATTR_IDENT #undef DEF_ATTR_TREE_LIST -#undef DEF_FN_ATTR ATTR_LAST }; static GTY(()) tree built_in_attributes[(int) ATTR_LAST]; -static bool c_attrs_initialized = false; - static void c_init_attributes (void); /* Build tree nodes and builtin functions common to both C and C++ language @@ -3354,8 +3351,7 @@ c_common_nodes_and_builtins (void) #undef DEF_FUNCTION_TYPE_VAR_3 #undef DEF_POINTER_TYPE - if (!c_attrs_initialized) - c_init_attributes (); + c_init_attributes (); #define DEF_BUILTIN(ENUM, NAME, CLASS, TYPE, LIBTYPE, \ BOTH_P, FALLBACK_P, NONANSI_P, ATTRS, IMPLICIT) \ @@ -4182,40 +4178,11 @@ c_init_attributes (void) = tree_cons (built_in_attributes[(int) PURPOSE], \ built_in_attributes[(int) VALUE], \ built_in_attributes[(int) CHAIN]); -#define DEF_FN_ATTR(NAME, ATTRS, PREDICATE) /* No initialization needed. */ #include "builtin-attrs.def" #undef DEF_ATTR_NULL_TREE #undef DEF_ATTR_INT #undef DEF_ATTR_IDENT #undef DEF_ATTR_TREE_LIST -#undef DEF_FN_ATTR - c_attrs_initialized = true; -} - -/* Depending on the name of DECL, apply default attributes to it. */ - -void -c_common_insert_default_attributes (tree decl) -{ - tree name = DECL_NAME (decl); - - if (!c_attrs_initialized) - c_init_attributes (); - -#define DEF_ATTR_NULL_TREE(ENUM) /* Nothing needed after initialization. */ -#define DEF_ATTR_INT(ENUM, VALUE) -#define DEF_ATTR_IDENT(ENUM, STRING) -#define DEF_ATTR_TREE_LIST(ENUM, PURPOSE, VALUE, CHAIN) -#define DEF_FN_ATTR(NAME, ATTRS, PREDICATE) \ - if ((PREDICATE) && name == built_in_attributes[(int) NAME]) \ - decl_attributes (&decl, built_in_attributes[(int) ATTRS], \ - ATTR_FLAG_BUILT_IN); -#include "builtin-attrs.def" -#undef DEF_ATTR_NULL_TREE -#undef DEF_ATTR_INT -#undef DEF_ATTR_IDENT -#undef DEF_ATTR_TREE_LIST -#undef DEF_FN_ATTR } /* Output a -Wshadow warning MSGCODE about NAME, and give the location @@ -5672,7 +5639,7 @@ c_estimate_num_insns_1 (tree *tp, int *walk_subtrees, void *data) return NULL; } /* Assume that constants and references counts nothing. These should - be majorized by amount of operations amoung them we count later + be majorized by amount of operations among them we count later and are common target of CSE and similar optimizations. */ if (TREE_CODE_CLASS (TREE_CODE (x)) == 'c' || TREE_CODE_CLASS (TREE_CODE (x)) == 'r') @@ -5767,4 +5734,35 @@ c_estimate_num_insns (tree decl) return num; } +/* Used by c_decl_uninit to find where expressions like x = x + 1; */ + +static tree +c_decl_uninit_1 (tree *t, int *walk_sub_trees, void *x) +{ + /* If x = EXP(&x)EXP, then do not warn about the use of x. */ + if (TREE_CODE (*t) == ADDR_EXPR && TREE_OPERAND (*t, 0) == x) + { + *walk_sub_trees = 0; + return NULL_TREE; + } + if (*t == x) + return *t; + return NULL_TREE; +} + +/* Find out if a variable is uninitialized based on DECL_INITIAL. */ + +bool +c_decl_uninit (tree t) +{ + /* int x = x; is GCC extension to turn off this warning, only if warn_init_self is zero. */ + if (DECL_INITIAL (t) == t) + return warn_init_self ? true : false; + + /* Walk the trees looking for the variable itself. */ + if (walk_tree_without_duplicates (&DECL_INITIAL (t), c_decl_uninit_1, t)) + return true; + return false; +} + #include "gt-c-common.h"