Re: [PATCH] Fix PR54659, include gmp.h from system.h

2012-12-22 Thread Richard Biener
Gerald Pfeifer  wrote:

>On Fri, 21 Dec 2012, Dominique Dhumieres wrote:
>> I think revision 194665 breaks bootstrap on at least
>x86_64-apple-darwin10:
>
>Same on everything FreeBSD.
>
>PR 55784 - [4.8 regression] declaration of C function 'const char* 
>strsignal(int)' conflicts with /usr/include/string.h:112: error:
>previous 
>declaration

If you cannot sort this out yourself (I suppose somehow gmp.h is pulled in 
configure tests?) consider reverting the patch until I am back after Christmas.

Thanks,
Richard.

>Gerald




Re: [PATCH] Fix PR54659, include gmp.h from system.h

2012-12-22 Thread Andreas Schwab
Richard Biener  writes:

> (I suppose somehow gmp.h is pulled in configure tests?)

AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[
#include "ansidecl.h"
#include "system.h"
#ifdef HAVE_SYS_RESOURCE_H
#include 
#endif
]], [[rlim_t l = 0;]])],[],[AC_DEFINE([rlim_t],[long],
[Define to `long' if  doesn't define.])])

Andreas.

-- 
Andreas Schwab, sch...@linux-m68k.org
GPG Key fingerprint = 58CA 54C7 6D53 942B 1756  01D3 44D5 214B 8276 4ED5
"And now for something completely different."


Re: [PATCH] Fix PR54659, include gmp.h from system.h

2012-12-22 Thread Richard Biener
On Sat, Dec 22, 2012 at 10:49 AM, Andreas Schwab  wrote:
> Richard Biener  writes:
>
>> (I suppose somehow gmp.h is pulled in configure tests?)
>
> AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[
> #include "ansidecl.h"
> #include "system.h"
> #ifdef HAVE_SYS_RESOURCE_H
> #include 
> #endif
> ]], [[rlim_t l = 0;]])],[],[AC_DEFINE([rlim_t],[long],
> [Define to `long' if  doesn't define.])])

Huh - looks at least bogus to not include config.h here, no?  Oh...
that isn't there.
Thus, it looks bogus to include system.h here.  Why's that done anyway?

Richard.


Re: [PATCH] Fix PR54659, include gmp.h from system.h

2012-12-22 Thread Dominique Dhumieres
The following patch allowed me to proceed for c,c++,lto,fortran,ada,objc,obj-c++
up to libada which has the same problem:

--- ../_clean/gcc/configure 2012-12-20 17:19:54.0 +0100
+++ ../p_work/gcc/configure 2012-12-21 23:44:46.0 +0100
@@ -10321,9 +10321,9 @@ $as_echo "#define HAVE_LANGINFO_CODESET 
 
 # We will need to find libiberty.h and ansidecl.h
 saved_CFLAGS="$CFLAGS"
-CFLAGS="$CFLAGS -I${srcdir} -I${srcdir}/../include"
+CFLAGS="$CFLAGS -I${srcdir} -I${srcdir}/../include $GMPINC"
 saved_CXXFLAGS="$CXXFLAGS"
-CXXFLAGS="$CXXFLAGS -I${srcdir} -I${srcdir}/../include"
+CXXFLAGS="$CXXFLAGS -I${srcdir} -I${srcdir}/../include $GMPINC"
 for ac_func in getenv atol asprintf sbrk abort atof getcwd getwd \
strsignal strstr stpcpy strverscmp \
errno snprintf vsnprintf vasprintf malloc realloc calloc \

Dominique


Re: [PATCH] Fix PR54659, include gmp.h from system.h

2012-12-22 Thread Andreas Schwab
Richard Biener  writes:

> On Sat, Dec 22, 2012 at 10:49 AM, Andreas Schwab  
> wrote:
>> Richard Biener  writes:
>>
>>> (I suppose somehow gmp.h is pulled in configure tests?)
>>
>> AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[
>> #include "ansidecl.h"
>> #include "system.h"
>> #ifdef HAVE_SYS_RESOURCE_H
>> #include 
>> #endif
>> ]], [[rlim_t l = 0;]])],[],[AC_DEFINE([rlim_t],[long],
>> [Define to `long' if  doesn't define.])])
>
> Huh - looks at least bogus to not include config.h here, no?

config.h uses auto-host.h which doesn't exist yet, it's created by
configure.  All already known config defs are set in conftest.c (see
config.log).

Andreas.

-- 
Andreas Schwab, sch...@linux-m68k.org
GPG Key fingerprint = 58CA 54C7 6D53 942B 1756  01D3 44D5 214B 8276 4ED5
"And now for something completely different."


Re: [PATCH] Fix PR54659, include gmp.h from system.h

2012-12-22 Thread Richard Sandiford
domi...@lps.ens.fr (Dominique Dhumieres) writes:
> The following patch allowed me to proceed for 
> c,c++,lto,fortran,ada,objc,obj-c++
> up to libada which has the same problem:
>
> --- ../_clean/gcc/configure   2012-12-20 17:19:54.0 +0100
> +++ ../p_work/gcc/configure   2012-12-21 23:44:46.0 +0100
> @@ -10321,9 +10321,9 @@ $as_echo "#define HAVE_LANGINFO_CODESET 
>  
>  # We will need to find libiberty.h and ansidecl.h
>  saved_CFLAGS="$CFLAGS"
> -CFLAGS="$CFLAGS -I${srcdir} -I${srcdir}/../include"
> +CFLAGS="$CFLAGS -I${srcdir} -I${srcdir}/../include $GMPINC"
>  saved_CXXFLAGS="$CXXFLAGS"
> -CXXFLAGS="$CXXFLAGS -I${srcdir} -I${srcdir}/../include"
> +CXXFLAGS="$CXXFLAGS -I${srcdir} -I${srcdir}/../include $GMPINC"
>  for ac_func in getenv atol asprintf sbrk abort atof getcwd getwd \
>   strsignal strstr stpcpy strverscmp \
>   errno snprintf vsnprintf vasprintf malloc realloc calloc \

Yeah, just came up with the same fix here (plain x86_64-linux-gnu,
but I don't have a gmp dev package installed and rely on --with-gmp).
Worked for me too.

Richard


Re: [PATCH] PR c++/52343 - error with alias template as template template argument

2012-12-22 Thread Dodji Seketeli
Gabriel Dos Reis  writes:

> Thank you very much for the explanation; your previous message
> makes sense to me now.

You are welcome.

> The question I have is why are we using TREE_TYPE of a TEMPLATE_DECL
> to represent the current instantiation of a template alias?

My understanding is that in the instantiation at line 7 below

 1  template
 2  using A = int;
 3  
 4  template class>
 5  struct B {};
 6  
 7  B b;

check_instantiated_arg is not looking at the current instantiation of
the template alias A.  Rather, it is looking at the template-name A
(which resolved, IMHO rightfully, to the decl for A which happens to be
a TEMPLATE_DECL).  This seems consistent with the fact that the
parameter of B is a template itself so its argument ought to be
template-name, rather than a template instantiation.

-- 
Dodji


[PATCH] PR c++/55311 - Cannot specialize alias template with arg of type array of char

2012-12-22 Thread Dodji Seketeli
Hello,

Consider this test case:

 1  template 
 2  struct A
 3  {};
 4
 5  struct B {};
 6
 7  extern constexpr char HELLO_WORLD[] = "hello world";
 8
 9  A g; // <-- This works fine
10
11  template 
12  using PartiallySpecialized = A;  // <-- This fails
13

At line 12 G++ fails to instantiate the alias template that has a
string variable initialized with a string literal, with the error
message:

test.cc:12:46: error: ‘"hello world"’ is not a valid template argument of 
type ‘const char*’ because ‘"hello world"’ is not a variable
 using PartiallySpecialized = A;  // <-- This fails
  ^

Note that instantiating the template A at line 9 with the same
arguments as in the problematic case above works.

This happens in the context of lookup_template_class_1, when it handles
the alias template instantiation A and thus passes the
VAR_DECL for HELLO_WORLD to convert_nontype_argument.

Note that from there decay_conversion replaces the the VAR_DECL with
its STRING_CST initializer[1].  Latter on, convert_nontype_argument
checks that the HELLO_WORLD constant it received as argument was
indeed a VAR_DECL:

  else
{
  tree decl;

  decl = ((TREE_CODE (expr) == ADDR_EXPR)
  ? TREE_OPERAND (expr, 0) : expr);
  if (TREE_CODE (decl) != VAR_DECL)
{
  error ("%qE is not a valid template argument of type %qT "
 "because %qE is not a variable",
 expr, type, decl);
  return NULL_TREE;
}

But the issue is, that VAR_DECL has been replaced by STRING_CST, so
the last 'if' above fails.

The idea of the patch I am proposing is to do the test above on the
argument received by convert_nontype_argument rather than on its
modified (decayed?) form.

[1]: The relacement of the VAR_DECL by its initializer is done by
decay_conversion by callig decl_constant_value_safe.  That replacement
doesn't happen if processing_template_decl is not set.  That's why it
doesn't happen for the class template instantiation at line 9, leading
to no error message there.

Bootstrapped and tested on x86_64-unknown-linux-gnu against trunk.

gcc/cp/

PR c++/55311
* pt.c (convert_nontype_argument): Perform the
sanity tests on the initial expression otherwise decay_conversion
might have made us loose some information.

gcc/testsuite/

PR c++/55311
* g++.dg/cpp0x/alias-decl-30.C: New test.
---
 gcc/cp/pt.c|  8 
 gcc/testsuite/g++.dg/cpp0x/alias-decl-30.C | 15 +++
 2 files changed, 19 insertions(+), 4 deletions(-)
 create mode 100644 gcc/testsuite/g++.dg/cpp0x/alias-decl-30.C

diff --git a/gcc/cp/pt.c b/gcc/cp/pt.c
index 1b3f039..4af30cf 100644
--- a/gcc/cp/pt.c
+++ b/gcc/cp/pt.c
@@ -5454,7 +5454,7 @@ unify_overload_resolution_failure (bool explain_p, tree 
arg)
 static tree
 convert_nontype_argument (tree type, tree expr, tsubst_flags_t complain)
 {
-  tree expr_type;
+  tree expr_type, initial_expr = expr;
 
   /* Detect immediately string literals as invalid non-type argument.
  This special-case is not needed for correctness (we would easily
@@ -5658,10 +5658,10 @@ convert_nontype_argument (tree type, tree expr, 
tsubst_flags_t complain)
}
   else
{
- tree decl;
+ tree decl = STRIP_NOPS (initial_expr);
 
- decl = ((TREE_CODE (expr) == ADDR_EXPR)
- ? TREE_OPERAND (expr, 0) : expr);
+ decl = ((TREE_CODE (initial_expr) == ADDR_EXPR)
+ ? TREE_OPERAND (initial_expr, 0) : initial_expr);
  if (TREE_CODE (decl) != VAR_DECL)
{
  error ("%qE is not a valid template argument of type %qT "
diff --git a/gcc/testsuite/g++.dg/cpp0x/alias-decl-30.C 
b/gcc/testsuite/g++.dg/cpp0x/alias-decl-30.C
new file mode 100644
index 000..7ad5e6d
--- /dev/null
+++ b/gcc/testsuite/g++.dg/cpp0x/alias-decl-30.C
@@ -0,0 +1,15 @@
+// Origin PR c++/55311
+// { dg-do compile { target c++11 } }
+
+template 
+struct A
+{};
+
+struct B {};
+
+extern constexpr char HELLO_WORLD[] = "hello world";
+
+A g; // <-- This works fine
+
+template 
+using PartiallySpecialized = A;  // <-- This fails
-- 
Dodji


Re: [PATCH] PR c++/52343 - error with alias template as template template argument

2012-12-22 Thread Gabriel Dos Reis
On Sat, Dec 22, 2012 at 9:53 AM, Dodji Seketeli  wrote:
> Gabriel Dos Reis  writes:
>
>> Thank you very much for the explanation; your previous message
>> makes sense to me now.
>
> You are welcome.
>
>> The question I have is why are we using TREE_TYPE of a TEMPLATE_DECL
>> to represent the current instantiation of a template alias?
>
> My understanding is that in the instantiation at line 7 below
>
>  1  template
>  2  using A = int;
>  3
>  4  template class>
>  5  struct B {};
>  6
>  7  B b;
>
> check_instantiated_arg is not looking at the current instantiation of
> the template alias A.  Rather, it is looking at the template-name A
> (which resolved, IMHO rightfully, to the decl for A which happens to be
> a TEMPLATE_DECL).  This seems consistent with the fact that the
> parameter of B is a template itself so its argument ought to be
> template-name, rather than a template instantiation.

Sorry for the confusion, "current instantiation" was the wrong word.
What I meant to say was that the use and interpretation of TREE_TYPE
is very confusing in this context.

-- Gaby


Re: [Patch, Fortran] PR55763 fix .mod reading plus CALL with CLASS(*)

2012-12-22 Thread Paul Richard Thomas
Dear Tobias,

I did this one myself on the plane to the UK last night!  We came to
the same patch, so yes it's OK for trunk.

Thanks

Paul

On 21 December 2012 22:41, Tobias Burnus  wrote:
> Another two fixes for CLASS(*). (We really should audit all calls to
> gfc_find_derived_vtab for possible issues with CLASS(*).)
>
> If I haven't miscounted, there is still one other failure in the PR.
>
> Build and regtested on x86-64-gnu-linux.
> OK for the trunk?
>
> Tobias



-- 
The knack of flying is learning how to throw yourself at the ground and miss.
   --Hitchhikers Guide to the Galaxy


Merge from trunk to gccgo branch

2012-12-22 Thread Ian Lance Taylor
I've merged trunk revision 194692 to the gccgo branch.

Ian


Re: C++ PATCH for c++/54325 (wrong error initializing abstract base class)

2012-12-22 Thread Jason Merrill

On 12/21/2012 06:38 AM, Paolo Carlini wrote:

I was looking a bit more into this Bug, and something seems still weird about 
the testcase in Comment #1 of the audit trail, which we also didn't reject with 
4.6.x:


What's weird about it?

Jason



Re: [Patch, libfortran] PR 55539 Regression with -fno-sign-zero

2012-12-22 Thread Janne Blomqvist
Ping!

On Sat, Dec 15, 2012 at 6:32 PM, Janne Blomqvist
 wrote:
> Hello,
>
> the attached patch fixes PR 55539 (4.8 regression). Regtested on
> x86_64-unknown-linux-gnu, Ok for trunk?
>
>
> 2012-12-15  Janne Blomqvist  
>
> PR fortran/55539
> * io/write_float.def (output_float): Take into account decimal dot.
>
>
> testsuite ChangeLog:
>
> 2012-12-15  Janne Blomqvist  
>
> PR fortran/55539
> * gfortran.dg/nosigned_zero_3.f90: New testcase.
>
>
>
> --
> Janne Blomqvist



-- 
Janne Blomqvist


Re: C++ PATCH for c++/54325 (wrong error initializing abstract base class)

2012-12-22 Thread Paolo Carlini
Hi,

Jason Merrill  ha scritto:

>On 12/21/2012 06:38 AM, Paolo Carlini wrote:
>> I was looking a bit more into this Bug, and something seems still
>weird about the testcase in Comment #1 of the audit trail, which we
>also didn't reject with 4.6.x:
>
>What's weird about it?

Well, we still reject it after the patch, whereas we didn't in 4.6.x. 
Apparently - I didn't check - clang also accepts it. By 'weird' I meant, isn't 
clear that the Bug is completely resolved...

Paolo




PR lto/54728 (streamer ICE)

2012-12-22 Thread Jan Hubicka
Hi,
in the testcase I don't really know how to put into testsuite since it needs DSO
there is issue with LTO not merging external declaration with body. This is 
because
logic in symtab_real_symbol_p that really applies only to LTO symbol table 
output
not to the symbol merging.

Bootstrapped/regtested x86_64-linux and tested with Mozilla build.

Honza

PR lto/54728
* cgraph.h (symtab_real_symbol_p): Drop code looking for external 
functions.
* lto-streamer-out.c (output_symbol_p): New function.
(produce_symtab) Use it.
Index: cgraph.h
===
*** cgraph.h(revision 194605)
--- cgraph.h(working copy)
*** static inline bool
*** 1357,1363 
  symtab_real_symbol_p (symtab_node node)
  {
struct cgraph_node *cnode;
-   struct ipa_ref *ref;
  
if (!is_a  (node))
  return true;
--- 1357,1362 
*** symtab_real_symbol_p (symtab_node node)
*** 1366,1376 
  return false;
if (cnode->abstract_and_needed)
  return false;
-   /* We keep virtual clones in symtab.  */
-   if (!cnode->analyzed
-   || DECL_EXTERNAL (cnode->symbol.decl))
- return (cnode->callers
-   || ipa_ref_list_referring_iterate (&cnode->symbol.ref_list, 0, 
ref));
return true;
  }
  #endif  /* GCC_CGRAPH_H  */
--- 1365,1370 
Index: lto-streamer-out.c
===
*** lto-streamer-out.c  (revision 194605)
--- lto-streamer-out.c  (working copy)
*** write_symbol (struct streamer_tree_cache
*** 1257,1262 
--- 1257,1282 
lto_output_data_stream (stream, &slot_num, 4);
  }
  
+ /* Return true if NODE should appear in the plugin symbol table.  */
+ 
+ bool
+ output_symbol_p (symtab_node node)
+ {
+   struct cgraph_node *cnode;
+   struct ipa_ref *ref;
+ 
+   if (!symtab_real_symbol_p (node))
+ return false;
+   /* We keep external functions in symtab for sake of inlining
+  and devirtualization.  We do not want to see them in symbol table as
+  references.  */
+   cnode = dyn_cast  (node);
+   if (cnode && DECL_EXTERNAL (cnode->symbol.decl))
+ return (cnode->callers
+   || ipa_ref_list_referring_iterate (&cnode->symbol.ref_list, 0, 
ref));
+   return true;
+ }
+ 
  
  /* Write an IL symbol table to OB.
 SET and VSET are cgraph/varpool node sets we are outputting.  */
*** produce_symtab (struct output_block *ob)
*** 1285,1291 
  {
symtab_node node = lsei_node (lsei);
  
!   if (!symtab_real_symbol_p (node) || DECL_EXTERNAL (node->symbol.decl))
continue;
write_symbol (cache, &stream, node->symbol.decl, seen, false);
  }
--- 1305,1311 
  {
symtab_node node = lsei_node (lsei);
  
!   if (!output_symbol_p (node) || DECL_EXTERNAL (node->symbol.decl))
continue;
write_symbol (cache, &stream, node->symbol.decl, seen, false);
  }
*** produce_symtab (struct output_block *ob)
*** 1294,1300 
  {
symtab_node node = lsei_node (lsei);
  
!   if (!symtab_real_symbol_p (node) || !DECL_EXTERNAL (node->symbol.decl))
continue;
write_symbol (cache, &stream, node->symbol.decl, seen, false);
  }
--- 1314,1320 
  {
symtab_node node = lsei_node (lsei);
  
!   if (!output_symbol_p (node) || !DECL_EXTERNAL (node->symbol.decl))
continue;
write_symbol (cache, &stream, node->symbol.decl, seen, false);
  }