On Thu, Nov 15, 2018 at 02:39:14PM +0100, Paolo Carlini wrote:
> Hi,
> 
> this one should be straightforward. Tested x86_64-linux.
> 
> Thanks, Paolo.
> 
> /////////////////////////
> 

> /cp
> 2018-11-15  Paolo Carlini  <paolo.carl...@oracle.com>
> 
>       * constexpr.c (ensure_literal_type_for_constexpr_object): Use
>       DECL_SOURCE_LOCATION in error_at calls.
> 
> /testsuite
> 2018-11-15  Paolo Carlini  <paolo.carl...@oracle.com>
> 
>       * g++.dg/cpp0x/constexpr-diag3.C: Check locations too.
>       * g++.dg/cpp0x/constexpr-ice19.C: Likewise.
>       * g++.dg/cpp0x/constexpr-nonlit2.C: Likewise.
>       * g++.dg/cpp1z/constexpr-lambda15.C: Likewise.
>       * g++.dg/ext/constexpr-vla5.C: Likewise.
>       * g++.dg/gomp/pr85134.C: Likewise.

> Index: cp/constexpr.c
> ===================================================================
> --- cp/constexpr.c    (revision 266174)
> +++ cp/constexpr.c    (working copy)
> @@ -98,8 +98,9 @@ ensure_literal_type_for_constexpr_object (tree dec
>         if (DECL_DECLARED_CONSTEXPR_P (decl))
>           {
>             auto_diagnostic_group d;
> -           error ("the type %qT of %<constexpr%> variable %qD "
> -                  "is not literal", type, decl);
> +           error_at (DECL_SOURCE_LOCATION (decl),
> +                     "the type %qT of %<constexpr%> variable %qD "
> +                     "is not literal", type, decl);
>             explain_non_literal_class (type);
>             decl = error_mark_node;
>           }
> @@ -108,8 +109,9 @@ ensure_literal_type_for_constexpr_object (tree dec
>             if (!is_instantiation_of_constexpr (current_function_decl))
>               {
>                 auto_diagnostic_group d;
> -               error ("variable %qD of non-literal type %qT in %<constexpr%> 
> "
> -                      "function", decl, type);
> +               error_at (DECL_SOURCE_LOCATION (decl),
> +                         "variable %qD of non-literal type %qT in "
> +                         "%<constexpr%> function", decl, type);
>                 explain_non_literal_class (type);
>                 decl = error_mark_node;
>               }
> @@ -119,8 +121,9 @@ ensure_literal_type_for_constexpr_object (tree dec
>        else if (DECL_DECLARED_CONSTEXPR_P (decl)
>              && variably_modified_type_p (type, NULL_TREE))
>       {
> -       error ("%<constexpr%> variable %qD has variably-modified type %qT",
> -              decl, type);
> +       error_at (DECL_SOURCE_LOCATION (decl),
> +                 "%<constexpr%> variable %qD has variably-modified "
> +                 "type %qT", decl, type);
>         decl = error_mark_node;

How about using location_of instead of DECL_SOURCE_LOCATION?

Marek

Reply via email to