aboutsummaryrefslogtreecommitdiff
path: root/gcc
diff options
context:
space:
mode:
authorMark Mitchell <mmitchel@gcc.gnu.org>2003-07-29 01:57:47 +0000
committerMark Mitchell <mmitchel@gcc.gnu.org>2003-07-29 01:57:47 +0000
commit415d46362678d5b5ab71a96cec3363ad01870df5 (patch)
treed294364dbe757f8114ce5fb8aa4219d5820584d1 /gcc
parent7b6d72fcfbd0aa2bb05d81afcdcf5e4c6027b2e8 (diff)
downloadgcc-415d46362678d5b5ab71a96cec3363ad01870df5.zip
gcc-415d46362678d5b5ab71a96cec3363ad01870df5.tar.gz
gcc-415d46362678d5b5ab71a96cec3363ad01870df5.tar.bz2
re PR c++/11530 ([unit-at-a-time] inline static function not emitted with -O3)
PR c++/11530 * parser.c (cp_parser_postfix_expression): Do not call mark_used. * semantics.c (finish_id_expression): Call mark_used for all declarations. PR c++/11530 * g++.dg/opt/call1.C: New test. From-SVN: r69911
Diffstat (limited to 'gcc')
-rw-r--r--gcc/cp/ChangeLog7
-rw-r--r--gcc/cp/parser.c4
-rw-r--r--gcc/cp/semantics.c44
-rw-r--r--gcc/testsuite/ChangeLog5
-rw-r--r--gcc/testsuite/g++.dg/opt/call1.C21
5 files changed, 58 insertions, 23 deletions
diff --git a/gcc/cp/ChangeLog b/gcc/cp/ChangeLog
index 64068a2..583d13f 100644
--- a/gcc/cp/ChangeLog
+++ b/gcc/cp/ChangeLog
@@ -1,5 +1,12 @@
2003-07-28 Mark Mitchell <mark@codesourcery.com>
+ PR c++/11530
+ * parser.c (cp_parser_postfix_expression): Do not call mark_used.
+ * semantics.c (finish_id_expression): Call mark_used for all
+ declarations.
+
+2003-07-28 Mark Mitchell <mark@codesourcery.com>
+
PR c++/11667
* call.c (standard_conversion): Allow all integral->enumeral
conversions, after marking them as bad.
diff --git a/gcc/cp/parser.c b/gcc/cp/parser.c
index 1b7b3de..00f1c6e 100644
--- a/gcc/cp/parser.c
+++ b/gcc/cp/parser.c
@@ -3428,10 +3428,6 @@ cp_parser_postfix_expression (cp_parser *parser, bool address_p)
return postfix_expression;
}
- /* Remember that there was a reference to this entity. */
- if (DECL_P (postfix_expression))
- mark_used (postfix_expression);
-
/* Keep looping until the postfix-expression is complete. */
while (true)
{
diff --git a/gcc/cp/semantics.c b/gcc/cp/semantics.c
index abfe086..bf30ca0 100644
--- a/gcc/cp/semantics.c
+++ b/gcc/cp/semantics.c
@@ -2486,19 +2486,8 @@ finish_id_expression (tree id_expression,
*non_constant_expression_p = true;
}
}
-
- if (scope)
- {
- decl = (adjust_result_of_qualified_name_lookup
- (decl, scope, current_class_type));
- if (TREE_CODE (decl) == FIELD_DECL || BASELINK_P (decl))
- *qualifying_class = scope;
- else if (!processing_template_decl)
- decl = convert_from_reference (decl);
- else if (TYPE_P (scope))
- decl = build (SCOPE_REF, TREE_TYPE (decl), scope, decl);
- }
- else if (TREE_CODE (decl) == NAMESPACE_DECL)
+
+ if (TREE_CODE (decl) == NAMESPACE_DECL)
{
error ("use of namespace `%D' as expression", decl);
return error_mark_node;
@@ -2516,6 +2505,25 @@ finish_id_expression (tree id_expression,
print_candidates (decl);
return error_mark_node;
}
+
+ /* Mark variable-like entities as used. Functions are similarly
+ marked either below or after overload resolution. */
+ if (TREE_CODE (decl) == VAR_DECL
+ || TREE_CODE (decl) == PARM_DECL
+ || TREE_CODE (decl) == RESULT_DECL)
+ mark_used (decl);
+
+ if (scope)
+ {
+ decl = (adjust_result_of_qualified_name_lookup
+ (decl, scope, current_class_type));
+ if (TREE_CODE (decl) == FIELD_DECL || BASELINK_P (decl))
+ *qualifying_class = scope;
+ else if (!processing_template_decl)
+ decl = convert_from_reference (decl);
+ else if (TYPE_P (scope))
+ decl = build (SCOPE_REF, TREE_TYPE (decl), scope, decl);
+ }
else if (TREE_CODE (decl) == FIELD_DECL)
decl = finish_non_static_data_member (decl, current_class_ref,
/*qualifying_scope=*/NULL_TREE);
@@ -2525,7 +2533,10 @@ finish_id_expression (tree id_expression,
if (TREE_CODE (first_fn) == TEMPLATE_DECL)
first_fn = DECL_TEMPLATE_RESULT (first_fn);
-
+
+ if (!really_overloaded_fn (decl))
+ mark_used (first_fn);
+
if (TREE_CODE (first_fn) == FUNCTION_DECL
&& DECL_FUNCTION_MEMBER_P (first_fn))
{
@@ -2533,9 +2544,6 @@ finish_id_expression (tree id_expression,
decl = maybe_dummy_object (DECL_CONTEXT (first_fn), 0);
return finish_class_member_access_expr (decl, id_expression);
}
- else if (!really_overloaded_fn (decl))
- /* not really overloaded function */
- mark_used (first_fn);
}
else
{
@@ -2566,8 +2574,6 @@ finish_id_expression (tree id_expression,
perform_or_defer_access_check (TYPE_BINFO (path), decl);
}
- mark_used (decl);
-
if (! processing_template_decl)
decl = convert_from_reference (decl);
}
diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog
index f017168..6b59e6a 100644
--- a/gcc/testsuite/ChangeLog
+++ b/gcc/testsuite/ChangeLog
@@ -1,3 +1,8 @@
+2003-07-28 Jan Hubicka <jh@suse.cz>
+
+ PR c++/11530
+ * g++.dg/opt/call1.C: New test.
+
2003-07-28 Alexandre Oliva <aoliva@redhat.com>
PR c++/11667
diff --git a/gcc/testsuite/g++.dg/opt/call1.C b/gcc/testsuite/g++.dg/opt/call1.C
new file mode 100644
index 0000000..642e024
--- /dev/null
+++ b/gcc/testsuite/g++.dg/opt/call1.C
@@ -0,0 +1,21 @@
+// { dg-options "-O2" }
+
+void a (void (*f)())
+{
+ f();
+}
+
+struct RunState
+{
+ static void runcallback() { }
+ static void wait()
+ {
+ a (runcallback);
+ }
+};
+
+int main()
+{
+ RunState::wait();
+ return 0;
+}