diff options
author | Joseph Myers <joseph@codesourcery.com> | 2015-12-02 18:24:23 +0000 |
---|---|---|
committer | Joseph Myers <jsm28@gcc.gnu.org> | 2015-12-02 18:24:23 +0000 |
commit | e9e32ee6e8df82ba1d103ec2c501ecc7c185bc2e (patch) | |
tree | e7fbe443ab146c38eb72dcfc64ff8add5a7da19b /gcc/c-family | |
parent | 701fa326a18df74cabd79cfef314ebbe5847d23b (diff) | |
download | gcc-e9e32ee6e8df82ba1d103ec2c501ecc7c185bc2e.zip gcc-e9e32ee6e8df82ba1d103ec2c501ecc7c185bc2e.tar.gz gcc-e9e32ee6e8df82ba1d103ec2c501ecc7c185bc2e.tar.bz2 |
Fix TYPE_MAIN_VARIANT construction for arrays of qualified typedefs (PR c/68162).
PR c/68162 reports a spurious warning about incompatible types
involving arrays of const double, constructed in one place using a
typedef for const double and in another place literally using const
double.
The problem is that the array of the typedef was incorrectly
constructed without a TYPE_MAIN_VARIANT being an array of unqualified
elements as it should be (though it seems some more recent change
resulted in this producing incorrect diagnostics, likely the support
for C++-style handling of arrays of qualified type). This patch fixes
the logic in grokdeclarator to determine first_non_attr_kind, which is
used to determine whether it is necessary to use the TYPE_MAIN_VARIANT
of the type in the declaration specifiers.
However, fixing that logic introduces a failure of
gcc.dg/debug/dwarf2/pr47939-4.c, a test introduced along with
first_non_attr_kind. Thus, it is necessary to track the original
qualified typedef when qualifying an array type, to use it rather than
a newly-constructed type, to avoid regressing regarding typedef names
in debug info. This is done along lines I suggested in
<https://gcc.gnu.org/bugzilla/show_bug.cgi?id=47939#c6>: track the
original type and the number of levels of array indirection at which
it appears, and, in possibly affected cases, pass extra arguments to
c_build_qualified_type (with default arguments to avoid needing to
pass those extra arguments explicitly everywhere). Given Richard's
recent fix to dwarf2out.c, this allows the C bug to be fixed without
causing debug information regressions.
Bootstrapped with no regressions on x86_64-pc-linux-gnu.
gcc/c:
PR c/68162
* c-decl.c (grokdeclarator): Set first_non_attr_kind before
following link from declarator to next declarator. Track original
qualified type and pass it to c_build_qualified_type.
* c-typeck.c (c_build_qualified_type): Add arguments
orig_qual_type and orig_qual_indirect.
gcc/c-family:
PR c/68162
* c-common.h (c_build_qualified_type): Add extra default
arguments.
gcc/cp:
PR c/68162
* tree.c (c_build_qualified_type): Add extra arguments.
gcc/testsuite:
PR c/68162
* gcc.dg/pr68162-1.c: New test.
From-SVN: r231194
Diffstat (limited to 'gcc/c-family')
-rw-r--r-- | gcc/c-family/ChangeLog | 6 | ||||
-rw-r--r-- | gcc/c-family/c-common.h | 2 |
2 files changed, 7 insertions, 1 deletions
diff --git a/gcc/c-family/ChangeLog b/gcc/c-family/ChangeLog index 982a74a..b89812f 100644 --- a/gcc/c-family/ChangeLog +++ b/gcc/c-family/ChangeLog @@ -1,3 +1,9 @@ +2015-12-02 Joseph Myers <joseph@codesourcery.com> + + PR c/68162 + * c-common.h (c_build_qualified_type): Add extra default + arguments. + 2015-12-01 Julian Brown <julian@codesourcery.com> Cesar Philippidis <cesar@codesourcery.com> James Norris <James_Norris@mentor.com> diff --git a/gcc/c-family/c-common.h b/gcc/c-family/c-common.h index bad8d05..6e60e34 100644 --- a/gcc/c-family/c-common.h +++ b/gcc/c-family/c-common.h @@ -866,7 +866,7 @@ extern tree pointer_int_sum (location_t, enum tree_code, tree, tree, bool = true); /* Add qualifiers to a type, in the fashion for C. */ -extern tree c_build_qualified_type (tree, int); +extern tree c_build_qualified_type (tree, int, tree = NULL_TREE, size_t = 0); /* Build tree nodes and builtin functions common to both C and C++ language frontends. */ |