[llvm-commits] [llvm-gcc-4.2] r70874 - /llvm-gcc-4.2/trunk/gcc/c-common.c
Duncan Sands
baldrick at free.fr
Mon May 4 09:45:55 PDT 2009
Author: baldrick
Date: Mon May 4 11:45:55 2009
New Revision: 70874
URL: http://llvm.org/viewvc/llvm-project?rev=70874&view=rev
Log:
In C-like languages, marking a function pure/const
means it cannot throw an exception. This is not
the case in other languages such as Ada. Make this
explicit by having pure/const imply nothrow for C
and friends.
Modified:
llvm-gcc-4.2/trunk/gcc/c-common.c
Modified: llvm-gcc-4.2/trunk/gcc/c-common.c
URL: http://llvm.org/viewvc/llvm-project/llvm-gcc-4.2/trunk/gcc/c-common.c?rev=70874&r1=70873&r2=70874&view=diff
==============================================================================
--- llvm-gcc-4.2/trunk/gcc/c-common.c (original)
+++ llvm-gcc-4.2/trunk/gcc/c-common.c Mon May 4 11:45:55 2009
@@ -4739,9 +4739,12 @@
tree type = TREE_TYPE (*node);
/* See FIXME comment on noreturn in c_common_attribute_table. */
- if (TREE_CODE (*node) == FUNCTION_DECL)
+ /* LLVM LOCAL begin */
+ if (TREE_CODE (*node) == FUNCTION_DECL) {
TREE_READONLY (*node) = 1;
- else if (TREE_CODE (type) == POINTER_TYPE
+ TREE_NOTHROW (*node) = 1;
+ } else if (TREE_CODE (type) == POINTER_TYPE
+ /* LLVM LOCAL end */
&& TREE_CODE (TREE_TYPE (type)) == FUNCTION_TYPE)
TREE_TYPE (*node)
= build_pointer_type
@@ -5573,10 +5576,13 @@
handle_pure_attribute (tree *node, tree name, tree ARG_UNUSED (args),
int ARG_UNUSED (flags), bool *no_add_attrs)
{
- if (TREE_CODE (*node) == FUNCTION_DECL)
+ /* LLVM LOCAL begin */
+ if (TREE_CODE (*node) == FUNCTION_DECL) {
DECL_IS_PURE (*node) = 1;
- /* ??? TODO: Support types. */
- else
+ TREE_NOTHROW (*node) = 1;
+ } else
+ /* LLVM LOCAL end */
+ /* ??? TODO: Support types. */
{
warning (OPT_Wattributes, "%qE attribute ignored", name);
*no_add_attrs = true;
More information about the llvm-commits
mailing list