mirror of
git://gcc.gnu.org/git/gcc.git
synced 2025-03-24 04:10:29 +08:00
re PR c++/16307 (-Wchar-subscripts does not warn on pointers)
2006-10-29 Dirk Mueller <dmueller@suse.de> PR c++/16307 * typeck.c (build_array_ref): Warn for char subscriptions on pointers. * g++.dg/warn/Wchar-subscripts-2.C: New testcase. From-SVN: r118154
This commit is contained in:
parent
3f07249e98
commit
0958b0d31d
@ -1,3 +1,9 @@
|
||||
2006-10-29 Dirk Mueller <dmueller@suse.de>
|
||||
|
||||
PR c++/16307
|
||||
* typeck.c (build_array_ref): Warn for char subscriptions
|
||||
on pointers.
|
||||
|
||||
2006-10-29 Kazu Hirata <kazu@codesourcery.com>
|
||||
|
||||
* decl.c: Fix a comment typo.
|
||||
|
@ -2489,6 +2489,8 @@ build_array_ref (tree array, tree idx)
|
||||
return error_mark_node;
|
||||
}
|
||||
|
||||
warn_array_subscript_with_type_char (idx);
|
||||
|
||||
return build_indirect_ref (cp_build_binary_op (PLUS_EXPR, ar, ind),
|
||||
"array indexing");
|
||||
}
|
||||
|
@ -1,3 +1,8 @@
|
||||
2006-10-29 Dirk Mueller <dmueller@suse.de>
|
||||
|
||||
PR c++/16307
|
||||
* g++.dg/warn/Wchar-subscripts-2.C: New testcase.
|
||||
|
||||
2006-10-29 Roger Sayle <roger@eyesopen.com>
|
||||
|
||||
PR tree-optimization/15458
|
||||
|
13
gcc/testsuite/g++.dg/warn/Wchar-subscripts-2.C
Normal file
13
gcc/testsuite/g++.dg/warn/Wchar-subscripts-2.C
Normal file
@ -0,0 +1,13 @@
|
||||
/* PR c++/16307 */
|
||||
// { dg-do compile }
|
||||
// { dg-options "-Wchar-subscripts" }
|
||||
|
||||
char foo (const char *s)
|
||||
{
|
||||
return s [s ['\x80']]; // { dg-warning "array subscript" }
|
||||
}
|
||||
|
||||
int main ()
|
||||
{
|
||||
foo ("\x80");
|
||||
}
|
Loading…
x
Reference in New Issue
Block a user