View | Details | Raw Unified | Return to bug 36587
Collapse All | Expand All

(-)gcc-4.1.1.orig/gcc/c-opts.c (-1 / +3 lines)
Lines 382-389 Link Here
382
      warn_parentheses = value;
382
      warn_parentheses = value;
383
      warn_return_type = value;
383
      warn_return_type = value;
384
      warn_sequence_point = value;	/* Was C only.  */
384
      warn_sequence_point = value;	/* Was C only.  */
385
      if (c_dialect_cxx ())
385
      if (c_dialect_cxx ()) {
386
	warn_sign_compare = value;
386
	warn_sign_compare = value;
387
	warn_unused_objects = value;
388
      }
387
      warn_switch = value;
389
      warn_switch = value;
388
      warn_strict_aliasing = value;
390
      warn_strict_aliasing = value;
389
391
(-)gcc-4.1.1.orig/gcc/cp/cp-gimplify.c (+29 lines)
Lines 355-360 Link Here
355
     In this case we will not want to emit the gimplified statement.
355
     In this case we will not want to emit the gimplified statement.
356
     However, we may still want to emit a warning, so we do that before
356
     However, we may still want to emit a warning, so we do that before
357
     gimplification.  */
357
     gimplification.  */
358
 
359
  if (stmt && warn_unused_objects)
360
    {
361
      if (TREE_CODE (stmt) == CONVERT_EXPR &&
362
	  VOID_TYPE_P (TREE_TYPE (stmt)))
363
	{
364
	  tree expr = TREE_OPERAND (stmt, 0);
365
	  if (TREE_CODE (expr) == TARGET_EXPR &&
366
	      CLASS_TYPE_P (TREE_TYPE (expr)))
367
	    {
368
	      tree maybe_aggr_init_expr = TREE_OPERAND(expr, 1);
369
370
	      if (TREE_CODE (maybe_aggr_init_expr) == AGGR_INIT_EXPR)
371
		{
372
		  tree maybe_addr_expr = TREE_OPERAND (maybe_aggr_init_expr, 0);
373
		  if (TREE_CODE (maybe_addr_expr) == ADDR_EXPR)
374
		    {
375
		      tree maybe_function_decl = TREE_OPERAND (maybe_addr_expr, 0);
376
		      if (TREE_CODE (maybe_function_decl) == FUNCTION_DECL &&
377
			  DECL_CONSTRUCTOR_P (maybe_function_decl))
378
			{
379
			  warning (0, "constructed object is discarded");
380
			}
381
		    }
382
		}
383
	    }
384
	}
385
    }
386
358
  if (stmt && (extra_warnings || warn_unused_value))
387
  if (stmt && (extra_warnings || warn_unused_value))
359
    {
388
    {
360
      if (!TREE_SIDE_EFFECTS (stmt))
389
      if (!TREE_SIDE_EFFECTS (stmt))
(-)gcc-4.1.1.orig/gcc/c.opt (+4 lines)
Lines 411-416 Link Here
411
C ObjC C++ ObjC++
411
C ObjC C++ ObjC++
412
Warn about macros defined in the main file that are not used
412
Warn about macros defined in the main file that are not used
413
413
414
Wunused-objects
415
C++ ObjC++ Var(warn_unused_objects)
416
Warn when a constructor is called explicitly and the returned object is ignored
417
414
Wvariadic-macros
418
Wvariadic-macros
415
C ObjC C++ ObjC++
419
C ObjC C++ ObjC++
416
Do not warn about using variadic macros when -pedantic
420
Do not warn about using variadic macros when -pedantic

Return to bug 36587