Skip to content

Commit 53884e9

Browse files
committed
Merge fedorahosted.org and github changes
2 parents d721624 + c9fceb4 commit 53884e9

File tree

13 files changed

+67
-40
lines changed

13 files changed

+67
-40
lines changed

gcc-c-api/gcc-cfg.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -202,7 +202,7 @@ gcc_cfg_block_for_each_gimple_phi (gcc_cfg_block block,
202202
!gsi_end_p (gsi); gsi_next (&gsi))
203203
{
204204

205-
gimple stmt = gsi_stmt (gsi);
205+
gimple_stmt_ptr stmt = gsi_stmt (gsi);
206206
if (cb (gcc_private_make_gimple_phi (stmt), user_data))
207207
{
208208
return true;
@@ -231,7 +231,7 @@ gcc_cfg_block_for_each_gimple (gcc_cfg_block block,
231231
!gsi_end_p (gsi); gsi_next (&gsi))
232232
{
233233

234-
gimple stmt = gsi_stmt (gsi);
234+
gimple_stmt_ptr stmt = gsi_stmt (gsi);
235235
if (cb (gcc_private_make_gimple (stmt), user_data))
236236
{
237237
return true;

gcc-c-api/gcc-common.h

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,12 @@
2727
#define GCC_PUBLIC_API(RETURN_TYPE) extern RETURN_TYPE
2828
#define GCC_PRIVATE_API(RETURN_TYPE) extern RETURN_TYPE
2929

30+
#if (GCC_VERSION >= 6000)
31+
typedef gimple *gimple_stmt_ptr;
32+
#else
33+
typedef gimple gimple_stmt_ptr;
34+
#endif
35+
3036
#include "gcc-public-types.h"
3137

3238
/* For internal use: */

gcc-c-api/gcc-gimple.c

Lines changed: 12 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -53,14 +53,21 @@ GCC_IMPLEMENT_PUBLIC_API (void) gcc_gimple_mark_in_use (gcc_gimple stmt)
5353

5454
/* GCC 4.9 converted gimple to a class hierarchy */
5555
#if (GCC_VERSION >= 4009)
56+
57+
/* GCC 6 converted the base class from "gimple_statement_base" to
58+
"gimple". */
59+
# if (GCC_VERSION >= 6000)
60+
gt_ggc_mx_gimple (stmt.inner);
61+
# else
5662
gt_ggc_mx_gimple_statement_base (stmt.inner);
57-
#else
63+
# endif
64+
#else /* #if (GCC_VERSION >= 4009) */
5865
gt_ggc_mx_gimple_statement_d (stmt.inner);
59-
#endif
66+
#endif /* #if (GCC_VERSION >= 4009) */
6067
}
6168

6269
GCC_IMPLEMENT_PRIVATE_API (struct gcc_gimple_phi)
63-
gcc_private_make_gimple_phi (gimple inner)
70+
gcc_private_make_gimple_phi (gimple_stmt_ptr inner)
6471
{
6572
struct gcc_gimple_phi result;
6673
GIMPLE_CHECK (inner, GIMPLE_PHI);
@@ -69,7 +76,7 @@ gcc_private_make_gimple_phi (gimple inner)
6976
}
7077

7178
GCC_IMPLEMENT_PRIVATE_API (struct gcc_gimple_call)
72-
gcc_private_make_gimple_call (gimple inner)
79+
gcc_private_make_gimple_call (gimple_stmt_ptr inner)
7380
{
7481
struct gcc_gimple_call result;
7582
GIMPLE_CHECK (inner, GIMPLE_CALL);
@@ -78,7 +85,7 @@ gcc_private_make_gimple_call (gimple inner)
7885
}
7986

8087
GCC_IMPLEMENT_PRIVATE_API (struct gcc_gimple)
81-
gcc_private_make_gimple (gimple inner)
88+
gcc_private_make_gimple (gimple_stmt_ptr inner)
8289
{
8390
struct gcc_gimple result;
8491
result.inner = inner;

gcc-c-api/gimple.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@
2121

2222
<doc>GIMPLE statements</doc>
2323

24-
<type name="gimple" varname="stmt" inner="gimple">
24+
<type name="gimple" varname="stmt" inner="gimple_stmt_ptr">
2525
<attribute name="location" kind="location">
2626
<doc>Source code location of this statement</doc>
2727
</attribute>

gcc-python.c

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,9 @@ int plugin_is_GPL_compatible;
3535

3636
#if 1
3737
/* Ideally we wouldn't have these includes here: */
38+
#if (GCC_VERSION >= 6000)
39+
#include "cp/cp-tree.h" /* for cp_expr */
40+
#endif
3841
#include "cp/name-lookup.h" /* for global_namespace */
3942
#include "tree.h"
4043
#include "function.h"

gccutils/__init__.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@ def get_global_typedef(name):
3737
# Look up a typedef in global scope by name, returning a gcc.TypeDecl,
3838
# or None if not found
3939
for u in gcc.get_translation_units():
40-
if u.language == 'GNU C++':
40+
if u.language.startswith('GNU C++'):
4141
gns = gcc.get_global_namespace()
4242
return gns.lookup(name)
4343
if u.block:

libcpychecker/formatstrings.py

Lines changed: 22 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
1-
# Copyright 2011 David Malcolm <dmalcolm@redhat.com>
2-
# Copyright 2011 Red Hat, Inc.
1+
# Copyright 2011, 2016 David Malcolm <dmalcolm@redhat.com>
2+
# Copyright 2011, 2016 Red Hat, Inc.
33
#
44
# This is free software: you can redistribute it and/or modify it
55
# under the terms of the GNU General Public License as published by
@@ -58,6 +58,13 @@ class FormatStringWarning(CExtensionWarning):
5858
def __init__(self, fmt_string):
5959
self.fmt_string = fmt_string
6060

61+
def emit_as_warning(self, loc):
62+
if gcc.warning(loc, str(self)):
63+
sys.stderr.write(self.extra_info())
64+
65+
def extra_info(self):
66+
return ""
67+
6168
class UnknownFormatChar(FormatStringWarning):
6269
def __init__(self, fmt_string, ch):
6370
FormatStringWarning.__init__(self, fmt_string)
@@ -137,12 +144,14 @@ def __init__(self, funcname, fmt, varargs):
137144
self.varargs = varargs
138145

139146
def __str__(self):
140-
result = ('%s in call to %s with format string "%s"\n'
141-
' expected %i extra arguments:\n'
142-
% (self._get_desc_prefix(),
143-
self.funcname,
144-
self.fmt.fmt_string,
145-
self.fmt.num_expected()))
147+
return ('%s in call to %s with format string "%s"'
148+
% (self._get_desc_prefix(),
149+
self.funcname,
150+
self.fmt.fmt_string))
151+
152+
def extra_info(self):
153+
result = (' expected %i extra arguments:\n'
154+
% self.fmt.num_expected())
146155
for (arg, exp_type) in self.fmt.iter_exp_types():
147156
result += ' %s\n' % describe_type(exp_type)
148157
if len(self.varargs) == 0:
@@ -380,8 +389,8 @@ def check_callsite(stmt, parser, funcname, format_idx, varargs_idx, with_size_t)
380389
try:
381390
fmt = parser.from_string(fmt_string, with_size_t)
382391
except FormatStringWarning:
383-
exc = sys.exc_info()[1]
384-
gcc.warning(stmt.loc, str(exc))
392+
err = sys.exc_info()[1]
393+
err.emit_as_warning(stmt.loc)
385394
return
386395
log('fmt: %r', fmt.args)
387396

@@ -392,11 +401,11 @@ def check_callsite(stmt, parser, funcname, format_idx, varargs_idx, with_size_t)
392401
varargs = stmt.args[varargs_idx:]
393402
# log('varargs: %r', varargs)
394403
if len(varargs) < len(exp_types):
395-
gcc.warning(loc, str(NotEnoughVars(funcname, fmt, varargs)))
404+
NotEnoughVars(funcname, fmt, varargs).emit_as_warning(loc)
396405
return
397406

398407
if len(varargs) > len(exp_types):
399-
gcc.warning(loc, str(TooManyVars(funcname, fmt, varargs)))
408+
TooManyVars(funcname, fmt, varargs).emit_as_warning(loc)
400409
return
401410

402411
for index, ((exp_arg, exp_type), vararg) in enumerate(zip(exp_types, varargs)):
@@ -408,9 +417,7 @@ def check_callsite(stmt, parser, funcname, format_idx, varargs_idx, with_size_t)
408417
loc = vararg.location
409418
else:
410419
loc = stmt.loc
411-
gcc.warning(loc,
412-
str(err))
413-
sys.stderr.write(err.extra_info())
420+
err.emit_as_warning(loc)
414421

415422
def maybe_check_callsite(stmt):
416423
if stmt.fndecl:

print-gcc-version.c

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,11 @@
1717
<http://www.gnu.org/licenses/>.
1818
*/
1919

20+
#include "config.h"
21+
#include "system.h"
22+
#include "coretypes.h"
2023
#include "plugin.h"
24+
#include <stdio.h>
2125

2226
int main(int argc, const char *argv[])
2327
{

run-test-suite.py

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -728,6 +728,10 @@ def exclude_tests_below(path):
728728
exclude_test('tests/plugin/callgraph')
729729
exclude_test('tests/plugin/rtl')
730730

731+
# Tests that are over-specified and only work for GCC 6 and later:
732+
if GCC_VERSION < 6000:
733+
exclude_test('tests/examples/find-global-state')
734+
731735
def run_one_test(testdir):
732736
try:
733737
sys.stdout.write('%s: ' % testdir)

testcpychecker.py

Lines changed: 8 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -182,11 +182,10 @@ def test_not_enough_varargs(self):
182182
"""
183183
self.assertFindsError(src,
184184
"$(SRCFILE): In function 'not_enough_varargs':\n"
185-
'$(SRCFILE):13:25: error: Not enough arguments in call to PyArg_ParseTuple with format string "i"\n'
185+
'$(SRCFILE):13:25: error: Not enough arguments in call to PyArg_ParseTuple with format string "i" [-Werror]\n'
186186
' expected 1 extra arguments:\n'
187187
' "int *" (pointing to 32 bits)\n'
188-
' but got none\n'
189-
' [-Werror]\n')
188+
' but got none\n')
190189

191190
def test_too_many_varargs(self):
192191
src = """
@@ -202,13 +201,12 @@ def test_too_many_varargs(self):
202201
"""
203202
self.assertFindsError(src,
204203
"$(SRCFILE): In function 'too_many_varargs':\n"
205-
'$(SRCFILE):14:26: error: Too many arguments in call to PyArg_ParseTuple with format string "i"\n'
204+
'$(SRCFILE):14:26: error: Too many arguments in call to PyArg_ParseTuple with format string "i" [-Werror]\n'
206205
' expected 1 extra arguments:\n'
207206
' "int *" (pointing to 32 bits)\n'
208207
' but got 2:\n'
209208
' "int *" (pointing to 32 bits)\n'
210-
' "int *" (pointing to 32 bits)\n'
211-
' [-Werror]\n')
209+
' "int *" (pointing to 32 bits)\n')
212210

213211
def test_correct_usage(self):
214212
src = """
@@ -528,11 +526,10 @@ def test_not_enough_varargs(self):
528526
"""
529527
self.assertFindsError(src,
530528
"$(SRCFILE): In function 'not_enough_varargs':\n"
531-
'$(SRCFILE):13:5: error: Not enough arguments in call to Py_BuildValue with format string "i"\n'
529+
'$(SRCFILE):13:5: error: Not enough arguments in call to Py_BuildValue with format string "i" [-Werror]\n'
532530
' expected 1 extra arguments:\n'
533531
' "int"\n'
534-
' but got none\n'
535-
' [-Werror]\n')
532+
' but got none\n')
536533

537534
def test_too_many_varargs(self):
538535
src = """
@@ -544,13 +541,12 @@ def test_too_many_varargs(self):
544541
"""
545542
self.assertFindsError(src,
546543
"$(SRCFILE): In function 'too_many_varargs':\n"
547-
'$(SRCFILE):13:5: error: Too many arguments in call to Py_BuildValue with format string "i"\n'
544+
'$(SRCFILE):13:5: error: Too many arguments in call to Py_BuildValue with format string "i" [-Werror]\n'
548545
' expected 1 extra arguments:\n'
549546
' "int"\n'
550547
' but got 2:\n'
551548
' "int"\n'
552-
' "int"\n'
553-
' [-Werror]\n')
549+
' "int"\n')
554550

555551
def test_correct_usage(self):
556552
src = """

0 commit comments

Comments
 (0)