Skip to content

Commit

Permalink
dom: Silence warnigns from m_dom_extras
Browse files Browse the repository at this point in the history
When exiting in an error condition an output variable
(data) was not set. This results in a warnign from g95
with --enable-debug and gfortran (always). To avoid this
set data="" (for the whole array). This is acheved by
extending the m4 macro TOHW_raise_exception to take a
forth agument (some text to insert before the return
call) and using this to set the value of the returned
(fortran) variable.
  • Loading branch information
andreww committed Jul 6, 2009
1 parent 0b46e2d commit edc2cf0
Show file tree
Hide file tree
Showing 3 changed files with 33 additions and 5 deletions.
3 changes: 3 additions & 0 deletions dom/m_dom_exception.m4
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ include(`m_dom_treewalk.m4')`'dnl
define(`TOHW_m_dom_throw_error',`dnl
dnl 1 is numerical code
dnl 2 is list of things to deallocate
dnl 3 is an optional thing to do before the return
if (getFoX_checks().or.$1<200) then
call throw_exception($1, "m4f_thisfunc", ex)
if (present(ex)) then
Expand All @@ -11,6 +12,8 @@ ifelse($2, `', `',
m4_foreach(`x', `$2', `
if (associated(x)) deallocate(x)
'))`'dnl
ifelse($3, `', `', ` $3
')`'dnl
return
endif
endif
Expand Down
15 changes: 15 additions & 0 deletions dom/m_dom_extras.F90
Original file line number Diff line number Diff line change
Expand Up @@ -268,6 +268,7 @@ subroutine extractDataContentChSca(arg, data, separator, csv, num, iostat, ex)
call throw_exception(FoX_NODE_IS_NULL, "extractDataContentChSca", ex)
if (present(ex)) then
if (inException(ex)) then
data = ""
return
endif
endif
Expand Down Expand Up @@ -459,6 +460,7 @@ subroutine extractDataContentChArr(arg, data, separator, csv, num, iostat, ex)
call throw_exception(FoX_NODE_IS_NULL, "extractDataContentChArr", ex)
if (present(ex)) then
if (inException(ex)) then
data = ""
return
endif
endif
Expand Down Expand Up @@ -650,6 +652,7 @@ subroutine extractDataContentChMat(arg, data, separator, csv, num, iostat, ex)
call throw_exception(FoX_NODE_IS_NULL, "extractDataContentChMat", ex)
if (present(ex)) then
if (inException(ex)) then
data = ""
return
endif
endif
Expand Down Expand Up @@ -913,6 +916,7 @@ subroutine extractDataAttributeChSca(arg, name, data, separator, csv, num, iosta
call throw_exception(FoX_NODE_IS_NULL, "extractDataAttributeChSca", ex)
if (present(ex)) then
if (inException(ex)) then
data = ""
return
endif
endif
Expand All @@ -923,6 +927,7 @@ subroutine extractDataAttributeChSca(arg, name, data, separator, csv, num, iosta
call throw_exception(FoX_INVALID_NODE, "extractDataAttributeChSca", ex)
if (present(ex)) then
if (inException(ex)) then
data = ""
return
endif
endif
Expand Down Expand Up @@ -1188,6 +1193,7 @@ subroutine extractDataAttributeChArr(arg, name, data, separator, csv, num, iosta
call throw_exception(FoX_NODE_IS_NULL, "extractDataAttributeChArr", ex)
if (present(ex)) then
if (inException(ex)) then
data = ""
return
endif
endif
Expand All @@ -1198,6 +1204,7 @@ subroutine extractDataAttributeChArr(arg, name, data, separator, csv, num, iosta
call throw_exception(FoX_INVALID_NODE, "extractDataAttributeChArr", ex)
if (present(ex)) then
if (inException(ex)) then
data = ""
return
endif
endif
Expand Down Expand Up @@ -1463,6 +1470,7 @@ subroutine extractDataAttributeChMat(arg, name, data, separator, csv, num, iosta
call throw_exception(FoX_NODE_IS_NULL, "extractDataAttributeChMat", ex)
if (present(ex)) then
if (inException(ex)) then
data = ""
return
endif
endif
Expand All @@ -1473,6 +1481,7 @@ subroutine extractDataAttributeChMat(arg, name, data, separator, csv, num, iosta
call throw_exception(FoX_INVALID_NODE, "extractDataAttributeChMat", ex)
if (present(ex)) then
if (inException(ex)) then
data = ""
return
endif
endif
Expand Down Expand Up @@ -1750,6 +1759,7 @@ subroutine extractDataAttNSChSca(arg, namespaceURI, localName, data, separator,
call throw_exception(FoX_NODE_IS_NULL, "extractDataAttNSChSca", ex)
if (present(ex)) then
if (inException(ex)) then
data = ""
return
endif
endif
Expand All @@ -1760,6 +1770,7 @@ subroutine extractDataAttNSChSca(arg, namespaceURI, localName, data, separator,
call throw_exception(FoX_INVALID_NODE, "extractDataAttNSChSca", ex)
if (present(ex)) then
if (inException(ex)) then
data = ""
return
endif
endif
Expand Down Expand Up @@ -2039,6 +2050,7 @@ subroutine extractDataAttNSChArr(arg, namespaceURI, localName, data, separator,
call throw_exception(FoX_NODE_IS_NULL, "extractDataAttNSChArr", ex)
if (present(ex)) then
if (inException(ex)) then
data = ""
return
endif
endif
Expand All @@ -2049,6 +2061,7 @@ subroutine extractDataAttNSChArr(arg, namespaceURI, localName, data, separator,
call throw_exception(FoX_INVALID_NODE, "extractDataAttNSChArr", ex)
if (present(ex)) then
if (inException(ex)) then
data = ""
return
endif
endif
Expand Down Expand Up @@ -2328,6 +2341,7 @@ subroutine extractDataAttNSChMat(arg, namespaceURI, localName, data, separator,
call throw_exception(FoX_NODE_IS_NULL, "extractDataAttNSChMat", ex)
if (present(ex)) then
if (inException(ex)) then
data = ""
return
endif
endif
Expand All @@ -2338,6 +2352,7 @@ subroutine extractDataAttNSChMat(arg, namespaceURI, localName, data, separator,
call throw_exception(FoX_INVALID_NODE, "extractDataAttNSChMat", ex)
if (present(ex)) then
if (inException(ex)) then
data = ""
return
endif
endif
Expand Down
20 changes: 15 additions & 5 deletions dom/m_dom_extras.m4
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,9 @@ ifelse(`$1', `Ch', `
dnl

if (.not.associated(arg)) then
TOHW_m_dom_throw_error(FoX_NODE_IS_NULL)
ifelse(`$1', `Ch',
` TOHW_m_dom_throw_error(FoX_NODE_IS_NULL, `', `data = ""')',
` TOHW_m_dom_throw_error(FoX_NODE_IS_NULL)')
endif
ifelse(`$1', `Ch', `dnl
if (present(ex)) then
Expand Down Expand Up @@ -60,9 +62,13 @@ ifelse(dnl
integer, intent(out), optional :: num, iostat
dnl
if (.not.associated(arg)) then
TOHW_m_dom_throw_error(FoX_NODE_IS_NULL)
ifelse(`$1', `Ch',
` TOHW_m_dom_throw_error(FoX_NODE_IS_NULL, `', `data = ""')',
` TOHW_m_dom_throw_error(FoX_NODE_IS_NULL)')
elseif (getNodeType(arg)/=ELEMENT_NODE) then
TOHW_m_dom_throw_error(FoX_INVALID_NODE)
ifelse(`$1', `Ch',
` TOHW_m_dom_throw_error(FoX_INVALID_NODE, `', `data = ""')',
` TOHW_m_dom_throw_error(FoX_INVALID_NODE)')
endif

ifelse(`$1', `Ch', `dnl
Expand Down Expand Up @@ -99,9 +105,13 @@ ifelse(`$1',`Ch', `
integer, intent(out), optional :: num, iostat
dnl
if (.not.associated(arg)) then
TOHW_m_dom_throw_error(FoX_NODE_IS_NULL)
ifelse(`$1', `Ch',
` TOHW_m_dom_throw_error(FoX_NODE_IS_NULL, `', `data = ""')',
` TOHW_m_dom_throw_error(FoX_NODE_IS_NULL)')
elseif (getNodeType(arg)/=ELEMENT_NODE) then
TOHW_m_dom_throw_error(FoX_INVALID_NODE)
ifelse(`$1', `Ch',
` TOHW_m_dom_throw_error(FoX_INVALID_NODE, `', `data = ""')',
` TOHW_m_dom_throw_error(FoX_INVALID_NODE)')
endif

ifelse(`$1', `Ch', `dnl
Expand Down

0 comments on commit edc2cf0

Please sign in to comment.