Commit 109e0040 by Mark Mitchell Committed by Mark Mitchell

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
parent 9655d83b
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> 2004-06-10 Jakub Jelinek <jakub@redhat.com>
PR c++/14791 PR c++/14791
......
...@@ -10726,8 +10726,10 @@ cp_parser_direct_declarator (cp_parser* parser, ...@@ -10726,8 +10726,10 @@ cp_parser_direct_declarator (cp_parser* parser,
type = resolve_typename_type (scope, type = resolve_typename_type (scope,
/*only_current_p=*/false); /*only_current_p=*/false);
/* If that failed, the declarator is invalid. */ /* If that failed, the declarator is invalid. */
if (type != error_mark_node) if (type == error_mark_node)
scope = type; error ("`%T::%D' is not a type",
TYPE_CONTEXT (scope),
TYPE_IDENTIFIER (scope));
/* Build a new DECLARATOR. */ /* Build a new DECLARATOR. */
declarator = build_nt (SCOPE_REF, declarator = build_nt (SCOPE_REF,
scope, scope,
......
...@@ -7421,7 +7421,7 @@ tsubst_copy (tree t, tree args, tsubst_flags_t complain, tree in_decl) ...@@ -7421,7 +7421,7 @@ tsubst_copy (tree t, tree args, tsubst_flags_t complain, tree in_decl)
return t; return t;
/* If ARGS is NULL, then T is known to be non-dependent. */ /* If ARGS is NULL, then T is known to be non-dependent. */
if (args == NULL_TREE) if (args == NULL_TREE)
return t; return decl_constant_value (t);
/* Unfortunately, we cannot just call lookup_name here. /* Unfortunately, we cannot just call lookup_name here.
Consider: Consider:
......
...@@ -4535,7 +4535,17 @@ build_static_cast (tree type, tree expr) ...@@ -4535,7 +4535,17 @@ build_static_cast (tree type, tree expr)
t. */ t. */
result = perform_direct_initialization_if_possible (type, expr); result = perform_direct_initialization_if_possible (type, expr);
if (result) 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] /* [expr.static.cast]
......
// PR c++/14211
void f(char *str) {
char *& m = const_cast<char *>(str); // { dg-error "" }
}
// PR c++/15076
struct Y { Y(int &); }; // { dg-error "" }
int v;
Y y1(reinterpret_cast<int>(v)); // { dg-error "" }
// PR c++/15877
template <int n> struct T1 { enum { N = 3 }; };
template <int n> struct T2 { enum { N = n, N1 = T1<N>::N }; };
// PR c++/15227
template<typename> struct A {};
template<typename T> void A<T>::B::foo() {} // { dg-error "" }
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment