View | Details | Raw Unified | Return to bug 33255 | Differences between
and this patch

Collapse All | Expand All

(-)a/gcc/Makefile.in (-1 / +1 lines)
Lines 937-943 ALIAS_H = alias.h coretypes.h Link Here
937
EMIT_RTL_H = emit-rtl.h
937
EMIT_RTL_H = emit-rtl.h
938
FLAGS_H = flags.h coretypes.h flag-types.h $(OPTIONS_H)
938
FLAGS_H = flags.h coretypes.h flag-types.h $(OPTIONS_H)
939
OPTIONS_H = options.h flag-types.h $(OPTIONS_H_EXTRA)
939
OPTIONS_H = options.h flag-types.h $(OPTIONS_H_EXTRA)
940
FUNCTION_H = function.h $(TREE_H) $(HASHTAB_H) vecprim.h $(TM_H) hard-reg-set.h
940
FUNCTION_H = function.h $(TREE_H) $(HASHTAB_H) vecprim.h $(TM_H) hard-reg-set.h pointer-set.h
941
EXPR_H = expr.h insn-config.h $(FUNCTION_H) $(RTL_H) $(FLAGS_H) $(TREE_H) $(MACHMODE_H) $(EMIT_RTL_H)
941
EXPR_H = expr.h insn-config.h $(FUNCTION_H) $(RTL_H) $(FLAGS_H) $(TREE_H) $(MACHMODE_H) $(EMIT_RTL_H)
942
OPTABS_H = optabs.h insn-codes.h
942
OPTABS_H = optabs.h insn-codes.h
943
REGS_H = regs.h $(MACHMODE_H) hard-reg-set.h
943
REGS_H = regs.h $(MACHMODE_H) hard-reg-set.h
(-)a/gcc/c-decl.c (-1 / +53 lines)
Lines 2769-2775 pushdecl (tree x) Link Here
2769
2769
2770
 skip_external_and_shadow_checks:
2770
 skip_external_and_shadow_checks:
2771
  if (TREE_CODE (x) == TYPE_DECL)
2771
  if (TREE_CODE (x) == TYPE_DECL)
2772
    set_underlying_type (x);
2772
    {
2773
      /* So this is a typedef, set its underlying type.  */
2774
      set_underlying_type (x);
2775
2776
      /* If X is a typedef defined in the current function, record it
2777
	 for the purpose of implementing the -Wunused-local-typedefs
2778
	 warning.  */
2779
      record_locally_defined_typedef (x);
2780
    }
2773
2781
2774
  bind (name, x, scope, /*invisible=*/false, nested, locus);
2782
  bind (name, x, scope, /*invisible=*/false, nested, locus);
2775
2783
Lines 6076-6081 grokdeclarator (const struct c_declarator *declarator, Link Here
6076
     name of a variable.  Thus, if it's known before this, die horribly.  */
6084
     name of a variable.  Thus, if it's known before this, die horribly.  */
6077
    gcc_assert (!DECL_ASSEMBLER_NAME_SET_P (decl));
6085
    gcc_assert (!DECL_ASSEMBLER_NAME_SET_P (decl));
6078
6086
6087
    maybe_record_local_typedef_use (TREE_TYPE (decl));
6088
6079
    if (warn_cxx_compat
6089
    if (warn_cxx_compat
6080
	&& TREE_CODE (decl) == VAR_DECL
6090
	&& TREE_CODE (decl) == VAR_DECL
6081
	&& TREE_PUBLIC (decl)
6091
	&& TREE_PUBLIC (decl)
Lines 8265-8270 finish_function (void) Link Here
8265
		      "parameter %qD set but not used", decl);
8275
		      "parameter %qD set but not used", decl);
8266
    }
8276
    }
8267
8277
8278
  /* Complain about locally defined typedefs that are not used in this
8279
     function.  */
8280
  maybe_warn_unused_local_typedefs ();
8281
8268
  /* Store the end of the function, so that we get good line number
8282
  /* Store the end of the function, so that we get good line number
8269
     info for the epilogue.  */
8283
     info for the epilogue.  */
8270
  cfun->function_end_locus = input_location;
8284
  cfun->function_end_locus = input_location;
Lines 9888-9891 c_register_addr_space (const char *word, addr_space_t as) Link Here
9888
  ridpointers [rid] = id;
9902
  ridpointers [rid] = id;
9889
}
9903
}
9890
9904
9905
/* Subroutine of c_maybe_record_local_typedef_use, called from
9906
   walk_tree_without_duplicates.   */
9907
9908
static tree
9909
maybe_record_local_typedef_use_r (tree *tp,
9910
				  int *walk_subtrees ATTRIBUTE_UNUSED,
9911
				  void *data ATTRIBUTE_UNUSED)
9912
{
9913
  maybe_record_local_typedef_use_real (*tp);
9914
  return NULL_TREE;
9915
}
9916
9917
/* A subroutine of maybe_record_local_typedef_use.  */
9918
9919
static void
9920
c_maybe_record_local_typedef_use (tree t)
9921
{
9922
    if (!warn_unused_local_typedefs)
9923
      return;
9924
9925
    maybe_record_local_typedef_use_real (t);
9926
9927
    /* Record the typedefs used by subtypes of TYPE.  */
9928
    walk_tree_without_duplicates (&t,
9929
				  maybe_record_local_typedef_use_r,
9930
				  NULL_TREE);
9931
}
9932
9933
/* If T is a typedef variant type or a TYPE_DECL declared locally,
9934
   record it in CFUN->USED_LOCAL_TYPEDEFS.  This function also records
9935
   the typedefs that are direct or indirect subtypes of T.  */
9936
9937
void
9938
maybe_record_local_typedef_use (tree t)
9939
{
9940
  c_maybe_record_local_typedef_use (t);
9941
}
9942
9891
#include "gt-c-decl.h"
9943
#include "gt-c-decl.h"
(-)a/gcc/c-family/c-common.c (+95 lines)
Lines 4340-4345 c_sizeof_or_alignof_type (location_t loc, Link Here
4340
  value = fold_convert_loc (loc, size_type_node, value);
4340
  value = fold_convert_loc (loc, size_type_node, value);
4341
  gcc_assert (!TYPE_IS_SIZETYPE (TREE_TYPE (value)));
4341
  gcc_assert (!TYPE_IS_SIZETYPE (TREE_TYPE (value)));
4342
4342
4343
  maybe_record_local_typedef_use (type);
4344
4343
  return value;
4345
  return value;
4344
}
4346
}
4345
4347
Lines 9604-9609 record_types_used_by_current_var_decl (tree decl) Link Here
9604
    }
9606
    }
9605
}
9607
}
9606
9608
9609
/* If DECL is a typedef that is declared in the current function,
9610
   record it in CFUN->LOCAL_TYPEDEFS, for the purpose of
9611
   -Wunused-local-typedefs.  */
9612
9613
void
9614
record_locally_defined_typedef (tree decl)
9615
{
9616
  if (!warn_unused_local_typedefs
9617
      /* if this is not a locally defined typedef then we are not
9618
	 interested.  */
9619
      || !is_typedef_decl (decl)
9620
      || !DECL_CONTEXT (decl)
9621
      || DECL_CONTEXT (decl) != current_function_decl)
9622
    return;
9623
9624
  VEC_safe_push (tree, gc, cfun->local_typedefs, decl);
9625
}
9626
9627
/* If T is a typedef variant type or a TYPE_DECL declared locally,
9628
   record it in CFUN->USED_LOCAL_TYPEDEFS.  Note that this function
9629
   does not record the typedefs presents in the subtypes of T.  */
9630
9631
void
9632
maybe_record_local_typedef_use_real (tree t)
9633
{
9634
  tree typedef_decl = NULL_TREE;
9635
9636
  /* We want T to be either a type or a TYPE_DECL.   */
9637
  if (t == NULL_TREE
9638
      || (!TYPE_P (t) && TREE_CODE (t) != TYPE_DECL))
9639
    return;
9640
9641
  if (TYPE_P (t))
9642
    {
9643
      if (typedef_variant_p (t))
9644
	typedef_decl = TYPE_NAME (t);
9645
    }
9646
  else
9647
    {
9648
      if (is_typedef_decl (t))
9649
	typedef_decl = t;
9650
    }
9651
9652
  if (typedef_decl != NULL_TREE)
9653
    {
9654
      /* We are only interested in a typedef declared locally.  */
9655
      if (DECL_CONTEXT (typedef_decl) != current_function_decl)
9656
	return;
9657
9658
      /* If this typedef is local, really record its use now.  */
9659
      if (cfun->used_local_typedefs == NULL)
9660
	cfun->used_local_typedefs = pointer_set_create ();
9661
      pointer_set_insert (cfun->used_local_typedefs, typedef_decl);
9662
    }
9663
}
9664
9665
/* Warn if there are some unused locally defined typedefs in the
9666
   current function. */
9667
9668
void
9669
maybe_warn_unused_local_typedefs (void)
9670
{
9671
  int i;
9672
  tree decl;
9673
  static int unused_local_typedefs_warn_count;
9674
9675
  if (cfun->used_local_typedefs != NULL)
9676
    gcc_assert (cfun->local_typedefs != NULL);
9677
9678
  if (warn_unused_local_typedefs
9679
      && errorcount == unused_local_typedefs_warn_count)
9680
    {
9681
      FOR_EACH_VEC_ELT (tree, cfun->local_typedefs, i, decl)
9682
	if (cfun->used_local_typedefs == NULL
9683
	    || !pointer_set_contains (cfun->used_local_typedefs, decl))
9684
	  warning_at (DECL_SOURCE_LOCATION (decl),
9685
		      OPT_Wunused_local_typedefs,
9686
		      "typedef %qD locally defined but not used", decl);
9687
      unused_local_typedefs_warn_count = errorcount;
9688
    }
9689
9690
  if (cfun->used_local_typedefs)
9691
    {
9692
      pointer_set_destroy (cfun->used_local_typedefs);
9693
      cfun->used_local_typedefs = NULL;
9694
    }
9695
  if (cfun->local_typedefs)
9696
    {
9697
      VEC_free (tree, gc, cfun->local_typedefs);
9698
      cfun->local_typedefs = NULL;
9699
    }
9700
}
9701
9607
/* The C and C++ parsers both use vectors to hold function arguments.
9702
/* The C and C++ parsers both use vectors to hold function arguments.
9608
   For efficiency, we keep a cache of unused vectors.  This is the
9703
   For efficiency, we keep a cache of unused vectors.  This is the
9609
   cache.  */
9704
   cache.  */
(-)a/gcc/c-family/c-common.h (+4 lines)
Lines 705-710 extern tree (*make_fname_decl) (location_t, tree, int); Link Here
705
705
706
/* In c-decl.c and cp/tree.c.  FIXME.  */
706
/* In c-decl.c and cp/tree.c.  FIXME.  */
707
extern void c_register_addr_space (const char *str, addr_space_t as);
707
extern void c_register_addr_space (const char *str, addr_space_t as);
708
extern void maybe_record_local_typedef_use (tree);
708
709
709
/* In c-common.c.  */
710
/* In c-common.c.  */
710
extern bool in_late_binary_op;
711
extern bool in_late_binary_op;
Lines 986-991 extern void warn_for_sign_compare (location_t, Link Here
986
extern void do_warn_double_promotion (tree, tree, tree, const char *, 
987
extern void do_warn_double_promotion (tree, tree, tree, const char *, 
987
				      location_t);
988
				      location_t);
988
extern void set_underlying_type (tree);
989
extern void set_underlying_type (tree);
990
extern void record_locally_defined_typedef (tree);
991
extern void maybe_record_local_typedef_use_real (tree);
992
extern void maybe_warn_unused_local_typedefs (void);
989
extern VEC(tree,gc) *make_tree_vector (void);
993
extern VEC(tree,gc) *make_tree_vector (void);
990
extern void release_tree_vector (VEC(tree,gc) *);
994
extern void release_tree_vector (VEC(tree,gc) *);
991
extern VEC(tree,gc) *make_tree_vector_single (tree);
995
extern VEC(tree,gc) *make_tree_vector_single (tree);
(-)a/gcc/c-family/c.opt (+4 lines)
Lines 653-658 Wunsuffixed-float-constants Link Here
653
C ObjC Var(warn_unsuffixed_float_constants) Warning
653
C ObjC Var(warn_unsuffixed_float_constants) Warning
654
Warn about unsuffixed float constants
654
Warn about unsuffixed float constants
655
655
656
Wunused-local-typedefs
657
C ObjC C++ ObjC++ Var(warn_unused_local_typedefs) Warning
658
Warn about
659
656
Wunused-macros
660
Wunused-macros
657
C ObjC C++ ObjC++ Warning
661
C ObjC C++ ObjC++ Warning
658
Warn about macros defined in the main file that are not used
662
Warn about macros defined in the main file that are not used
(-)a/gcc/c-typeck.c (+5 lines)
Lines 2633-2638 c_expr_sizeof_type (location_t loc, struct c_type_name *t) Link Here
2633
  ret.value = c_sizeof (loc, type);
2633
  ret.value = c_sizeof (loc, type);
2634
  ret.original_code = ERROR_MARK;
2634
  ret.original_code = ERROR_MARK;
2635
  ret.original_type = NULL;
2635
  ret.original_type = NULL;
2636
2637
  maybe_record_local_typedef_use (type);
2638
2636
  if ((type_expr || TREE_CODE (ret.value) == INTEGER_CST)
2639
  if ((type_expr || TREE_CODE (ret.value) == INTEGER_CST)
2637
      && c_vla_type_p (type))
2640
      && c_vla_type_p (type))
2638
    {
2641
    {
Lines 4737-4742 c_cast_expr (location_t loc, struct c_type_name *type_name, tree expr) Link Here
4737
  type = groktypename (type_name, &type_expr, &type_expr_const);
4740
  type = groktypename (type_name, &type_expr, &type_expr_const);
4738
  warn_strict_prototypes = saved_wsp;
4741
  warn_strict_prototypes = saved_wsp;
4739
4742
4743
  maybe_record_local_typedef_use (type);
4744
4740
  ret = build_c_cast (loc, type, expr);
4745
  ret = build_c_cast (loc, type, expr);
4741
  if (type_expr)
4746
  if (type_expr)
4742
    {
4747
    {
(-)a/gcc/cp/cp-tree.h (+1 lines)
Lines 5001-5006 extern void note_vague_linkage_fn (tree); Link Here
5001
extern tree build_artificial_parm		(tree, tree);
5001
extern tree build_artificial_parm		(tree, tree);
5002
extern bool possibly_inlined_p			(tree);
5002
extern bool possibly_inlined_p			(tree);
5003
extern int parm_index                           (tree);
5003
extern int parm_index                           (tree);
5004
void maybe_record_local_typedef_use             (tree);
5004
5005
5005
/* in error.c */
5006
/* in error.c */
5006
extern void init_error				(void);
5007
extern void init_error				(void);
(-)a/gcc/cp/decl.c (+6 lines)
Lines 10318-10323 grokdeclarator (const cp_declarator *declarator, Link Here
10318
    if (!processing_template_decl)
10318
    if (!processing_template_decl)
10319
      cp_apply_type_quals_to_decl (type_quals, decl);
10319
      cp_apply_type_quals_to_decl (type_quals, decl);
10320
10320
10321
    maybe_record_local_typedef_use (TREE_TYPE (decl));
10322
10321
    return decl;
10323
    return decl;
10322
  }
10324
  }
10323
}
10325
}
Lines 13378-13383 finish_function (int flags) Link Here
13378
      unused_but_set_errorcount = errorcount;
13380
      unused_but_set_errorcount = errorcount;
13379
    }
13381
    }
13380
13382
13383
  /* Complain about locally defined typedefs that are not used in this
13384
     function.  */
13385
  maybe_warn_unused_local_typedefs ();
13386
13381
  /* Genericize before inlining.  */
13387
  /* Genericize before inlining.  */
13382
  if (!processing_template_decl)
13388
  if (!processing_template_decl)
13383
    {
13389
    {
(-)a/gcc/cp/decl2.c (+46 lines)
Lines 4175-4180 mark_used (tree decl) Link Here
4175
4175
4176
  /* Set TREE_USED for the benefit of -Wunused.  */
4176
  /* Set TREE_USED for the benefit of -Wunused.  */
4177
  TREE_USED (decl) = 1;
4177
  TREE_USED (decl) = 1;
4178
4179
  maybe_record_local_typedef_use (TREE_TYPE (decl));
4180
4178
  if (DECL_CLONED_FUNCTION_P (decl))
4181
  if (DECL_CLONED_FUNCTION_P (decl))
4179
    TREE_USED (DECL_CLONED_FUNCTION (decl)) = 1;
4182
    TREE_USED (DECL_CLONED_FUNCTION (decl)) = 1;
4180
4183
Lines 4335-4338 mark_used (tree decl) Link Here
4335
    }
4338
    }
4336
}
4339
}
4337
4340
4341
/* Subroutine of cp_maybe_record_local_typedef_use, called from
4342
   cp_walk_tree_without_duplicate.   */
4343
4344
static tree
4345
cp_maybe_record_local_typedef_use_r (tree *tp,
4346
				     int *walk_subtrees ATTRIBUTE_UNUSED,
4347
				     void *data ATTRIBUTE_UNUSED)
4348
{
4349
  maybe_record_local_typedef_use_real (*tp);
4350
  return NULL_TREE;
4351
}
4352
4353
/* A subroutine of maybe_record_local_typedef_use.  */
4354
4355
static void
4356
cp_maybe_record_local_typedef_use (tree t)
4357
{
4358
  if (!warn_unused_local_typedefs)
4359
    return;
4360
4361
  /*  If the current function is being instantiated, bail out.  */
4362
  if (current_instantiation () != NULL
4363
      && (current_instantiation ()->decl == current_function_decl))
4364
    return;
4365
4366
  maybe_record_local_typedef_use_real (t);
4367
4368
  /* Record the typedefs used by subtypes of TYPE.  */
4369
  cp_walk_tree_without_duplicates (&t,
4370
				   cp_maybe_record_local_typedef_use_r,
4371
				   NULL_TREE);
4372
}
4373
4374
/* If T is a typedef variant type or a TYPE_DECL declared locally,
4375
   record it in CFUN->USED_LOCAL_TYPEDEFS.  This function also records
4376
   the typedefs that are direct or indirect subtypes of T.  */
4377
4378
void
4379
maybe_record_local_typedef_use (tree t)
4380
{
4381
  cp_maybe_record_local_typedef_use (t);
4382
}
4383
4338
#include "gt-cp-decl2.h"
4384
#include "gt-cp-decl2.h"
(-)a/gcc/cp/init.c (+2 lines)
Lines 2612-2617 build_new (VEC(tree,gc) **placement, tree type, tree nelts, Link Here
2612
  if (type == error_mark_node)
2612
  if (type == error_mark_node)
2613
    return error_mark_node;
2613
    return error_mark_node;
2614
2614
2615
  maybe_record_local_typedef_use (type);
2616
2615
  if (nelts == NULL_TREE && VEC_length (tree, *init) == 1)
2617
  if (nelts == NULL_TREE && VEC_length (tree, *init) == 1)
2616
    {
2618
    {
2617
      tree auto_node = type_uses_auto (type);
2619
      tree auto_node = type_uses_auto (type);
(-)a/gcc/cp/name-lookup.c (+7 lines)
Lines 868-873 pushdecl_maybe_friend_1 (tree x, bool is_friend) Link Here
868
	      && TYPE_NAME (type)
868
	      && TYPE_NAME (type)
869
	      && TYPE_IDENTIFIER (type))
869
	      && TYPE_IDENTIFIER (type))
870
	    set_identifier_type_value (DECL_NAME (x), x);
870
	    set_identifier_type_value (DECL_NAME (x), x);
871
872
	  /* If this is a locally defined typedef in a function that
873
	     is not a template instantation, record it to implement
874
	     -Wunused-local-typedefs.  */
875
	  if (current_instantiation () == NULL
876
	      || (current_instantiation ()->decl != current_function_decl))
877
	  record_locally_defined_typedef (x);
871
	}
878
	}
872
879
873
      /* Multiple external decls of the same identifier ought to match.
880
      /* Multiple external decls of the same identifier ought to match.
(-)a/gcc/cp/parser.c (+7 lines)
Lines 4707-4712 cp_parser_qualifying_entity (cp_parser *parser, Link Here
4707
      scope = cp_parser_namespace_name (parser);
4707
      scope = cp_parser_namespace_name (parser);
4708
    }
4708
    }
4709
4709
4710
  maybe_record_local_typedef_use (scope);
4710
  return scope;
4711
  return scope;
4711
}
4712
}
4712
4713
Lines 11705-11710 cp_parser_template_id (cp_parser *parser, Link Here
11705
      template_id = lookup_template_function (templ, arguments);
11706
      template_id = lookup_template_function (templ, arguments);
11706
    }
11707
    }
11707
11708
11709
  /* Mark the possible use of a typedefs in the arguments, for the
11710
     purpose of -Wunused-local-typedefs.  */
11711
  if (arguments != NULL_TREE)
11712
    for (i = 0; i < TREE_VEC_LENGTH (arguments); ++i)
11713
      maybe_record_local_typedef_use (TREE_VEC_ELT (arguments, i));
11714
11708
  /* If parsing tentatively, replace the sequence of tokens that makes
11715
  /* If parsing tentatively, replace the sequence of tokens that makes
11709
     up the template-id with a CPP_TEMPLATE_ID token.  That way,
11716
     up the template-id with a CPP_TEMPLATE_ID token.  That way,
11710
     should we re-parse the token stream, we will not have to repeat
11717
     should we re-parse the token stream, we will not have to repeat
(-)a/gcc/cp/rtti.c (+2 lines)
Lines 523-528 build_dynamic_cast_1 (tree type, tree expr, tsubst_flags_t complain) Link Here
523
  /* Save casted types in the function's used types hash table.  */
523
  /* Save casted types in the function's used types hash table.  */
524
  used_types_insert (type);
524
  used_types_insert (type);
525
525
526
  maybe_record_local_typedef_use (type);
527
526
  /* T shall be a pointer or reference to a complete class type, or
528
  /* T shall be a pointer or reference to a complete class type, or
527
     `pointer to cv void''.  */
529
     `pointer to cv void''.  */
528
  switch (tc)
530
  switch (tc)
(-)a/gcc/cp/typeck.c (+7 lines)
Lines 1534-1539 cxx_sizeof_or_alignof_type (tree type, enum tree_code op, bool complain) Link Here
1534
    {
1534
    {
1535
      value = build_min (op, size_type_node, type);
1535
      value = build_min (op, size_type_node, type);
1536
      TREE_READONLY (value) = 1;
1536
      TREE_READONLY (value) = 1;
1537
      maybe_record_local_typedef_use (type);
1537
      return value;
1538
      return value;
1538
    }
1539
    }
1539
1540
Lines 5714-5719 build_static_cast_1 (tree type, tree expr, bool c_cast_p, Link Here
5714
  /* Save casted types in the function's used types hash table.  */
5715
  /* Save casted types in the function's used types hash table.  */
5715
  used_types_insert (type);
5716
  used_types_insert (type);
5716
5717
5718
  maybe_record_local_typedef_use (type);
5719
5717
  /* [expr.static.cast]
5720
  /* [expr.static.cast]
5718
5721
5719
     An lvalue of type "cv1 B", where B is a class type, can be cast
5722
     An lvalue of type "cv1 B", where B is a class type, can be cast
Lines 6017-6022 build_reinterpret_cast_1 (tree type, tree expr, bool c_cast_p, Link Here
6017
  /* Save casted types in the function's used types hash table.  */
6020
  /* Save casted types in the function's used types hash table.  */
6018
  used_types_insert (type);
6021
  used_types_insert (type);
6019
6022
6023
  maybe_record_local_typedef_use (type);
6024
6020
  /* [expr.reinterpret.cast]
6025
  /* [expr.reinterpret.cast]
6021
     An lvalue expression of type T1 can be cast to the type
6026
     An lvalue expression of type T1 can be cast to the type
6022
     "reference to T2" if an expression of type "pointer to T1" can be
6027
     "reference to T2" if an expression of type "pointer to T1" can be
Lines 6237-6242 build_const_cast_1 (tree dst_type, tree expr, tsubst_flags_t complain, Link Here
6237
  /* Save casted types in the function's used types hash table.  */
6242
  /* Save casted types in the function's used types hash table.  */
6238
  used_types_insert (dst_type);
6243
  used_types_insert (dst_type);
6239
6244
6245
  maybe_record_local_typedef_use (dst_type);
6246
6240
  src_type = TREE_TYPE (expr);
6247
  src_type = TREE_TYPE (expr);
6241
  /* Expressions do not really have reference types.  */
6248
  /* Expressions do not really have reference types.  */
6242
  if (TREE_CODE (src_type) == REFERENCE_TYPE)
6249
  if (TREE_CODE (src_type) == REFERENCE_TYPE)
(-)a/gcc/cp/typeck2.c (+2 lines)
Lines 1607-1612 build_functional_cast (tree exp, tree parms, tsubst_flags_t complain) Link Here
1607
      type = error_mark_node;
1607
      type = error_mark_node;
1608
    }
1608
    }
1609
1609
1610
  maybe_record_local_typedef_use (type);
1611
1610
  if (processing_template_decl)
1612
  if (processing_template_decl)
1611
    {
1613
    {
1612
      tree t;
1614
      tree t;
(-)a/gcc/doc/invoke.texi (-2 / +7 lines)
Lines 267-274 Objective-C and Objective-C++ Dialects}. Link Here
267
-Wsystem-headers  -Wtrampolines  -Wtrigraphs  -Wtype-limits  -Wundef @gol
267
-Wsystem-headers  -Wtrampolines  -Wtrigraphs  -Wtype-limits  -Wundef @gol
268
-Wuninitialized  -Wunknown-pragmas  -Wno-pragmas @gol
268
-Wuninitialized  -Wunknown-pragmas  -Wno-pragmas @gol
269
-Wunsuffixed-float-constants  -Wunused  -Wunused-function @gol
269
-Wunsuffixed-float-constants  -Wunused  -Wunused-function @gol
270
-Wunused-label  -Wunused-parameter -Wno-unused-result -Wunused-value @gol
270
-Wunused-label  -Wunused-local-typedefs -Wunused-parameter @gol
271
-Wunused-variable -Wunused-but-set-parameter -Wunused-but-set-variable @gol
271
-Wno-unused-result -Wunused-value @gol -Wunused-variable @gol
272
-Wunused-but-set-parameter -Wunused-but-set-variable @gol
272
-Wvariadic-macros -Wvla -Wvolatile-register-var  -Wwrite-strings}
273
-Wvariadic-macros -Wvla -Wvolatile-register-var  -Wwrite-strings}
273
274
274
@item C and Objective-C-only Warning Options
275
@item C and Objective-C-only Warning Options
Lines 3499-3504 This warning is enabled by @option{-Wall}. Link Here
3499
To suppress this warning use the @samp{unused} attribute
3500
To suppress this warning use the @samp{unused} attribute
3500
(@pxref{Variable Attributes}).
3501
(@pxref{Variable Attributes}).
3501
3502
3503
@item -Wunused-local-typedefs @r{(C, Objective-C, C++ and Objective-C++ only)}
3504
@opindex Wunused-local-typedefs
3505
Warn when a typedef locally defined in a function is not used.
3506
3502
@item -Wunused-parameter
3507
@item -Wunused-parameter
3503
@opindex Wunused-parameter
3508
@opindex Wunused-parameter
3504
@opindex Wno-unused-parameter
3509
@opindex Wno-unused-parameter
(-)a/gcc/function.h (+8 lines)
Lines 27-32 along with GCC; see the file COPYING3. If not see Link Here
27
#include "vecprim.h"
27
#include "vecprim.h"
28
#include "tm.h"		/* For CUMULATIVE_ARGS.  */
28
#include "tm.h"		/* For CUMULATIVE_ARGS.  */
29
#include "hard-reg-set.h"
29
#include "hard-reg-set.h"
30
#include "pointer-set.h"
30
31
31
/* Stack of pending (incomplete) sequences saved by `start_sequence'.
32
/* Stack of pending (incomplete) sequences saved by `start_sequence'.
32
   Each element describes one pending sequence.
33
   Each element describes one pending sequence.
Lines 532-537 struct GTY(()) function { Link Here
532
  /* Vector of function local variables, functions, types and constants.  */
533
  /* Vector of function local variables, functions, types and constants.  */
533
  VEC(tree,gc) *local_decls;
534
  VEC(tree,gc) *local_decls;
534
535
536
  /* Vector of locally defined typedefs, for
537
     -Wunused-local-typedefs.  */
538
  VEC(tree,gc) *local_typedefs;
539
540
  /*  Set of typedefs that are used in this function.  */
541
  struct pointer_set_t * GTY((skip)) used_local_typedefs;
542
535
  /* For md files.  */
543
  /* For md files.  */
536
544
537
  /* tm.h can use this to store whatever it likes.  */
545
  /* tm.h can use this to store whatever it likes.  */
(-)a/gcc/testsuite/c-c++-common/Wunused-local-typedefs.c (+38 lines)
Line 0 Link Here
1
/*  Origin PR c++/33255
2
    { dg-options "-Wunused-local-typedefs" }
3
    { dg-do compile }
4
*/
5
6
void
7
test_warn ()
8
{
9
  typedef int foo; // { dg-warning "locally defined but not used" }
10
}
11
12
void
13
test0 ()
14
{
15
    typedef int foo;
16
    foo var __attribute__((unused));
17
}
18
19
void
20
test1 ()
21
{
22
    typedef int foo;
23
    const foo *var = 0;
24
}
25
26
void
27
test2 ()
28
{
29
  typedef int foo;
30
  void func(foo);  
31
}
32
33
void
34
test7 (void)
35
{
36
  typedef int foo;
37
  int vec[1] = {sizeof (foo)};
38
}
(-)a/gcc/tree.c (+5 lines)
Lines 10323-10328 walk_type_fields (tree type, walk_tree_fn func, void *data, Link Here
10323
{
10323
{
10324
  tree result = NULL_TREE;
10324
  tree result = NULL_TREE;
10325
10325
10326
  /* If this type is a typedef variant, walk the fields of its
10327
     underlying type.  */
10328
  if (typedef_variant_p (type))
10329
    WALK_SUBTREE (DECL_ORIGINAL_TYPE (TYPE_NAME (type)));
10330
10326
  switch (TREE_CODE (type))
10331
  switch (TREE_CODE (type))
10327
    {
10332
    {
10328
    case POINTER_TYPE:
10333
    case POINTER_TYPE:
(-)a/libstdc++-v3/include/ext/bitmap_allocator.h (-2 lines)
Lines 238-245 namespace __gnu_cxx _GLIBCXX_VISIBILITY(default) Link Here
238
      __lower_bound(_ForwardIterator __first, _ForwardIterator __last,
238
      __lower_bound(_ForwardIterator __first, _ForwardIterator __last,
239
		    const _Tp& __val, _Compare __comp)
239
		    const _Tp& __val, _Compare __comp)
240
      {
240
      {
241
	typedef typename __mv_iter_traits<_ForwardIterator>::value_type
242
	  _ValueType;
243
	typedef typename __mv_iter_traits<_ForwardIterator>::difference_type
241
	typedef typename __mv_iter_traits<_ForwardIterator>::difference_type
244
	  _DistanceType;
242
	  _DistanceType;
245
243
(-)a/libstdc++-v3/src/istream.cc (-3 lines)
Lines 280-286 _GLIBCXX_BEGIN_NAMESPACE_VERSION Link Here
280
    {
280
    {
281
      typedef basic_istream<char>       	__istream_type;
281
      typedef basic_istream<char>       	__istream_type;
282
      typedef __istream_type::int_type		__int_type;
282
      typedef __istream_type::int_type		__int_type;
283
      typedef __istream_type::char_type		__char_type;
284
      typedef __istream_type::traits_type	__traits_type;
283
      typedef __istream_type::traits_type	__traits_type;
285
      typedef __istream_type::__streambuf_type  __streambuf_type;
284
      typedef __istream_type::__streambuf_type  __streambuf_type;
286
      typedef __istream_type::__ctype_type	__ctype_type;
285
      typedef __istream_type::__ctype_type	__ctype_type;
Lines 364-370 _GLIBCXX_BEGIN_NAMESPACE_VERSION Link Here
364
      typedef __istream_type::char_type		__char_type;
363
      typedef __istream_type::char_type		__char_type;
365
      typedef __istream_type::traits_type	__traits_type;
364
      typedef __istream_type::traits_type	__traits_type;
366
      typedef __istream_type::__streambuf_type  __streambuf_type;
365
      typedef __istream_type::__streambuf_type  __streambuf_type;
367
      typedef __istream_type::__ctype_type	__ctype_type;
368
      typedef basic_string<char>        	__string_type;
366
      typedef basic_string<char>        	__string_type;
369
      typedef __string_type::size_type		__size_type;
367
      typedef __string_type::size_type		__size_type;
370
368
Lines 610-616 _GLIBCXX_BEGIN_NAMESPACE_VERSION Link Here
610
      typedef __istream_type::char_type		__char_type;
608
      typedef __istream_type::char_type		__char_type;
611
      typedef __istream_type::traits_type	__traits_type;
609
      typedef __istream_type::traits_type	__traits_type;
612
      typedef __istream_type::__streambuf_type  __streambuf_type;
610
      typedef __istream_type::__streambuf_type  __streambuf_type;
613
      typedef __istream_type::__ctype_type	__ctype_type;
614
      typedef basic_string<wchar_t>        	__string_type;
611
      typedef basic_string<wchar_t>        	__string_type;
615
      typedef __string_type::size_type		__size_type;
612
      typedef __string_type::size_type		__size_type;
616
613
(-)a/libstdc++-v3/src/valarray.cc (-2 lines)
Lines 49-55 _GLIBCXX_BEGIN_NAMESPACE_VERSION Link Here
49
  inline size_t
49
  inline size_t
50
  __valarray_product(const valarray<size_t>& __a)
50
  __valarray_product(const valarray<size_t>& __a)
51
  {
51
  {
52
    typedef const size_t* __restrict__ _Tp;
53
    const size_t __n = __a.size();
52
    const size_t __n = __a.size();
54
    // XXX: This ugly cast is necessary because
53
    // XXX: This ugly cast is necessary because
55
    //      valarray::operator[]() const return a VALUE!
54
    //      valarray::operator[]() const return a VALUE!
56
- 

Return to bug 33255