Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
R
riscv-gcc-1
Overview
Overview
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
lvzhengyang
riscv-gcc-1
Commits
2bfa73e4
Commit
2bfa73e4
authored
Mar 01, 2000
by
Bernd Schmidt
Committed by
Bernd Schmidt
Mar 01, 2000
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Reorganize some warning code
From-SVN: r32282
parent
765a46f9
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
41 additions
and
39 deletions
+41
-39
gcc/cp/ChangeLog
+5
-0
gcc/cp/typeck.c
+36
-39
No files found.
gcc/cp/ChangeLog
View file @
2bfa73e4
2000-03-01 Bernd Schmidt <bernds@cygnus.co.uk>
* typeck.c (maybe_warn_about_returning_address_of_local): Reorganize
to merge reference/pointer code and fix incorrect warnings.
2000-02-29 Jason Merrill <jason@casey.cygnus.com>
* search.c (protected_accessible_p): Use context_for_name_lookup.
...
...
gcc/cp/typeck.c
View file @
2bfa73e4
...
...
@@ -6705,59 +6705,56 @@ maybe_warn_about_returning_address_of_local (retval)
tree
retval
;
{
tree
valtype
=
TREE_TYPE
(
DECL_RESULT
(
current_function_decl
));
tree
whats_returned
=
retval
;
if
(
TREE_CODE
(
valtype
)
==
REFERENCE_TYPE
)
for
(;;
)
{
tree
whats_returned
;
/* Sort through common things to see what it is
we are returning. */
whats_returned
=
retval
;
if
(
TREE_CODE
(
whats_returned
)
==
COMPOUND_EXPR
)
{
whats_returned
=
TREE_OPERAND
(
whats_returned
,
1
);
if
(
TREE_CODE
(
whats_returned
)
==
ADDR_EXPR
)
whats_returned
=
TREE_OPERAND
(
whats_returned
,
0
);
}
while
(
TREE_CODE
(
whats_returned
)
==
CONVERT_EXPR
||
TREE_CODE
(
whats_returned
)
==
NOP_EXPR
)
whats_returned
=
TREE_OPERAND
(
whats_returned
,
1
);
else
if
(
TREE_CODE
(
whats_returned
)
==
CONVERT_EXPR
||
TREE_CODE
(
whats_returned
)
==
NON_LVALUE_EXPR
||
TREE_CODE
(
whats_returned
)
==
NOP_EXPR
)
whats_returned
=
TREE_OPERAND
(
whats_returned
,
0
);
if
(
TREE_CODE
(
whats_returned
)
==
ADDR_EXPR
)
else
break
;
}
if
(
TREE_CODE
(
whats_returned
)
!=
ADDR_EXPR
)
return
;
whats_returned
=
TREE_OPERAND
(
whats_returned
,
0
);
if
(
TREE_CODE
(
valtype
)
==
REFERENCE_TYPE
)
{
if
(
TREE_CODE
(
whats_returned
)
==
AGGR_INIT_EXPR
||
TREE_CODE
(
whats_returned
)
==
TARGET_EXPR
)
{
/* Get the target. */
whats_returned
=
TREE_OPERAND
(
whats_returned
,
0
);
while
(
TREE_CODE
(
whats_returned
)
==
AGGR_INIT_EXPR
||
TREE_CODE
(
whats_returned
)
==
TARGET_EXPR
)
{
/* Get the target. */
whats_returned
=
TREE_OPERAND
(
whats_returned
,
0
);
warning
(
"returning reference to temporary"
);
}
warning
(
"returning reference to temporary"
);
return
;
}
if
(
TREE_CODE
(
whats_returned
)
==
VAR_DECL
&&
DECL_NAME
(
whats_returned
))
&&
DECL_NAME
(
whats_returned
)
&&
TEMP_NAME_P
(
DECL_NAME
(
whats_returned
)))
{
if
(
TEMP_NAME_P
(
DECL_NAME
(
whats_returned
)))
warning
(
"reference to non-lvalue returned"
);
else
if
(
TREE_CODE
(
TREE_TYPE
(
whats_returned
))
!=
REFERENCE_TYPE
&&
DECL_FUNCTION_SCOPE_P
(
whats_returned
)
&&
!
(
TREE_STATIC
(
whats_returned
)
||
TREE_PUBLIC
(
whats_returned
)))
cp_warning_at
(
"reference to local variable `%D' returned"
,
whats_returned
);
warning
(
"reference to non-lvalue returned"
);
return
;
}
}
else
if
(
TREE_CODE
(
retval
)
==
ADDR_EXPR
)
{
tree
whats_returned
=
TREE_OPERAND
(
retval
,
0
);
if
(
TREE_CODE
(
whats_returned
)
==
VAR_DECL
&&
DECL_NAME
(
whats_returned
)
&&
DECL_FUNCTION_SCOPE_P
(
whats_returned
)
&&
!
(
TREE_STATIC
(
whats_returned
)
||
TREE_PUBLIC
(
whats_returned
)))
if
(
TREE_CODE
(
whats_returned
)
==
VAR_DECL
&&
DECL_NAME
(
whats_returned
)
&&
DECL_FUNCTION_SCOPE_P
(
whats_returned
)
&&
!
(
TREE_STATIC
(
whats_returned
)
||
TREE_PUBLIC
(
whats_returned
)))
{
if
(
TREE_CODE
(
valtype
)
==
REFERENCE_TYPE
)
cp_warning_at
(
"reference to local variable `%D' returned"
,
whats_returned
);
else
cp_warning_at
(
"address of local variable `%D' returned"
,
whats_returned
);
return
;
}
}
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment