[Bug c/88000] Warn when different local vars regs order may produce different and so unsupported code [-Wasm-register-var]

2019-06-16 Thread dominik.b.czarnota+bugzilla at gmail dot com
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=88000

--- Comment #6 from Dominik Czarnota  ---
(In reply to Eric Gallager from comment #5)
> Reopening to confirm the part about this warning request at least

Yay, thanks. I am happy someone cares about this. It is good to make it less
likely that the users shoot themselves in the foot.

[Bug c/88000] Warn when different local vars regs order may produce different and so unsupported code [-Wasm-register-var]

2019-06-14 Thread egallager at gcc dot gnu.org
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=88000

Eric Gallager  changed:

   What|Removed |Added

 Status|RESOLVED|REOPENED
   Keywords||diagnostic
   Last reconfirmed||2019-06-15
 CC||egallager at gcc dot gnu.org
 Resolution|INVALID |---
 Blocks||87403
 Ever confirmed|0   |1
Summary|Different local vars regs   |Warn when different local
   |order may produce different |vars regs order may produce
   |and so wrong code   |different and so
   ||unsupported code
   ||[-Wasm-register-var]

--- Comment #5 from Eric Gallager  ---
(In reply to Martin Sebor from comment #4)
> GCC could help by issuing a warning for unsupported uses, like in the
> prototype patch below:
> 
> Index: gcc/c/c-typeck.c
> ===
> --- gcc/c/c-typeck.c  (revision 266033)
> +++ gcc/c/c-typeck.c  (working copy)
> @@ -6505,6 +6505,14 @@ convert_for_assignment (location_t location, locat
>objc_ok = objc_compare_types (type, rhstype, parmno, rname);
>  }
>  
> +  if (VAR_P (rhs) && DECL_HARD_REGISTER (rhs)
> +  && warning_at (expr_loc, OPT_Wasm_register_var,
> +  "unsupported use of a hard register %qD as "
> +  "argument %d of %qE",
> +  rhs, parmnum, rname))
> +inform (DECL_SOURCE_LOCATION (rhs),
> + "%qD declared here", rhs);
> +
>if (warn_cxx_compat)
>  {
>tree checktype = origtype != NULL_TREE ? origtype : rhstype;
> Index: gcc/c-family/c.opt
> ===
> --- gcc/c-family/c.opt(revision 266033)
> +++ gcc/c-family/c.opt(working copy)
> @@ -338,6 +338,10 @@ Warray-bounds=
>  LangEnabledBy(C ObjC C++ LTO ObjC++,Wall,1,0)
>  ; in common.opt
>  
> +Wasm-register-var
> +ObjC ObjC++ Var(warn_asm_register_var) Warning LangEnabledBy(C ObjC C++
> ObjC++, Wall)
> +Warn for unsupported uses of variables declared asm register.
> +
>  Wassign-intercept
>  ObjC ObjC++ Var(warn_assign_intercept) Warning
>  Warn whenever an Objective-C assignment is being intercepted by the garbage
> collector.

Reopening to confirm the part about this warning request at least


Referenced Bugs:

https://gcc.gnu.org/bugzilla/show_bug.cgi?id=87403
[Bug 87403] [Meta-bug] Issues that suggest a new warning