[Bug c++/43486] Preserve variable-use locations

2010-03-22 Thread pinskia at gcc dot gnu dot org


--- Comment #1 from pinskia at gcc dot gnu dot org  2010-03-22 22:33 ---
Which location do you want?   For function calls, it will be part of the call
expression (or rather the call statement).  For variables, it is harder to keep
track of that usage.  But most statements have a line/column info already.  


-- 

pinskia at gcc dot gnu dot org changed:

   What|Removed |Added

   Severity|normal  |enhancement


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=43486



[Bug c++/43486] Preserve variable-use locations

2010-03-22 Thread tglek at mozilla dot com


--- Comment #2 from tglek at mozilla dot com  2010-03-22 22:42 ---
(In reply to comment #1)
> Which location do you want?   For function calls, it will be part of the call
> expression (or rather the call statement).  For variables, it is harder to 
> keep
> track of that usage.  But most statements have a line/column info already.  
> 

Ideally I would want the beginning and ending of every expression in the AST,
but I'd settle for ability to know the beginning of variables. For example
somenamespace::foo->call(
x,
y);

Right now there is no way to get locations for x, y or "call". CALL_EXPR just
gives one a vague location, given that there can be a large number of other
decls referenced within the CALL_EXPR.


-- 


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=43486



[Bug c++/43486] Preserve variable-use locations

2010-03-22 Thread manu at gcc dot gnu dot org


--- Comment #3 from manu at gcc dot gnu dot org  2010-03-22 23:38 ---
I think we want this also for better diagnostics and in the long term for caret
diagnostics. At a minimum, we should handle the case 

foo(
x, /* warning/error about x but location is that of either foo or the ';' */
y);

I am not sure how difficult is to implement this in the straightforward cases.
More complex cases would be those affected by folding and constant arguments
(which do not have locations).

A first step would be to propagate the correct locations when building
expressions (adding location parameters to build_* functions and passing down
the correct value).


-- 

manu at gcc dot gnu dot org changed:

   What|Removed |Added

 CC||manu at gcc dot gnu dot org
 Status|UNCONFIRMED |NEW
 Ever Confirmed|0   |1
   Keywords||diagnostic
   Last reconfirmed|-00-00 00:00:00 |2010-03-22 23:38:29
   date||


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=43486



[Bug c++/43486] Preserve variable-use locations

2010-03-22 Thread jason at gcc dot gnu dot org


--- Comment #4 from jason at gcc dot gnu dot org  2010-03-23 01:51 ---
I suppose we could wrap rvalue uses in NOP_EXPR and lvalue uses in
VIEW_CONVERT_EXPR.

Taras: You aren't actually trying to do this sort of analysis after lowering to
GIMPLE, are you?


-- 

jason at gcc dot gnu dot org changed:

   What|Removed |Added

 CC||jason at gcc dot gnu dot org


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=43486



[Bug c++/43486] Preserve variable-use locations

2010-03-22 Thread tglek at mozilla dot com


--- Comment #5 from tglek at mozilla dot com  2010-03-23 02:07 ---
(In reply to comment #4)
> I suppose we could wrap rvalue uses in NOP_EXPR and lvalue uses in
> VIEW_CONVERT_EXPR.
> 
> Taras: You aren't actually trying to do this sort of analysis after lowering 
> to
> GIMPLE, are you?

Ideally this would work in gimple too, but just having this in C++ fe would be
enough.


-- 


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=43486



[Bug c++/43486] Preserve variable-use locations

2018-01-10 Thread dmalcolm at gcc dot gnu.org
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=43486

--- Comment #11 from David Malcolm  ---
Author: dmalcolm
Date: Wed Jan 10 19:40:55 2018
New Revision: 256448

URL: https://gcc.gnu.org/viewcvs?rev=256448&root=gcc&view=rev
Log:
Preserving locations for variable-uses and constants (PR c++/43486)

This patch implements location wrapper nodes, preserving source locations
of the uses of variables and constants in various places in the
C++ frontend: at the arguments at callsites, and for typeid, alignof,
sizeof, and offsetof.

For example, it allows the C++ FE to underline the pertinent argument
for mismatching calls, for such expressions, improving:

extern int callee (int one, const char *two, float three);

int caller (int first, int second, float third)
{
  return callee (first, second, third);
}

from

test.cc: In function 'int caller(int, int, float)':
test.cc:5:38: error: invalid conversion from 'int' to 'const char*'
[-fpermissive]
   return callee (first, second, third);
  ^
test.cc:1:41: note:   initializing argument 2 of 'int callee(int, const char*,
float)'
 extern int callee (int one, const char *two, float three);
 ^~~

to:

test.cc: In function 'int caller(int, int, float)':
test.cc:5:25: error: invalid conversion from 'int' to 'const char*'
[-fpermissive]
   return callee (first, second, third);
 ^~
test.cc:1:41: note:   initializing argument 2 of 'int callee(int, const char*,
float)'
 extern int callee (int one, const char *two, float three);
 ^~~

This is the combination of the following patches:

  "[PATCH 01/14] C++: preserve locations within build_address"
 https://gcc.gnu.org/ml/gcc-patches/2017-11/msg00883.html

  "[PATCH v2.4 of 02/14] Support for adding and stripping location_t wrapper
nodes"
https://gcc.gnu.org/ml/gcc-patches/2018-01/msg00591.html

  "[PATCH] Eliminate location wrappers in tree_nop_conversion/STRIP_NOPS"
https://gcc.gnu.org/ml/gcc-patches/2017-12/msg01330.html

  "[PATCH v4 of 03/14] C++: add location_t wrapper nodes during parsing
(minimal impl)"
https://gcc.gnu.org/ml/gcc-patches/2018-01/msg00660.html

  "[PATCH 04/14] Update testsuite to show improvements"
https://gcc.gnu.org/ml/gcc-patches/2017-11/msg00891.html

  "[v3 of 05/14] C++: handle locations wrappers when calling warn_for_memset"
https://gcc.gnu.org/ml/gcc-patches/2017-12/msg01378.html

  "[PATCH 07/14] reject_gcc_builtin: strip any location wrappers"
https://gcc.gnu.org/ml/gcc-patches/2017-11/msg00886.html

  "[v3 of PATCH 08/14] cp/tree.c: strip location wrappers in lvalue_kind"
https://gcc.gnu.org/ml/gcc-patches/2017-12/msg01433.html

  "[PATCH 09/14] Strip location wrappers in null_ptr_cst_p"
https://gcc.gnu.org/ml/gcc-patches/2017-11/msg00888.html

  "[PATCH 11/14] Handle location wrappers in string_conv_p"
https://gcc.gnu.org/ml/gcc-patches/2017-11/msg00890.html

  "[PATCH 12/14] C++: introduce null_node_p"
https://gcc.gnu.org/ml/gcc-patches/2017-11/msg00894.html

  "[v3 of PATCH 13/14] c-format.c: handle location wrappers"
https://gcc.gnu.org/ml/gcc-patches/2017-12/msg01494.html

  "[PATCH 14/14] pp_c_cast_expression: don't print casts for location wrappers"
https://gcc.gnu.org/ml/gcc-patches/2017-11/msg00893.html

  "[v3 of PATCH 15/14] Use fold_for_warn in get_atomic_generic_size"
https://gcc.gnu.org/ml/gcc-patches/2017-12/msg01380.html

  "[PATCH] Add selftest for "fold_for_warn (error_mark_node)""
https://gcc.gnu.org/ml/gcc-patches/2017-12/msg01385.html

gcc/c-family/ChangeLog:
PR c++/43486
* c-common.c: Include "selftest.h".
(get_atomic_generic_size): Perform the test for integral type
before the range test for any integer constant, fixing indentation
of braces.  Call fold_for_warn before testing for an INTEGER_CST.
(reject_gcc_builtin): Strip any location wrapper from EXPR.
(selftest::test_fold_for_warn): New function.
(selftest::c_common_c_tests): New function.
(selftest::c_family_tests): Call it, and
selftest::c_pretty_print_c_tests.
* c-common.h (selftest::c_pretty_print_c_tests): New decl.
* c-format.c (check_format_arg): Convert VAR_P check to a
fold_for_warn.
* c-pretty-print.c: Include "selftest.h".
(pp_c_cast_expression): Don't print casts for location wrappers.
(selftest::assert_c_pretty_printer_output): New function.
(ASSERT_C_PRETTY_PRINTER_OUTPUT): New macro.
(selftest::test_location_wrappers): New function.
(selftest::c_pretty_print_c_tests): New function.
* c-warn.c (warn_for_memset): Call fold_for_warn on the arguments.

gcc/cp/ChangeLog:
PR c++/43486
* call.c (null_ptr_cst_p): Strip location wrappers when
converting from '0' to a pointer type in C++11 onwards.
(conversion_null_warnings): 

[Bug c++/43486] Preserve variable-use locations

2018-01-10 Thread dmalcolm at gcc dot gnu.org
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=43486

--- Comment #12 from David Malcolm  ---
(In reply to David Malcolm from comment #11)
> Author: dmalcolm
> Date: Wed Jan 10 19:40:55 2018
> New Revision: 256448
> 
> URL: https://gcc.gnu.org/viewcvs?rev=256448&root=gcc&view=rev
> Log:
> Preserving locations for variable-uses and constants (PR c++/43486)

This patch is a step towards fixing this bug, but we're not there yet:

The patch adds machinery for adding location wrapper nodes for those
expressions that don't have them, and adds such wrappers to the C++ FE for
callsite arguments and at a few other places. This is a minimal approach, which
improves various diagnostics in the C++ FE, but in theory we should add
wrappers throughout the C++ FE for *all* uses-of-decls and uses-of-constants. 
See:
  https://gcc.gnu.org/ml/gcc-patches/2017-11/msg01588.html
for an earlier work-in-progress attempt at this (probably bit-rotted by now).

Similarly, the patch doesn't add any wrapper nodes to other frontends, in
particular, the C FE.

Finally, I believe, all of these wrappers are discarded at some point at or
before gimplification, so it doesn't help the middle-end yet; we'd need some
way to retain the location information there.

[Bug c++/43486] Preserve variable-use locations

2018-01-11 Thread dmalcolm at gcc dot gnu.org
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=43486

--- Comment #13 from David Malcolm  ---
Author: dmalcolm
Date: Thu Jan 11 19:38:52 2018
New Revision: 256552

URL: https://gcc.gnu.org/viewcvs?rev=256552&root=gcc&view=rev
Log:
Add some reproducers for issues found developing the location-wrappers patch

gcc/testsuite/ChangeLog:
PR c++/43486
* g++.dg/wrappers: New subdirectory.
* g++.dg/wrappers/README: New file.
* g++.dg/wrappers/alloc.C: New test case.
* g++.dg/wrappers/cow-istream-string.C: New test case.
* g++.dg/wrappers/cp-stdlib.C: New test case.
* g++.dg/wrappers/sanitizer_coverage_libcdep_new.C: New test case.
* g++.dg/wrappers/wrapper-around-type-pack-expansion.C: New test
case.


Added:
trunk/gcc/testsuite/g++.dg/wrappers/
trunk/gcc/testsuite/g++.dg/wrappers/README
trunk/gcc/testsuite/g++.dg/wrappers/alloc.C
trunk/gcc/testsuite/g++.dg/wrappers/cow-istream-string.C
trunk/gcc/testsuite/g++.dg/wrappers/cp-stdlib.C
trunk/gcc/testsuite/g++.dg/wrappers/sanitizer_coverage_libcdep_new.C
trunk/gcc/testsuite/g++.dg/wrappers/wrapper-around-type-pack-expansion.C
Modified:
trunk/gcc/testsuite/ChangeLog

[Bug c++/43486] Preserve variable-use locations

2020-11-26 Thread cvs-commit at gcc dot gnu.org via Gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=43486

--- Comment #18 from CVS Commits  ---
The master branch has been updated by Thomas Schwinge :

https://gcc.gnu.org/g:c0c7270cc4efd896fe99f8ad5409dbef089a407f

commit r11-5430-gc0c7270cc4efd896fe99f8ad5409dbef089a407f
Author: Thomas Schwinge 
Date:   Wed Nov 25 20:36:55 2020 +0100

Don't create location wrapper nodes within OpenACC clauses

This fixes a GCC 11, 10, 9 regression introduced by commit
dfd7fdca2ac17d8b823a16700525824ca312ade0 (Subversion r267272) "C++: more
location wrapper nodes (PR c++/43064, PR c++/43486)".  But: this isn't
intending to blame David, because back then, the problem hasn't been
visible in
the testsuite (or else I'm sure would've been addressed right away) because
of
our all dear friend: missing testsuite coverage.  Thus, for GCC 8, I'm
likewise
enhancing the testsuite, without the C++ front end code changes.

I actually had presumed that there may be an issue for OpenACC:
, so
here
we are, two years (and many "wasted" hours...) later...

gcc/cp/
* parser.c (cp_parser_omp_var_list_no_open): Assert that array
section's 'low_bound', 'length' are not location wrapper nodes.
(cp_parser_oacc_all_clauses, cp_parser_oacc_cache): Instantiate
'auto_suppress_location_wrappers'.
gcc/testsuite/
* c-c++-common/goacc/cache-3-1.c: New.
* c-c++-common/goacc/cache-3-2.c: Likewise.
* c-c++-common/goacc/data-clause-1.c: Likewise.
* c-c++-common/goacc/data-clause-2.c: Likewise.
* c-c++-common/gomp/map-1.c: Adjust.
* c-c++-common/gomp/map-2.c: Likewise.
* g++.dg/goacc/cache-3-1.C: New.
* g++.dg/goacc/cache-3-2.C: Likewise.
* g++.dg/goacc/data-clause-1.C: Likewise.
* g++.dg/goacc/data-clause-2.C: Likewise.
* g++.dg/gomp/map-1.C: Adjust.
* g++.dg/gomp/map-2.C: Likewise.

Reported-by: Sandra Loosemore 

[Bug c++/43486] Preserve variable-use locations

2020-11-26 Thread cvs-commit at gcc dot gnu.org via Gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=43486

--- Comment #19 from CVS Commits  ---
The releases/gcc-10 branch has been updated by Thomas Schwinge
:

https://gcc.gnu.org/g:e8e0357d129187b24085ce52172c87dbf6c2ecae

commit r10-9086-ge8e0357d129187b24085ce52172c87dbf6c2ecae
Author: Thomas Schwinge 
Date:   Wed Nov 25 20:36:55 2020 +0100

Don't create location wrapper nodes within OpenACC clauses

This fixes a GCC 11, 10, 9 regression introduced by commit
dfd7fdca2ac17d8b823a16700525824ca312ade0 (Subversion r267272) "C++: more
location wrapper nodes (PR c++/43064, PR c++/43486)".  But: this isn't
intending to blame David, because back then, the problem hasn't been
visible in
the testsuite (or else I'm sure would've been addressed right away) because
of
our all dear friend: missing testsuite coverage.  Thus, for GCC 8, I'm
likewise
enhancing the testsuite, without the C++ front end code changes.

I actually had presumed that there may be an issue for OpenACC:
, so
here
we are, two years (and many "wasted" hours...) later...

gcc/cp/
* parser.c (cp_parser_omp_var_list_no_open): Assert that array
section's 'low_bound', 'length' are not location wrapper nodes.
(cp_parser_oacc_all_clauses, cp_parser_oacc_cache): Instantiate
'auto_suppress_location_wrappers'.
gcc/testsuite/
* c-c++-common/goacc/cache-3-1.c: New.
* c-c++-common/goacc/cache-3-2.c: Likewise.
* c-c++-common/goacc/data-clause-1.c: Likewise.
* c-c++-common/goacc/data-clause-2.c: Likewise.
* c-c++-common/gomp/map-1.c: Adjust.
* c-c++-common/gomp/map-2.c: Likewise.
* g++.dg/goacc/cache-3-1.C: New.
* g++.dg/goacc/cache-3-2.C: Likewise.
* g++.dg/goacc/data-clause-1.C: Likewise.
* g++.dg/goacc/data-clause-2.C: Likewise.
* g++.dg/gomp/map-1.C: Adjust.
* g++.dg/gomp/map-2.C: Likewise.

Reported-by: Sandra Loosemore 
(cherry picked from commit c0c7270cc4efd896fe99f8ad5409dbef089a407f)

[Bug c++/43486] Preserve variable-use locations

2020-11-26 Thread cvs-commit at gcc dot gnu.org via Gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=43486

--- Comment #20 from CVS Commits  ---
The releases/gcc-9 branch has been updated by Thomas Schwinge
:

https://gcc.gnu.org/g:25b61f935a8eca56c68c8587fc8915797250bb30

commit r9-9073-g25b61f935a8eca56c68c8587fc8915797250bb30
Author: Thomas Schwinge 
Date:   Wed Nov 25 20:36:55 2020 +0100

Don't create location wrapper nodes within OpenACC clauses

This fixes a GCC 11, 10, 9 regression introduced by commit
dfd7fdca2ac17d8b823a16700525824ca312ade0 (Subversion r267272) "C++: more
location wrapper nodes (PR c++/43064, PR c++/43486)".  But: this isn't
intending to blame David, because back then, the problem hasn't been
visible in
the testsuite (or else I'm sure would've been addressed right away) because
of
our all dear friend: missing testsuite coverage.  Thus, for GCC 8, I'm
likewise
enhancing the testsuite, without the C++ front end code changes.

I actually had presumed that there may be an issue for OpenACC:
, so
here
we are, two years (and many "wasted" hours...) later...

gcc/cp/
* parser.c (cp_parser_omp_var_list_no_open): Assert that array
section's 'low_bound', 'length' are not location wrapper nodes.
(cp_parser_oacc_all_clauses, cp_parser_oacc_cache): Instantiate
'auto_suppress_location_wrappers'.
gcc/testsuite/
* c-c++-common/goacc/cache-3-1.c: New.
* c-c++-common/goacc/cache-3-2.c: Likewise.
* c-c++-common/goacc/data-clause-1.c: Likewise.
* c-c++-common/goacc/data-clause-2.c: Likewise.
* c-c++-common/gomp/map-1.c: Adjust.
* c-c++-common/gomp/map-2.c: Likewise.
* g++.dg/goacc/cache-3-1.C: New.
* g++.dg/goacc/cache-3-2.C: Likewise.
* g++.dg/goacc/data-clause-1.C: Likewise.
* g++.dg/goacc/data-clause-2.C: Likewise.
* g++.dg/gomp/map-1.C: Adjust.
* g++.dg/gomp/map-2.C: Likewise.

Reported-by: Sandra Loosemore 
(cherry picked from commit c0c7270cc4efd896fe99f8ad5409dbef089a407f)

[Bug c++/43486] Preserve variable-use locations

2020-11-26 Thread cvs-commit at gcc dot gnu.org via Gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=43486

--- Comment #21 from CVS Commits  ---
The releases/gcc-8 branch has been updated by Thomas Schwinge
:

https://gcc.gnu.org/g:23ec71d91e3044108a557dace573d3e60ff1c07e

commit r8-10649-g23ec71d91e3044108a557dace573d3e60ff1c07e
Author: Thomas Schwinge 
Date:   Wed Nov 25 20:36:55 2020 +0100

Don't create location wrapper nodes within OpenACC clauses (testsuite
changes only)

This fixes a GCC 11, 10, 9 regression introduced by commit
dfd7fdca2ac17d8b823a16700525824ca312ade0 (Subversion r267272) "C++: more
location wrapper nodes (PR c++/43064, PR c++/43486)".  But: this isn't
intending to blame David, because back then, the problem hasn't been
visible in
the testsuite (or else I'm sure would've been addressed right away) because
of
our all dear friend: missing testsuite coverage.  Thus, for GCC 8, I'm
likewise
enhancing the testsuite, without the C++ front end code changes.

I actually had presumed that there may be an issue for OpenACC:
, so
here
we are, two years (and many "wasted" hours...) later...

gcc/testsuite/
* c-c++-common/goacc/cache-3-1.c: New.
* c-c++-common/goacc/cache-3-2.c: Likewise.
* c-c++-common/goacc/data-clause-1.c: Likewise.
* c-c++-common/goacc/data-clause-2.c: Likewise.
* c-c++-common/gomp/map-1.c: Adjust.
* c-c++-common/gomp/map-2.c: Likewise.
* g++.dg/goacc/cache-3-1.C: New.
* g++.dg/goacc/cache-3-2.C: Likewise.
* g++.dg/goacc/data-clause-1.C: Likewise.
* g++.dg/goacc/data-clause-2.C: Likewise.
* g++.dg/gomp/map-1.C: Adjust.
* g++.dg/gomp/map-2.C: Likewise.

Reported-by: Sandra Loosemore 
(cherry picked from commit c0c7270cc4efd896fe99f8ad5409dbef089a407f
(testsuite changes only))

[Bug c++/43486] Preserve variable-use locations

2018-11-05 Thread dmalcolm at gcc dot gnu.org
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=43486

David Malcolm  changed:

   What|Removed |Added

 Status|NEW |ASSIGNED
   Assignee|unassigned at gcc dot gnu.org  |dmalcolm at gcc dot 
gnu.org

--- Comment #14 from David Malcolm  ---
Candidate followup patch:
  https://gcc.gnu.org/ml/gcc-patches/2018-11/msg00304.html

[Bug c++/43486] Preserve variable-use locations

2018-12-19 Thread dmalcolm at gcc dot gnu.org
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=43486

--- Comment #15 from David Malcolm  ---
Author: dmalcolm
Date: Wed Dec 19 15:08:21 2018
New Revision: 267272

URL: https://gcc.gnu.org/viewcvs?rev=267272&root=gcc&view=rev
Log:
C++: more location wrapper nodes (PR c++/43064, PR c++/43486)

This is v6 of the patch, as posted to:
  https://gcc.gnu.org/ml/gcc-patches/2018-12/msg01331.html


The C++ frontend gained various location wrapper nodes in r256448 (GCC 8).
That patch:
  https://gcc.gnu.org/ml/gcc-patches/2018-01/msg00799.html
added wrapper nodes around all nodes with !CAN_HAVE_LOCATION_P for:

* arguments at callsites, and for

* typeid, alignof, sizeof, and offsetof.

This is a followup to that patch, adding many more location wrappers
to the C++ frontend.  It adds location wrappers for nodes with
!CAN_HAVE_LOCATION_P to:

* all literal nodes (in cp_parser_primary_expression)

* all id-expression nodes (in finish_id_expression), except within a
  decltype.

* all mem-initializer nodes within a mem-initializer-list
  (in cp_parser_mem_initializer)

However, the patch also adds some suppressions: regions in the parser
for which wrapper nodes will not be created:

* within a template-parameter-list or template-argument-list (in
  cp_parser_template_parameter_list and cp_parser_template_argument_list
  respectively), to avoid encoding the spelling location of the nodes
  in types.  For example, "array<10>" and "array<10>" are the same type,
  despite the fact that the two different "10" tokens are spelled in
  different locations in the source.

* within a gnu-style attribute (none of are handlers are set up to cope
  with location wrappers yet)

* within various OpenMP clauses

The patch enables various improvements to locations for bad
initializations, for -Wchar-subscripts, and enables various other
improvements in the followup patch.

For example, given the followup buggy mem-initializer:

class X {
  X() : bad(42),
good(42)
  { }
  void* bad;
  int good;
};

previously, our diagnostic was on the final close parenthesis of the
mem-initializer-list, leaving it unclear where the problem is:

t.cc: In constructor 'X::X()':
t.cc:3:16: error: invalid conversion from 'int' to 'void*' [-fpermissive]
3 | good(42)
  |^
  ||
  |int

whereas with the patch we highlight which expression is bogus:

t.cc: In constructor 'X::X()':
t.cc:2:13: error: invalid conversion from 'int' to 'void*' [-fpermissive]
2 |   X() : bad(42),
  | ^~
  | |
  | int

Similarly, the diagnostic for this bogus initialization:

i.cc:1:44: error: initializer-string for array of chars is too long
[-fpermissive]
1 | char test[3][4] = { "ok", "too long", "ok" };
  |^

is improved by the patch so that it indicates which string is too long:

i.cc:1:27: error: initializer-string for array of chars is too long
[-fpermissive]
1 | char test[3][4] = { "ok", "too long", "ok" };
  |   ^~


gcc/c-family/ChangeLog:
PR c++/43064
PR c++/43486
* c-common.c (unsafe_conversion_p): Fold any location wrapper.
(verify_tree): Handle location wrappers.
(c_common_truthvalue_conversion): Strip any location wrapper.
Handle CONST_DECL.
(fold_offsetof): Strip any location wrapper.
(complete_array_type): Likewise for initial_value.
(convert_vector_to_array_for_subscript): Call fold_for_warn on the
index before checking for INTEGER_CST.
* c-pretty-print.c (c_pretty_printer::primary_expression): Don't
print parentheses around location wrappers.
* c-warn.c (warn_logical_operator): Call fold_for_warn on op_right
before checking for INTEGER_CST.
(warn_tautological_bitwise_comparison): Call
tree_strip_any_location_wrapper on lhs, rhs, and bitop's operand
before checking for INTEGER_CST.
(readonly_error): Strip any location wrapper.
(warn_array_subscript_with_type_char): Strip location wrappers
before checking for INTEGER_CST.  Use the location of the index if
available.

gcc/ChangeLog:
PR c++/43064
PR c++/43486
* convert.c: Include "selftest.h".
(preserve_any_location_wrapper): New function.
(convert_to_pointer_maybe_fold): Update to handle location
wrappers.
(convert_to_real_maybe_fold): Likewise.
(convert_to_integer_1): Strip expr when using TREE_OVERFLOW.
Handle location wrappers when checking for INTEGER_CST.
(convert_to_integer_maybe_fold): Update to handle location
wrappers.
(convert_to_complex_maybe_fold): Likewise.
(selftest::test_convert_to_integer_maybe_fold): New functions.
(selftest::convert_c_tests): New function.
* convert.h (preserve_any_location_wrapper): Ne

[Bug c++/43486] Preserve variable-use locations

2018-12-19 Thread dmalcolm at gcc dot gnu.org
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=43486

--- Comment #16 from David Malcolm  ---
Should be greatly improved for C++ for gcc 9 by r267272.

[Bug c++/43486] Preserve variable-use locations

2018-12-19 Thread egallager at gcc dot gnu.org
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=43486

--- Comment #17 from Eric Gallager  ---
(In reply to David Malcolm from comment #16)
> Should be greatly improved for C++ for gcc 9 by r267272.

...but not fixed?

[Bug c++/43486] Preserve variable-use locations

2012-10-14 Thread manu at gcc dot gnu.org

http://gcc.gnu.org/bugzilla/show_bug.cgi?id=43486

--- Comment #6 from Manuel López-Ibáñez  2012-10-14 
18:28:32 UTC ---
I think there is a consensus that g++ wants this somehow. Recent work:

http://gcc.gnu.org/ml/gcc-patches/2012-09/msg01222.html


[Bug c++/43486] Preserve variable-use locations

2012-11-01 Thread paolo.carlini at oracle dot com


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=43486



--- Comment #7 from Paolo Carlini  2012-11-01 
23:06:54 UTC ---

*** Bug 55173 has been marked as a duplicate of this bug. ***


[Bug c++/43486] Preserve variable-use locations

2015-05-21 Thread paolo.carlini at oracle dot com
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=43486

Paolo Carlini  changed:

   What|Removed |Added

 CC||darlingm at gmail dot com

--- Comment #9 from Paolo Carlini  ---
*** Bug 66231 has been marked as a duplicate of this bug. ***


[Bug c++/43486] Preserve variable-use locations

2015-05-21 Thread manu at gcc dot gnu.org
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=43486

--- Comment #10 from Manuel López-Ibáñez  ---
(In reply to Matthew Woehlke from comment #8)
> Can this *please* get fixed? This really hurts the ability to use
> -Wzero-as-null-ptr in particular. See
> https://bugreports.qt.io/browse/QTBUG-45291 for an example of the pain this
> causes.

Fixing this is hard. There are several ideas floating around but all of them
have their disadvantages
(https://gcc.gnu.org/ml/gcc-patches/2012-09/msg01373.html and
https://gcc.gnu.org/ml/gcc-patches/2012-11/msg00164.html). Unless some new
brilliant contributor appears and starts passionately working on this, this is
not going to be fixed in the near (or medium) term. If you know such a person,
please let us know.

[Bug c++/43486] Preserve variable-use locations

2015-03-30 Thread mw_triad at users dot sourceforge.net
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=43486

--- Comment #8 from Matthew Woehlke  ---
Can this *please* get fixed? This really hurts the ability to use
-Wzero-as-null-ptr in particular. See
https://bugreports.qt.io/browse/QTBUG-45291 for an example of the pain this
causes.


[Bug c++/43486] Preserve variable-use locations

2024-01-23 Thread mpolacek at gcc dot gnu.org via Gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=43486

Marek Polacek  changed:

   What|Removed |Added

 Status|ASSIGNED|RESOLVED
 CC||mpolacek at gcc dot gnu.org
 Resolution|--- |FIXED

--- Comment #22 from Marek Polacek  ---
Fixed, I suppose.