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
e23bd218
Commit
e23bd218
authored
Jan 10, 2002
by
Ira Ruben
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Added __attribute__((deprecated)) patches.
From-SVN: r48743
parent
47073a38
Hide whitespace changes
Inline
Side-by-side
Showing
17 changed files
with
316 additions
and
21 deletions
+316
-21
gcc/attribs.c
+65
-0
gcc/c-decl.c
+31
-2
gcc/c-typeck.c
+7
-0
gcc/cp/call.c
+4
-1
gcc/cp/class.c
+4
-0
gcc/cp/cp-tree.h
+5
-0
gcc/cp/decl.c
+32
-0
gcc/cp/lex.c
+3
-0
gcc/cp/typeck.c
+3
-0
gcc/diagnostic.c
+41
-0
gcc/doc/extend.texi
+85
-16
gcc/doc/invoke.texi
+9
-1
gcc/flags.h
+5
-0
gcc/print-tree.c
+2
-0
gcc/toplev.c
+7
-0
gcc/toplev.h
+1
-0
gcc/tree.h
+12
-1
No files found.
gcc/attribs.c
View file @
e23bd218
...
@@ -82,6 +82,8 @@ static tree handle_no_limit_stack_attribute PARAMS ((tree *, tree, tree, int,
...
@@ -82,6 +82,8 @@ static tree handle_no_limit_stack_attribute PARAMS ((tree *, tree, tree, int,
bool
*
));
bool
*
));
static
tree
handle_pure_attribute
PARAMS
((
tree
*
,
tree
,
tree
,
int
,
static
tree
handle_pure_attribute
PARAMS
((
tree
*
,
tree
,
tree
,
int
,
bool
*
));
bool
*
));
static
tree
handle_deprecated_attribute
PARAMS
((
tree
*
,
tree
,
tree
,
int
,
bool
*
));
static
tree
handle_vector_size_attribute
PARAMS
((
tree
*
,
tree
,
tree
,
int
,
static
tree
handle_vector_size_attribute
PARAMS
((
tree
*
,
tree
,
tree
,
int
,
bool
*
));
bool
*
));
static
tree
vector_size_helper
PARAMS
((
tree
,
tree
));
static
tree
vector_size_helper
PARAMS
((
tree
,
tree
));
...
@@ -138,6 +140,8 @@ static const struct attribute_spec c_common_attribute_table[] =
...
@@ -138,6 +140,8 @@ static const struct attribute_spec c_common_attribute_table[] =
handle_no_limit_stack_attribute
},
handle_no_limit_stack_attribute
},
{
"pure"
,
0
,
0
,
true
,
false
,
false
,
{
"pure"
,
0
,
0
,
true
,
false
,
false
,
handle_pure_attribute
},
handle_pure_attribute
},
{
"deprecated"
,
0
,
0
,
false
,
false
,
false
,
handle_deprecated_attribute
},
{
"vector_size"
,
1
,
1
,
false
,
true
,
false
,
{
"vector_size"
,
1
,
1
,
false
,
true
,
false
,
handle_vector_size_attribute
},
handle_vector_size_attribute
},
{
NULL
,
0
,
0
,
false
,
false
,
false
,
NULL
}
{
NULL
,
0
,
0
,
false
,
false
,
false
,
NULL
}
...
@@ -1131,6 +1135,67 @@ handle_pure_attribute (node, name, args, flags, no_add_attrs)
...
@@ -1131,6 +1135,67 @@ handle_pure_attribute (node, name, args, flags, no_add_attrs)
return
NULL_TREE
;
return
NULL_TREE
;
}
}
/* Handle a "deprecated" attribute; arguments as in
struct attribute_spec.handler. */
static
tree
handle_deprecated_attribute
(
node
,
name
,
args
,
flags
,
no_add_attrs
)
tree
*
node
;
tree
name
;
tree
args
ATTRIBUTE_UNUSED
;
int
flags
;
bool
*
no_add_attrs
;
{
tree
type
=
NULL_TREE
;
int
warn
=
0
;
char
*
what
=
NULL
;
if
(
DECL_P
(
*
node
))
{
tree
decl
=
*
node
;
type
=
TREE_TYPE
(
decl
);
if
(
TREE_CODE
(
decl
)
==
TYPE_DECL
||
TREE_CODE
(
decl
)
==
PARM_DECL
||
TREE_CODE
(
decl
)
==
VAR_DECL
||
TREE_CODE
(
decl
)
==
FUNCTION_DECL
||
TREE_CODE
(
decl
)
==
FIELD_DECL
)
TREE_DEPRECATED
(
decl
)
=
1
;
else
warn
=
1
;
}
else
if
(
TYPE_P
(
*
node
))
{
if
(
!
(
flags
&
(
int
)
ATTR_FLAG_TYPE_IN_PLACE
))
*
node
=
build_type_copy
(
*
node
);
TREE_DEPRECATED
(
*
node
)
=
1
;
type
=
*
node
;
}
else
warn
=
1
;
if
(
warn
)
{
*
no_add_attrs
=
true
;
if
(
type
&&
TYPE_NAME
(
type
))
{
if
(
TREE_CODE
(
TYPE_NAME
(
type
))
==
IDENTIFIER_NODE
)
what
=
IDENTIFIER_POINTER
(
TYPE_NAME
(
*
node
));
else
if
(
TREE_CODE
(
TYPE_NAME
(
type
))
==
TYPE_DECL
&&
DECL_NAME
(
TYPE_NAME
(
type
)))
what
=
IDENTIFIER_POINTER
(
DECL_NAME
(
TYPE_NAME
(
type
)));
}
if
(
what
)
warning
(
"`%s' attribute ignored for `%s'"
,
IDENTIFIER_POINTER
(
name
),
what
);
else
warning
(
"`%s' attribute ignored"
,
IDENTIFIER_POINTER
(
name
));
}
return
NULL_TREE
;
}
/* Handle a "vector_size" attribute; arguments as in
/* Handle a "vector_size" attribute; arguments as in
struct attribute_spec.handler. */
struct attribute_spec.handler. */
...
...
gcc/c-decl.c
View file @
e23bd218
...
@@ -439,6 +439,18 @@ int warn_multichar = 1;
...
@@ -439,6 +439,18 @@ int warn_multichar = 1;
#endif
#endif
int
dollars_in_ident
=
DOLLARS_IN_IDENTIFIERS
;
int
dollars_in_ident
=
DOLLARS_IN_IDENTIFIERS
;
/* States indicating how grokdeclarator() should handle declspecs marked
with __attribute__((deprecated)). An object declared as
__attribute__((deprecated)) suppresses warnings of uses of other
deprecated items. */
enum
deprecated_states
{
DEPRECATED_NORMAL
,
DEPRECATED_SUPPRESS
};
static
enum
deprecated_states
deprecated_state
=
DEPRECATED_NORMAL
;
/* Decode the string P as a language-specific option for C.
/* Decode the string P as a language-specific option for C.
Return the number of strings consumed. Should not complain
Return the number of strings consumed. Should not complain
if it does not recognise the option. */
if it does not recognise the option. */
...
@@ -3420,9 +3432,18 @@ start_decl (declarator, declspecs, initialized, attributes)
...
@@ -3420,9 +3432,18 @@ start_decl (declarator, declspecs, initialized, attributes)
int
initialized
;
int
initialized
;
tree
attributes
;
tree
attributes
;
{
{
tree
decl
=
grokdeclarator
(
declarator
,
declspecs
,
tree
decl
;
NORMAL
,
initialized
);
tree
tem
;
tree
tem
;
/* An object declared as __attribute__((deprecated)) suppresses
warnings of uses of other deprecated items. */
if
(
lookup_attribute
(
"deprecated"
,
attributes
))
deprecated_state
=
DEPRECATED_SUPPRESS
;
decl
=
grokdeclarator
(
declarator
,
declspecs
,
NORMAL
,
initialized
);
deprecated_state
=
DEPRECATED_NORMAL
;
if
(
warn_main
>
0
&&
TREE_CODE
(
decl
)
!=
FUNCTION_DECL
if
(
warn_main
>
0
&&
TREE_CODE
(
decl
)
!=
FUNCTION_DECL
&&
MAIN_NAME_P
(
DECL_NAME
(
decl
)))
&&
MAIN_NAME_P
(
DECL_NAME
(
decl
)))
...
@@ -4091,6 +4112,14 @@ grokdeclarator (declarator, declspecs, decl_context, initialized)
...
@@ -4091,6 +4112,14 @@ grokdeclarator (declarator, declspecs, decl_context, initialized)
{
{
tree
id
=
TREE_VALUE
(
spec
);
tree
id
=
TREE_VALUE
(
spec
);
/* If the entire declaration is itself tagged as deprecated then
suppress reports of deprecated items. */
if
(
id
&&
TREE_DEPRECATED
(
id
))
{
if
(
deprecated_state
!=
DEPRECATED_SUPPRESS
)
warn_deprecated_use
(
id
);
}
if
(
id
==
ridpointers
[(
int
)
RID_INT
])
if
(
id
==
ridpointers
[(
int
)
RID_INT
])
explicit_int
=
1
;
explicit_int
=
1
;
if
(
id
==
ridpointers
[(
int
)
RID_CHAR
])
if
(
id
==
ridpointers
[(
int
)
RID_CHAR
])
...
...
gcc/c-typeck.c
View file @
e23bd218
...
@@ -1199,6 +1199,10 @@ build_component_ref (datum, component)
...
@@ -1199,6 +1199,10 @@ build_component_ref (datum, component)
TREE_READONLY
(
ref
)
=
1
;
TREE_READONLY
(
ref
)
=
1
;
if
(
TREE_THIS_VOLATILE
(
datum
)
||
TREE_THIS_VOLATILE
(
subdatum
))
if
(
TREE_THIS_VOLATILE
(
datum
)
||
TREE_THIS_VOLATILE
(
subdatum
))
TREE_THIS_VOLATILE
(
ref
)
=
1
;
TREE_THIS_VOLATILE
(
ref
)
=
1
;
if
(
TREE_DEPRECATED
(
subdatum
))
warn_deprecated_use
(
subdatum
);
datum
=
ref
;
datum
=
ref
;
}
}
...
@@ -1415,6 +1419,9 @@ build_external_ref (id, fun)
...
@@ -1415,6 +1419,9 @@ build_external_ref (id, fun)
tree
decl
=
lookup_name
(
id
);
tree
decl
=
lookup_name
(
id
);
tree
objc_ivar
=
lookup_objc_ivar
(
id
);
tree
objc_ivar
=
lookup_objc_ivar
(
id
);
if
(
decl
&&
TREE_DEPRECATED
(
decl
))
warn_deprecated_use
(
decl
);
if
(
!
decl
||
decl
==
error_mark_node
||
C_DECL_ANTICIPATED
(
decl
))
if
(
!
decl
||
decl
==
error_mark_node
||
C_DECL_ANTICIPATED
(
decl
))
{
{
if
(
objc_ivar
)
if
(
objc_ivar
)
...
...
gcc/cp/call.c
View file @
e23bd218
...
@@ -407,7 +407,10 @@ build_call (function, parms)
...
@@ -407,7 +407,10 @@ build_call (function, parms)
throw without being declared throw(). */
throw without being declared throw(). */
nothrow
=
((
decl
&&
TREE_NOTHROW
(
decl
))
nothrow
=
((
decl
&&
TREE_NOTHROW
(
decl
))
||
TYPE_NOTHROW_P
(
TREE_TYPE
(
TREE_TYPE
(
function
))));
||
TYPE_NOTHROW_P
(
TREE_TYPE
(
TREE_TYPE
(
function
))));
if
(
decl
&&
TREE_DEPRECATED
(
decl
))
warn_deprecated_use
(
decl
);
if
(
decl
&&
DECL_CONSTRUCTOR_P
(
decl
))
if
(
decl
&&
DECL_CONSTRUCTOR_P
(
decl
))
is_constructor
=
1
;
is_constructor
=
1
;
...
...
gcc/cp/class.c
View file @
e23bd218
...
@@ -2926,6 +2926,8 @@ add_implicitly_declared_members (t, cant_have_default_ctor,
...
@@ -2926,6 +2926,8 @@ add_implicitly_declared_members (t, cant_have_default_ctor,
tree
virtual_dtor
=
NULL_TREE
;
tree
virtual_dtor
=
NULL_TREE
;
tree
*
f
;
tree
*
f
;
++
adding_implicit_members
;
/* Destructor. */
/* Destructor. */
if
(
TYPE_HAS_NONTRIVIAL_DESTRUCTOR
(
t
)
&&
!
TYPE_HAS_DESTRUCTOR
(
t
))
if
(
TYPE_HAS_NONTRIVIAL_DESTRUCTOR
(
t
)
&&
!
TYPE_HAS_DESTRUCTOR
(
t
))
{
{
...
@@ -2985,6 +2987,8 @@ add_implicitly_declared_members (t, cant_have_default_ctor,
...
@@ -2985,6 +2987,8 @@ add_implicitly_declared_members (t, cant_have_default_ctor,
*
f
=
TYPE_METHODS
(
t
);
*
f
=
TYPE_METHODS
(
t
);
TYPE_METHODS
(
t
)
=
implicit_fns
;
TYPE_METHODS
(
t
)
=
implicit_fns
;
--
adding_implicit_members
;
return
virtual_dtor
;
return
virtual_dtor
;
}
}
...
...
gcc/cp/cp-tree.h
View file @
e23bd218
...
@@ -3108,6 +3108,11 @@ extern int warn_overloaded_virtual;
...
@@ -3108,6 +3108,11 @@ extern int warn_overloaded_virtual;
/* Nonzero means warn about use of multicharacter literals. */
/* Nonzero means warn about use of multicharacter literals. */
extern
int
warn_multichar
;
extern
int
warn_multichar
;
/* Set by add_implicitly_declared_members() to keep those members from
being flagged as deprecated or reported as using deprecated
types. */
extern
int
adding_implicit_members
;
/* Non-zero means warn if a non-templatized friend function is
/* Non-zero means warn if a non-templatized friend function is
declared in a templatized class. This behavior is warned about with
declared in a templatized class. This behavior is warned about with
flag_guiding_decls in do_friend. */
flag_guiding_decls in do_friend. */
...
...
gcc/cp/decl.c
View file @
e23bd218
...
@@ -302,6 +302,23 @@ tree anonymous_namespace_name;
...
@@ -302,6 +302,23 @@ tree anonymous_namespace_name;
(Zero if we are at namespace scope, one inside the body of a
(Zero if we are at namespace scope, one inside the body of a
function, two inside the body of a function in a local class, etc.) */
function, two inside the body of a function in a local class, etc.) */
int
function_depth
;
int
function_depth
;
/* States indicating how grokdeclarator() should handle declspecs marked
with __attribute__((deprecated)). An object declared as
__attribute__((deprecated)) suppresses warnings of uses of other
deprecated items. */
enum
deprecated_states
{
DEPRECATED_NORMAL
,
DEPRECATED_SUPPRESS
};
static
enum
deprecated_states
deprecated_state
=
DEPRECATED_NORMAL
;
/* Set by add_implicitly_declared_members() to keep those members from
being flagged as deprecated or reported as using deprecated
types. */
int
adding_implicit_members
=
0
;
/* For each binding contour we allocate a binding_level structure
/* For each binding contour we allocate a binding_level structure
which records the names defined in that contour.
which records the names defined in that contour.
...
@@ -7161,11 +7178,18 @@ start_decl (declarator, declspecs, initialized, attributes, prefix_attributes)
...
@@ -7161,11 +7178,18 @@ start_decl (declarator, declspecs, initialized, attributes, prefix_attributes)
used_extern_spec
=
1
;
used_extern_spec
=
1
;
}
}
/* An object declared as __attribute__((deprecated)) suppresses
warnings of uses of other deprecated items. */
if
(
lookup_attribute
(
"deprecated"
,
attributes
))
deprecated_state
=
DEPRECATED_SUPPRESS
;
attributes
=
chainon
(
attributes
,
prefix_attributes
);
attributes
=
chainon
(
attributes
,
prefix_attributes
);
decl
=
grokdeclarator
(
declarator
,
declspecs
,
NORMAL
,
initialized
,
decl
=
grokdeclarator
(
declarator
,
declspecs
,
NORMAL
,
initialized
,
&
attributes
);
&
attributes
);
deprecated_state
=
DEPRECATED_NORMAL
;
if
(
decl
==
NULL_TREE
||
TREE_CODE
(
decl
)
==
VOID_TYPE
)
if
(
decl
==
NULL_TREE
||
TREE_CODE
(
decl
)
==
VOID_TYPE
)
return
NULL_TREE
;
return
NULL_TREE
;
...
@@ -9992,6 +10016,14 @@ grokdeclarator (declarator, declspecs, decl_context, initialized, attrlist)
...
@@ -9992,6 +10016,14 @@ grokdeclarator (declarator, declspecs, decl_context, initialized, attrlist)
id
=
TREE_VALUE
(
spec
);
id
=
TREE_VALUE
(
spec
);
/* If the entire declaration is itself tagged as deprecated then
suppress reports of deprecated items. */
if
(
!
adding_implicit_members
&&
id
&&
TREE_DEPRECATED
(
id
))
{
if
(
deprecated_state
!=
DEPRECATED_SUPPRESS
)
warn_deprecated_use
(
id
);
}
if
(
TREE_CODE
(
id
)
==
IDENTIFIER_NODE
)
if
(
TREE_CODE
(
id
)
==
IDENTIFIER_NODE
)
{
{
if
(
id
==
ridpointers
[(
int
)
RID_INT
]
if
(
id
==
ridpointers
[(
int
)
RID_INT
]
...
...
gcc/cp/lex.c
View file @
e23bd218
...
@@ -1215,6 +1215,9 @@ do_identifier (token, parsing, args)
...
@@ -1215,6 +1215,9 @@ do_identifier (token, parsing, args)
else
else
id
=
lastiddecl
;
id
=
lastiddecl
;
if
(
lexing
&&
id
&&
TREE_DEPRECATED
(
id
))
warn_deprecated_use
(
id
);
/* Do Koenig lookup if appropriate (inside templates we build lookup
/* Do Koenig lookup if appropriate (inside templates we build lookup
expressions instead).
expressions instead).
...
...
gcc/cp/typeck.c
View file @
e23bd218
...
@@ -2199,6 +2199,9 @@ build_component_ref (datum, component, basetype_path, protect)
...
@@ -2199,6 +2199,9 @@ build_component_ref (datum, component, basetype_path, protect)
}
}
}
}
if
(
TREE_DEPRECATED
(
field
))
warn_deprecated_use
(
field
);
/* See if we have to do any conversions so that we pick up the field from the
/* See if we have to do any conversions so that we pick up the field from the
right context. */
right context. */
if
(
DECL_FIELD_CONTEXT
(
field
)
!=
basetype
)
if
(
DECL_FIELD_CONTEXT
(
field
)
!=
basetype
)
...
...
gcc/diagnostic.c
View file @
e23bd218
...
@@ -1520,3 +1520,44 @@ default_diagnostic_finalizer (buffer, dc)
...
@@ -1520,3 +1520,44 @@ default_diagnostic_finalizer (buffer, dc)
{
{
output_destroy_prefix
(
buffer
);
output_destroy_prefix
(
buffer
);
}
}
void
warn_deprecated_use
(
node
)
tree
node
;
{
if
(
node
&&
warn_deprecated_decl
)
if
(
DECL_P
(
node
))
{
warning
(
"`%s' is deprecated (declared at %s:%d)"
,
IDENTIFIER_POINTER
(
DECL_NAME
(
node
)),
DECL_SOURCE_FILE
(
node
),
DECL_SOURCE_LINE
(
node
));
}
else
if
(
TYPE_P
(
node
))
{
char
*
what
=
NULL
;
tree
decl
=
TYPE_STUB_DECL
(
node
);
if
(
TREE_CODE
(
TYPE_NAME
(
node
))
==
IDENTIFIER_NODE
)
what
=
IDENTIFIER_POINTER
(
TYPE_NAME
(
node
));
else
if
(
TREE_CODE
(
TYPE_NAME
(
node
))
==
TYPE_DECL
&&
DECL_NAME
(
TYPE_NAME
(
node
)))
what
=
IDENTIFIER_POINTER
(
DECL_NAME
(
TYPE_NAME
(
node
)));
if
(
what
)
{
if
(
decl
)
warning
(
"`%s' is deprecated (declared at %s:%d)"
,
what
,
DECL_SOURCE_FILE
(
decl
),
DECL_SOURCE_LINE
(
decl
));
else
warning
(
"`%s' is deprecated"
,
what
);
}
else
{
if
(
decl
)
warning
(
"type is deprecated (declared at %s:%d)"
,
DECL_SOURCE_FILE
(
decl
),
DECL_SOURCE_LINE
(
decl
));
else
warning
(
"type is deprecated"
);
}
}
}
gcc/doc/extend.texi
View file @
e23bd218
...
@@ -1882,11 +1882,11 @@ attributes are currently defined for functions on all targets:
...
@@ -1882,11 +1882,11 @@ attributes are currently defined for functions on all targets:
@
code
{
noreturn
},
@
code
{
noinline
},
@
code
{
pure
},
@
code
{
const
},
@
code
{
noreturn
},
@
code
{
noinline
},
@
code
{
pure
},
@
code
{
const
},
@
code
{
format
},
@
code
{
format_arg
},
@
code
{
no_instrument_function
},
@
code
{
format
},
@
code
{
format_arg
},
@
code
{
no_instrument_function
},
@
code
{
section
},
@
code
{
constructor
},
@
code
{
destructor
},
@
code
{
used
},
@
code
{
section
},
@
code
{
constructor
},
@
code
{
destructor
},
@
code
{
used
},
@
code
{
unused
},
@
code
{
weak
},
@
code
{
malloc
},
and
@
code
{
alias
}.
Several
@
code
{
unused
},
@
code
{
deprecated
},
@
code
{
weak
},
@
code
{
malloc
},
and
other
attributes
are
defined
for
functions
on
particular
target
systems
.
@
code
{
alias
}.
Several
other
attributes
are
defined
for
functions
on
Other
attributes
,
including
@
code
{
section
}
are
supported
for
variables
particular
target
systems
.
Other
attributes
,
including
@
code
{
section
}
declarations
(@
pxref
{
Variable
Attributes
})
and
for
types
(@
pxref
{
Type
are
supported
for
variables
declarations
(@
pxref
{
Variable
Attributes
})
Attributes
}).
and
for
types
(@
pxref
{
Type
Attributes
}).
You
may
also
specify
attributes
with
@
samp
{
__
}
preceding
and
following
You
may
also
specify
attributes
with
@
samp
{
__
}
preceding
and
following
each
keyword
.
This
allows
you
to
use
them
in
header
files
without
each
keyword
.
This
allows
you
to
use
them
in
header
files
without
...
@@ -2147,6 +2147,27 @@ for the function even if it appears that the function is not referenced.
...
@@ -2147,6 +2147,27 @@ for the function even if it appears that the function is not referenced.
This
is
useful
,
for
example
,
when
the
function
is
referenced
only
in
This
is
useful
,
for
example
,
when
the
function
is
referenced
only
in
inline
assembly
.
inline
assembly
.
@
cindex
@
code
{
deprecated
}
attribute
.
@
item
deprecated
The
@
code
{
deprecated
}
attribute
results
in
a
warning
if
the
function
is
used
anywhere
in
the
source
file
.
This
is
useful
when
identifying
functions
that
are
expected
to
be
removed
in
a
future
version
of
a
program
.
The
warning
also
includes
the
location
of
the
declaration
of
the
deprecated
function
,
to
enable
users
to
easily
find
further
information
about
why
the
function
is
deprecated
,
or
what
they
should
do
instead
.
Note
that
the
warnings
only
occurs
for
uses
:
@
smallexample
int
old_fn
()
__attribute__
((
deprecated
));
int
old_fn
();
int
(*
fn_ptr
)()
=
old_fn
;
@
end
smallexample
results
in
a
warning
on
line
3
but
not
line
2.
The
@
code
{
deprecated
}
attribute
can
also
be
used
for
variables
and
types
(@
pxref
{
Variable
Attributes
},
@
pxref
{
Type
Attributes
}.)
@
item
weak
@
item
weak
@
cindex
@
code
{
weak
}
attribute
@
cindex
@
code
{
weak
}
attribute
The
@
code
{
weak
}
attribute
causes
the
declaration
to
be
emitted
as
a
weak
The
@
code
{
weak
}
attribute
causes
the
declaration
to
be
emitted
as
a
weak
...
@@ -2760,15 +2781,15 @@ section.
...
@@ -2760,15 +2781,15 @@ section.
The
keyword
@
code
{
__attribute__
}
allows
you
to
specify
special
The
keyword
@
code
{
__attribute__
}
allows
you
to
specify
special
attributes
of
variables
or
structure
fields
.
This
keyword
is
followed
attributes
of
variables
or
structure
fields
.
This
keyword
is
followed
by
an
attribute
specification
inside
double
parentheses
.
Nine
by
an
attribute
specification
inside
double
parentheses
.
Ten
attributes
are
currently
defined
for
variables
:
@
code
{
aligned
},
attributes
are
currently
defined
for
variables
:
@
code
{
aligned
},
@
code
{
mode
},
@
code
{
nocommon
},
@
code
{
packed
},
@
code
{
section
},
@
code
{
mode
},
@
code
{
nocommon
},
@
code
{
packed
},
@
code
{
section
},
@
code
{
transparent_union
},
@
code
{
unused
},
@
code
{
vector_size
},
and
@
code
{
transparent_union
},
@
code
{
unused
},
@
code
{
deprecated
},
@
code
{
weak
}.
Some
other
attributes
are
defined
for
variables
on
@
code
{
vector_size
},
and
@
code
{
weak
}.
Some
other
attributes
are
defined
particular
target
systems
.
Other
attributes
are
available
for
functions
for
variables
on
particular
target
systems
.
Other
attributes
are
(@
pxref
{
Function
Attributes
})
and
for
types
(@
pxref
{
Type
Attributes
}).
available
for
functions
(@
pxref
{
Function
Attributes
})
and
for
types
Other
front
ends
might
define
more
attributes
(@
pxref
{
C
++
(@
pxref
{
Type
Attributes
}).
Other
front
ends
might
define
more
Extensions
,,
Extensions
to
the
C
++
Language
}).
attributes
(@
pxref
{
C
++
Extensions
,,
Extensions
to
the
C
++
Language
}).
You
may
also
specify
attributes
with
@
samp
{
__
}
preceding
and
following
You
may
also
specify
attributes
with
@
samp
{
__
}
preceding
and
following
each
keyword
.
This
allows
you
to
use
them
in
header
files
without
each
keyword
.
This
allows
you
to
use
them
in
header
files
without
...
@@ -2970,6 +2991,26 @@ This attribute, attached to a variable, means that the variable is meant
...
@@ -2970,6 +2991,26 @@ This attribute, attached to a variable, means that the variable is meant
to be possibly unused. GCC will not produce a warning for this
to be possibly unused. GCC will not produce a warning for this
variable.
variable.
@item deprecated
The @code{deprecated} attribute results in a warning if the variable
is used anywhere in the source file. This is useful when identifying
variables that are expected to be removed in a future version of a
program. The warning also includes the location of the declaration
of the deprecated variable, to enable users to easily find further
information about why the variable is deprecated, or what they should
do instead. Note that the warnings only occurs for uses:
@smallexample
extern int old_var __attribute__ ((deprecated));
extern int old_var;
int new_fn () @{ return old_var; @}
@end smallexample
results in a warning on line 3 but not line 2.
The @code{deprecated} attribute can also be used for functions and
types (@pxref{Function Attributes}, @pxref{Type Attributes}.)
@item vector_size (@var{bytes})
@item vector_size (@var{bytes})
This attribute specifies the vector size for the variable, measured in
This attribute specifies the vector size for the variable, measured in
bytes. For example, the declaration:
bytes. For example, the declaration:
...
@@ -3029,10 +3070,10 @@ packed))}.
...
@@ -3029,10 +3070,10 @@ packed))}.
The keyword @code{__attribute__} allows you to specify special
The keyword @code{__attribute__} allows you to specify special
attributes of @code{struct} and @code{union} types when you define such
attributes of @code{struct} and @code{union} types when you define such
types. This keyword is followed by an attribute specification inside
types. This keyword is followed by an attribute specification inside
double parentheses. F
our
attributes are currently defined for types:
double parentheses. F
ive
attributes are currently defined for types:
@code{aligned}, @code{packed}, @code{transparent_union},
and @code{unused}.
@code{aligned}, @code{packed}, @code{transparent_union},
@code{unused},
Other attributes are defined for functions (@pxref{Function Attributes}) and
and @code{deprecated}. Other attributes are defined for functions
for variables (@pxref{Variable Attributes}).
(@pxref{Function Attributes}) and
for variables (@pxref{Variable Attributes}).
You may also specify any one of these attributes with @samp{__}
You may also specify any one of these attributes with @samp{__}
preceding and following its keyword. This allows you to use these
preceding and following its keyword. This allows you to use these
...
@@ -3215,6 +3256,34 @@ the case with lock or thread classes, which are usually defined and then
...
@@ -3215,6 +3256,34 @@ the case with lock or thread classes, which are usually defined and then
not
referenced
,
but
contain
constructors
and
destructors
that
have
not
referenced
,
but
contain
constructors
and
destructors
that
have
nontrivial
bookkeeping
functions
.
nontrivial
bookkeeping
functions
.
@
item
deprecated
The
@
code
{
deprecated
}
attribute
results
in
a
warning
if
the
type
is
used
anywhere
in
the
source
file
.
This
is
useful
when
identifying
types
that
are
expected
to
be
removed
in
a
future
version
of
a
program
.
If
possible
,
the
warning
also
includes
the
location
of
the
declaration
of
the
deprecated
type
,
to
enable
users
to
easily
find
further
information
about
why
the
type
is
deprecated
,
or
what
they
should
do
instead
.
Note
that
the
warnings
only
occur
for
uses
and
then
only
if
the
type
is
being
applied
to
a
identifier
that
itself
is
not
being
declared
as
deprecated
.
@
smallexample
typedef
int
T1
__attribute__
((
deprecated
));
T1
x
;
typedef
T1
T2
;
T2
y
;
typedef
T1
T3
__attribute__
((
deprecated
));
T3
z
__attribute__
((
deprecated
));
@
end
smallexample
results
in
a
warning
on
line
2
and
3
but
not
lines
4
,
5
,
or
6.
No
warning
is
issued
for
line
4
because
T2
is
not
explicitly
deprecated
.
Line
5
has
no
warning
because
T3
is
explicitly
deprecated
.
Similarly
for
line
6.
The
@
code
{
deprecated
}
attribute
can
also
be
used
for
functions
and
variables
(@
pxref
{
Function
Attributes
},
@
pxref
{
Variable
Attributes
}.)
@
end
table
@
end
table
To
specify
multiple
attributes
,
separate
them
by
commas
within
the
To
specify
multiple
attributes
,
separate
them
by
commas
within
the
...
...
gcc/doc/invoke.texi
View file @
e23bd218
...
@@ -213,7 +213,8 @@ in the following sections.
...
@@ -213,7 +213,8 @@ in the following sections.
-
fsyntax
-
only
-
pedantic
-
pedantic
-
errors
@
gol
-
fsyntax
-
only
-
pedantic
-
pedantic
-
errors
@
gol
-
w
-
W
-
Wall
-
Waggregate
-
return
@
gol
-
w
-
W
-
Wall
-
Waggregate
-
return
@
gol
-
Wcast
-
align
-
Wcast
-
qual
-
Wchar
-
subscripts
-
Wcomment
@
gol
-
Wcast
-
align
-
Wcast
-
qual
-
Wchar
-
subscripts
-
Wcomment
@
gol
-
Wconversion
-
Wdisabled
-
optimization
-
Wdiv
-
by
-
zero
-
Werror
@
gol
-
Wconversion
-
Wno
-
deprecated
-
declarations
@
gol
-
Wdisabled
-
optimization
-
Wdiv
-
by
-
zero
-
Werror
@
gol
-
Wfloat
-
equal
-
Wformat
-
Wformat
=
2
@
gol
-
Wfloat
-
equal
-
Wformat
-
Wformat
=
2
@
gol
-
Wformat
-
nonliteral
-
Wformat
-
security
@
gol
-
Wformat
-
nonliteral
-
Wformat
-
security
@
gol
-
Wimplicit
-
Wimplicit
-
int
@
gol
-
Wimplicit
-
Wimplicit
-
int
@
gol
...
@@ -2506,6 +2507,13 @@ case, and some functions for which @code{format} attributes are
...
@@ -2506,6 +2507,13 @@ case, and some functions for which @code{format} attributes are
appropriate
may
not
be
detected
.
This
option
has
no
effect
unless
appropriate
may
not
be
detected
.
This
option
has
no
effect
unless
@
option
{-
Wformat
}
is
enabled
(
possibly
by
@
option
{-
Wall
}).
@
option
{-
Wformat
}
is
enabled
(
possibly
by
@
option
{-
Wall
}).
@
item
-
Wno
-
deprecated
-
declarations
@
opindex
Wno
-
deprecated
-
declarations
Do
not
warn
about
uses
of
functions
,
variables
,
and
types
marked
as
deprecated
by
using
the
@
code
{
deprecated
}
attribute
.
(@
pxref
{
Function
Attributes
},
@
pxref
{
Variable
Attributes
},
@
pxref
{
Type
Attributes
}.)
@
item
-
Wpacked
@
item
-
Wpacked
@
opindex
Wpacked
@
opindex
Wpacked
Warn
if
a
structure
is
given
the
packed
attribute
,
but
the
packed
Warn
if
a
structure
is
given
the
packed
attribute
,
but
the
packed
...
...
gcc/flags.h
View file @
e23bd218
...
@@ -169,6 +169,11 @@ extern int warn_padded;
...
@@ -169,6 +169,11 @@ extern int warn_padded;
extern
int
warn_disabled_optimization
;
extern
int
warn_disabled_optimization
;
/* Nonzero means warn about uses of __attribute__((deprecated))
declarations. */
extern
int
warn_deprecated_decl
;
/* Nonzero if generating code to do profiling. */
/* Nonzero if generating code to do profiling. */
extern
int
profile_flag
;
extern
int
profile_flag
;
...
...
gcc/print-tree.c
View file @
e23bd218
...
@@ -294,6 +294,8 @@ print_node (file, prefix, node, indent)
...
@@ -294,6 +294,8 @@ print_node (file, prefix, node, indent)
fputs
(
" protected"
,
file
);
fputs
(
" protected"
,
file
);
if
(
TREE_STATIC
(
node
))
if
(
TREE_STATIC
(
node
))
fputs
(
" static"
,
file
);
fputs
(
" static"
,
file
);
if
(
TREE_DEPRECATED
(
node
))
fputs
(
" deprecated"
,
file
);
if
(
TREE_LANG_FLAG_0
(
node
))
if
(
TREE_LANG_FLAG_0
(
node
))
fputs
(
" tree_0"
,
file
);
fputs
(
" tree_0"
,
file
);
if
(
TREE_LANG_FLAG_1
(
node
))
if
(
TREE_LANG_FLAG_1
(
node
))
...
...
gcc/toplev.c
View file @
e23bd218
...
@@ -1464,6 +1464,11 @@ int warn_disabled_optimization;
...
@@ -1464,6 +1464,11 @@ int warn_disabled_optimization;
int
warn_missing_noreturn
;
int
warn_missing_noreturn
;
/* Nonzero means warn about uses of __attribute__((deprecated))
declarations. */
int
warn_deprecated_decl
=
1
;
/* Likewise for -W. */
/* Likewise for -W. */
static
const
lang_independent_options
W_options
[]
=
static
const
lang_independent_options
W_options
[]
=
...
@@ -1502,6 +1507,8 @@ static const lang_independent_options W_options[] =
...
@@ -1502,6 +1507,8 @@ static const lang_independent_options W_options[] =
N_
(
"Warn when padding is required to align struct members"
)
},
N_
(
"Warn when padding is required to align struct members"
)
},
{
"disabled-optimization"
,
&
warn_disabled_optimization
,
1
,
{
"disabled-optimization"
,
&
warn_disabled_optimization
,
1
,
N_
(
"Warn when an optimization pass is disabled"
)
},
N_
(
"Warn when an optimization pass is disabled"
)
},
{
"deprecated-declarations"
,
&
warn_deprecated_decl
,
1
,
N_
(
"Warn about uses of __attribute__((deprecated)) declarations"
)
},
{
"missing-noreturn"
,
&
warn_missing_noreturn
,
1
,
{
"missing-noreturn"
,
&
warn_missing_noreturn
,
1
,
N_
(
"Warn about functions which might be candidates for attribute noreturn"
)
}
N_
(
"Warn about functions which might be candidates for attribute noreturn"
)
}
};
};
...
...
gcc/toplev.h
View file @
e23bd218
...
@@ -87,6 +87,7 @@ extern void error_for_asm PARAMS ((struct rtx_def *,
...
@@ -87,6 +87,7 @@ extern void error_for_asm PARAMS ((struct rtx_def *,
const
char
*
,
...));
const
char
*
,
...));
extern
void
warning_for_asm
PARAMS
((
struct
rtx_def
*
,
extern
void
warning_for_asm
PARAMS
((
struct
rtx_def
*
,
const
char
*
,
...));
const
char
*
,
...));
extern
void
warn_deprecated_use
PARAMS
((
union
tree_node
*
));
extern
int
do_float_handler
PARAMS
((
void
(
*
)
(
PTR
),
PTR
));
extern
int
do_float_handler
PARAMS
((
void
(
*
)
(
PTR
),
PTR
));
#ifdef BUFSIZ
#ifdef BUFSIZ
...
...
gcc/tree.h
View file @
e23bd218
...
@@ -139,6 +139,7 @@ struct tree_common
...
@@ -139,6 +139,7 @@ struct tree_common
unsigned
private_flag
:
1
;
unsigned
private_flag
:
1
;
unsigned
protected_flag
:
1
;
unsigned
protected_flag
:
1
;
unsigned
bounded_flag
:
1
;
unsigned
bounded_flag
:
1
;
unsigned
deprecated_flag
:
1
;
unsigned
lang_flag_0
:
1
;
unsigned
lang_flag_0
:
1
;
unsigned
lang_flag_1
:
1
;
unsigned
lang_flag_1
:
1
;
...
@@ -260,7 +261,13 @@ struct tree_common
...
@@ -260,7 +261,13 @@ struct tree_common
expressions, VAR_DECL, PARM_DECL, FIELD_DECL, FUNCTION_DECL,
expressions, VAR_DECL, PARM_DECL, FIELD_DECL, FUNCTION_DECL,
IDENTIFIER_NODE
IDENTIFIER_NODE
TYPE_BOUNDED in
TYPE_BOUNDED in
..._TYPE */
..._TYPE
deprecated_flag:
TREE_DEPRECATED in
..._DECL
*/
/* Define accessors for the fields that all tree nodes have
/* Define accessors for the fields that all tree nodes have
(though some fields are not used for all kinds of nodes). */
(though some fields are not used for all kinds of nodes). */
...
@@ -651,6 +658,10 @@ extern void tree_class_check_failed PARAMS ((const tree, int,
...
@@ -651,6 +658,10 @@ extern void tree_class_check_failed PARAMS ((const tree, int,
#define TREE_BOUNDED(NODE) ((NODE)->common.bounded_flag)
#define TREE_BOUNDED(NODE) ((NODE)->common.bounded_flag)
/* Nonzero in a IDENTIFIER_NODE if the use of the name is defined as a
deprecated feature by __attribute__((deprecated)). */
#define TREE_DEPRECATED(NODE) ((NODE)->common.deprecated_flag)
/* These flags are available for each language front end to use internally. */
/* These flags are available for each language front end to use internally. */
#define TREE_LANG_FLAG_0(NODE) ((NODE)->common.lang_flag_0)
#define TREE_LANG_FLAG_0(NODE) ((NODE)->common.lang_flag_0)
#define TREE_LANG_FLAG_1(NODE) ((NODE)->common.lang_flag_1)
#define TREE_LANG_FLAG_1(NODE) ((NODE)->common.lang_flag_1)
...
...
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