re PR c++/15227 (Trouble with invalid function definition)

PR c++/15227
	* parser.c (cp_parser_direct_declarator): Robustify.

	PR c++/15877
	* pt.c (tsubst_copy): Use decl_constant_value on enumeration
	constants in non-dependent contexts.

	PR c++/14211
	PR c++/15076
	* typeck.c (build_static_cast): Wrap casts in NON_LVALUE_EXPR when
	necessary.

	PR c++/14211
	* g++.dg/conversion/const1.C: New test.

	PR c++/15076
	* g++.dg/conversion/reinterpret1.C: New test.

	PR c++/15877
	* g++.dg/template/enum2.C: New test.

	PR c++/15227
	* g++.dg/template/error13.C: New test.

From-SVN: r82917
This commit is contained in:
Mark Mitchell 2004-06-10 14:26:23 +00:00 committed by Mark Mitchell
parent 9655d83b75
commit 109e00403a
8 changed files with 50 additions and 4 deletions

View file

@ -1,3 +1,17 @@
2004-06-10 Mark Mitchell <mark@codesourcery.com>
PR c++/15227
* parser.c (cp_parser_direct_declarator): Robustify.
PR c++/15877
* pt.c (tsubst_copy): Use decl_constant_value on enumeration
constants in non-dependent contexts.
PR c++/14211
PR c++/15076
* typeck.c (build_static_cast): Wrap casts in NON_LVALUE_EXPR when
necessary.
2004-06-10 Jakub Jelinek <jakub@redhat.com>
PR c++/14791

View file

@ -10726,8 +10726,10 @@ cp_parser_direct_declarator (cp_parser* parser,
type = resolve_typename_type (scope,
/*only_current_p=*/false);
/* If that failed, the declarator is invalid. */
if (type != error_mark_node)
scope = type;
if (type == error_mark_node)
error ("`%T::%D' is not a type",
TYPE_CONTEXT (scope),
TYPE_IDENTIFIER (scope));
/* Build a new DECLARATOR. */
declarator = build_nt (SCOPE_REF,
scope,

View file

@ -7421,7 +7421,7 @@ tsubst_copy (tree t, tree args, tsubst_flags_t complain, tree in_decl)
return t;
/* If ARGS is NULL, then T is known to be non-dependent. */
if (args == NULL_TREE)
return t;
return decl_constant_value (t);
/* Unfortunately, we cannot just call lookup_name here.
Consider:

View file

@ -4535,7 +4535,17 @@ build_static_cast (tree type, tree expr)
t. */
result = perform_direct_initialization_if_possible (type, expr);
if (result)
return convert_from_reference (result);
{
result = convert_from_reference (result);
/* [expr.static.cast]
If T is a reference type, the result is an lvalue; otherwise,
the result is an rvalue. */
if (TREE_CODE (type) != REFERENCE_TYPE
&& real_lvalue_p (result))
result = build1 (NON_LVALUE_EXPR, TREE_TYPE (result), result);
return result;
}
/* [expr.static.cast]

View file

@ -0,0 +1,5 @@
// PR c++/14211
void f(char *str) {
char *& m = const_cast<char *>(str); // { dg-error "" }
}

View file

@ -0,0 +1,6 @@
// PR c++/15076
struct Y { Y(int &); }; // { dg-error "" }
int v;
Y y1(reinterpret_cast<int>(v)); // { dg-error "" }

View file

@ -0,0 +1,4 @@
// PR c++/15877
template <int n> struct T1 { enum { N = 3 }; };
template <int n> struct T2 { enum { N = n, N1 = T1<N>::N }; };

View file

@ -0,0 +1,5 @@
// PR c++/15227
template<typename> struct A {};
template<typename T> void A<T>::B::foo() {} // { dg-error "" }