[PATCH] Adding warning for constexpr's

Andres Tiraboschi andres.tiraboschi@tallertechnologies.com
Mon Jun 15 15:12:00 GMT 2015


Hi, thanks for your answer. I was trying with warning_at this way
instead that I was doing before:

+  else if (TREE_CODE(init) == CALL_EXPR)
+    {
+      tree fn = TREE_OPERAND(CALL_EXPR_FN(init), 0);
+      if (DECL_DECLARED_CONSTEXPR_P(fn) && warn_constexpr)
+          warning_at (DECL_SOURCE_LINE(decl), OPT_Wconstexpr,
"function %q+F cannot be evaluated at compile time", fn);
+

where "decl" is the declaration that is being initializated. For some
reason this isn't working. Checking with gdb I realised that
warning_at in this case is returnin false. I don't know if I am
missing something.

2015-06-12 18:35 GMT-03:00 Joseph Myers <joseph@codesourcery.com>:
> On Fri, 12 Jun 2015, Andres Tiraboschi wrote:
>
>> Hi, this patch is for adding a warning when a constexpr cannot be evaluated at compile time.
>> This is a single case:
>> type var = fun(args...), with fun declared as a constexpr.
>
> All options need documenting in invoke.texi.  All diagnostics need
> testcases added to the testsuite.  C++-specific options go in c.opt and
> should be listed as C++ ObjC++, not Common.  All new diagnostics should
> use warning_at etc. with explicit locations passed, unless there is some
> strong reason it's hard to get the relevant location when the warning is
> given.
>
> --
> Joseph S. Myers
> joseph@codesourcery.com



More information about the Gcc-patches mailing list