re PR c++/51316 (alignof doesn't work with arrays of unknown bound)

/c-family
2011-12-30  Paolo Carlini  <paolo.carlini@oracle.com>

	PR c++/51316
	* c-common.c (c_sizeof_or_alignof_type): In C++ allow for alignof
	of array types with an unknown bound.

/testsuite
2011-12-30  Paolo Carlini  <paolo.carlini@oracle.com>

	PR c++/51316
	* g++.dg/cpp0x/alignof4.C: New.

From-SVN: r182746
This commit is contained in:
Paolo Carlini 2011-12-30 21:11:20 +00:00 committed by Paolo Carlini
parent 30c34af582
commit 73ac190a5e
4 changed files with 29 additions and 2 deletions

View file

@ -1,3 +1,9 @@
2011-12-30 Paolo Carlini <paolo.carlini@oracle.com>
PR c++/51316
* c-common.c (c_sizeof_or_alignof_type): In C++ allow for alignof
of array types with an unknown bound.
2011-12-20 Joseph Myers <joseph@codesourcery.com>
* c-common.c (flag_isoc99): Update comment to refer to C11.

View file

@ -4382,13 +4382,22 @@ c_sizeof_or_alignof_type (location_t loc,
return error_mark_node;
value = size_one_node;
}
else if (!COMPLETE_TYPE_P (type))
else if (!COMPLETE_TYPE_P (type)
&& (!c_dialect_cxx () || is_sizeof || type_code != ARRAY_TYPE))
{
if (complain)
error_at (loc, "invalid application of %qs to incomplete type %qT ",
error_at (loc, "invalid application of %qs to incomplete type %qT",
op_name, type);
return error_mark_node;
}
else if (c_dialect_cxx () && type_code == ARRAY_TYPE
&& !COMPLETE_TYPE_P (TREE_TYPE (type)))
{
if (complain)
error_at (loc, "invalid application of %qs to array type %qT of "
"incomplete element type", op_name, type);
return error_mark_node;
}
else
{
if (is_sizeof)

View file

@ -1,3 +1,8 @@
2011-12-30 Paolo Carlini <paolo.carlini@oracle.com>
PR c++/51316
* g++.dg/cpp0x/alignof4.C: New.
2011-12-29 Michael Meissner <meissner@linux.vnet.ibm.com>
PR testsuite/51702

View file

@ -0,0 +1,7 @@
// PR c++/51316
// { dg-options "-std=c++0x" }
int main()
{
alignof(int []);
}