re PR c++/41131 (non-lvalue in unary `&' wrongly accepted)

PR c++/41131
	* tree.c (lvalue_p_1) <case CONST_DECL>: Return clk_none if
	not TREE_STATIC.

	* g++.dg/expr/unary3.C: New test.

From-SVN: r150986
This commit is contained in:
Jakub Jelinek 2009-08-21 09:10:36 +02:00 committed by Jakub Jelinek
parent 516a319d6e
commit 964c8e25cc
4 changed files with 28 additions and 0 deletions

View File

@ -1,3 +1,9 @@
2009-08-21 Jakub Jelinek <jakub@redhat.com>
PR c++/41131
* tree.c (lvalue_p_1) <case CONST_DECL>: Return clk_none if
not TREE_STATIC.
2009-08-05 Jason Merrill <jason@redhat.com>
PR c++/40948

View File

@ -132,6 +132,12 @@ lvalue_p_1 (tree ref)
return clk_ordinary;
case CONST_DECL:
/* CONST_DECL without TREE_STATIC are enumeration values and
thus not lvalues. With TREE_STATIC they are used by ObjC++
in objc_build_string_object and need to be considered as
lvalues. */
if (! TREE_STATIC (ref))
return clk_none;
case VAR_DECL:
if (TREE_READONLY (ref) && ! TREE_STATIC (ref)
&& DECL_LANG_SPECIFIC (ref)

View File

@ -1,3 +1,8 @@
2009-08-21 Jakub Jelinek <jakub@redhat.com>
PR c++/41131
* g++.dg/expr/unary3.C: New test.
2009-08-20 Thomas Koenig <tkoenig@gcc.gnu.org>
PR libfortran/40962

View File

@ -0,0 +1,11 @@
// PR c++/41131
// { dg-do compile }
struct X { enum E { a = 100 }; };
int
main ()
{
X x;
(void) &x.a; // { dg-error "lvalue required" }
}