Here, since the condition for the constexpr if depends on the type of 'j',
it's still dependent when we are partially instantiating the inner lambda,
so we need to defer instantiating the constexpr if. When we instantiated
the inner lambda, we tried to substitute into the typename, which failed
because we didn't have a declaration of 'i' available.
Fixed by teaching extract_locals_r to capture local typedefs such as 'ar';
if we have the typedef handy, we don't need to substitute into its
definition.
* pt.c (extract_locals_r): Remember local typedefs.
From-SVN: r259185
This patch adds more suggestions as per:
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=84269#c10
some of which need C++14 and C++17, and some of which use headers that
exist in earlier standards.
For example, <memory> exists in C++98, but if the user attempts to
use std::make_shared with -std=c++98, they are suggested to include
<memory>, even if they've already included it.
This patch adds the missing names, and fixes the nonsensical suggestions
by detecting if the name isn't available yet, based on the user's
dialect, and reporting things more intelligently:
t.cc: In function 'void test_make_shared()':
t.cc:5:8: error: 'make_shared' is not a member of 'std'
std::make_shared<int>();
^~~~~~~~~~~
t.cc:5:8: note: 'std::make_shared' is only available from C++11 onwards
gcc/cp/ChangeLog:
PR c++/84269
* name-lookup.c (struct std_name_hint): Move out of
get_std_name_hint; add field "min_dialect".
(get_std_name_hint): Add min_dialect values to all initializers.
Add <any>, <atomic>, <bitset>, <condition_variable>, <functional>,
<future>, <istream>, <iterator>, <ostream>, <mutex>, <optional>,
<shared_mutex>, <string_view>, <thread>, and <variant>.
Add fstream, ifstream, and ofstream to <fstream>.
Add istringstream, ostringstream, and stringstream to <sstream>.
Add basic_string to <string>.
Add tuple_element and tuple_size to <tuple>.
Add declval to <utility>.
Fix ordering of <queue> and <tuple>.
Return a std_name_hint, rather than a const char *.
(get_cxx_dialect_name): New function.
(maybe_suggest_missing_std_header): Detect names that aren't yet
available in the current dialect, and instead of suggesting a
missing #include, warn about the dialect.
gcc/testsuite/ChangeLog:
PR c++/84269
* g++.dg/lookup/missing-std-include-6.C: Move std::array and
std::tuple here since they need C++11.
* g++.dg/lookup/missing-std-include-8.C: New test.
* g++.dg/lookup/missing-std-include.C: Move std::array and
std::tuple test to missing-std-include-6.C to avoid failures
with C++98.
From-SVN: r259184
PR debug/85252
* dwarf2out.c (rtl_for_decl_init): For STRING_CST initializer only
build CONST_STRING if TYPE_MAX_VALUE is non-NULL and is INTEGER_CST.
* gcc.dg/debug/pr85252.c: New test.
From-SVN: r259183
PR rtl-optimization/84872
* cfgloopmanip.c (create_preheader): Use make_forwarder_block even if
nentry == 1 when CP_FALLTHRU_PREHEADERS and single_entry is
EDGE_CROSSING edge.
* gcc.dg/graphite/pr84872.c: New test.
From-SVN: r259182
PR c++/85210
* pt.c (tsubst_decomp_names): Return error_mark_node and assert
errorcount is set if tsubst doesn't return a VAR_DECL.
* g++.dg/cpp1z/decomp42.C: New test.
From-SVN: r259181
We provide fix-it hints for the most common "std" names when an explicit
"std::" prefix is present, however we don't yet provide fix-it hints for
this implicit case:
using namespace std;
void f() { cout << "test"; }
for which we emit:
t.cc: In function 'void f()':
t.cc:2:13: error: 'cout' was not declared in this scope
void f() { cout << "test"; }
^~~~
This patch detects if a "using namespace std;" directive is present
in the current namespace, and if so, offers a suggestion for
unrecognized names that are in our list of common "std" names:
t.cc: In function 'void f()':
t.cc:2:13: error: 'cout' was not declared in this scope
void f() { cout << "test"; }
^~~~
t.cc:2:13: note: 'std::cout' is defined in header '<iostream>'; did you forget to '#include <iostream>'?
+#include <iostream>
using namespace std;
void f() { cout << "test"; }
^~~~
gcc/cp/ChangeLog:
PR c++/85021
* name-lookup.c (using_directives_contain_std_p): New function.
(has_using_namespace_std_directive_p): New function.
(suggest_alternatives_for): Simplify if/else logic using early
returns. If no candidates were found, and there's a
"using namespace std;" directive, call
maybe_suggest_missing_std_header.
(maybe_suggest_missing_header): Split later part of the function
into..
(maybe_suggest_missing_std_header): New.
gcc/testsuite/ChangeLog:
PR c++/85021
* g++.dg/lookup/missing-std-include-7.C: New test.
From-SVN: r259179
2018-04-06 Richard Biener <rguenther@suse.de>
PR middle-end/85244
* tree-dfa.c (get_ref_base_and_extent): Reset seen_variable_array_ref
after seeing a component reference with an adjacent field. Treat
refs to arrays at struct end of external decls similar to
refs to unconstrained commons.
* gcc.dg/torture/pr85244-1.c: New testcase.
* gcc.dg/torture/pr85244-2.c: Likewise.
From-SVN: r259168
2018-04-06 Richard Biener <rguenther@suse.de>
PR middle-end/85180
* alias.c (find_base_term): New wrapper around find_base_term
unwinding CSELIB_VAL_PTR changes.
(find_base_term): Do not restore CSELIB_VAL_PTR during the
recursion.
* gcc.dg/pr85180.c: New testcase.
From-SVN: r259166
gcc/testsuite/ChangeLog:
2018-04-06 Andreas Krebbel <krebbel@linux.vnet.ibm.com>
* gcc.target/s390/vector/vcond-shift.c: Use the proper conditions
to trigger the optimization. Do some cleanup and function
renaming. Add more test functions.
From-SVN: r259165
We still use lr r0,r0 as a NOP instruction although we have some kind
of dedicated NOP instruction (nopr) which maps to a "branch never".
As a side-effect this fixes testcases scanning for NOPs
e.g. patchable_function_entry-*.
As another side-effect this makes it difficult to distingiush NOPs
generated for hotpatching from NOPs added when using -O0 to attach
location information to it. Hence I had to make sure that the hotpatch
testcases get skipped when compiling without optimization.
gcc/ChangeLog:
2018-04-06 Andreas Krebbel <krebbel@linux.vnet.ibm.com>
* config/s390/s390.c (s390_z10_optimize_cmp): Expand dedicated NOP
instructions.
* config/s390/s390.md (UNSPECV_NOP_LR_0, UNSPECV_NOP_LR_1): New
constant definitions.
("nop"): lr 0,0 -> nopr r0
("nop_lr0", "nop_lr1"): New insn definitions.
gcc/testsuite/ChangeLog:
2018-04-06 Andreas Krebbel <krebbel@linux.vnet.ibm.com>
* gcc.target/s390/s390.exp: Remove -O0 from list of torture
options.
* gcc.target/s390/hotpatch-1.c: Skip when building without
optimization.
* gcc.target/s390/hotpatch-10.c: Likewise.
* gcc.target/s390/hotpatch-11.c: Likewise.
* gcc.target/s390/hotpatch-12.c: Likewise.
* gcc.target/s390/hotpatch-13.c: Likewise.
* gcc.target/s390/hotpatch-14.c: Likewise.
* gcc.target/s390/hotpatch-15.c: Likewise.
* gcc.target/s390/hotpatch-16.c: Likewise.
* gcc.target/s390/hotpatch-17.c: Likewise.
* gcc.target/s390/hotpatch-18.c: Likewise.
* gcc.target/s390/hotpatch-19.c: Likewise.
* gcc.target/s390/hotpatch-2.c: Likewise.
* gcc.target/s390/hotpatch-3.c: Likewise.
* gcc.target/s390/hotpatch-4.c: Likewise.
* gcc.target/s390/hotpatch-5.c: Likewise.
* gcc.target/s390/hotpatch-6.c: Likewise.
* gcc.target/s390/hotpatch-7.c: Likewise.
* gcc.target/s390/hotpatch-8.c: Likewise.
* gcc.target/s390/hotpatch-9.c: Likewise.
From-SVN: r259164
On IBM Z we enforce function alignment to 8 bytes. Hence we get an
error instead of a warning when trying to specify smaller alignments.
gcc/testsuite/ChangeLog:
2018-04-06 Andreas Krebbel <krebbel@linux.vnet.ibm.com>
* c-c++-common/Wattributes.c: Disable warning for s390* target and
check for an error instead.
* gcc.dg/Wattributes-6.c: Likewise.
From-SVN: r259163
gcc/
* config.gcc (nds32*-*-*): Add v2j v3f v3s checking.
(nds32*-*-*): Add float and fpu_config into supported_defaults.
* common/config/nds32/nds32-common.c (TARGET_DEFAULT_TARGET_FLAGS):
Include TARGET_DEFAULT_FPU_ISA and TARGET_DEFAULT_FPU_FMA.
* config/nds32/constants.md (unspec_element): Add UNSPEC_COPYSIGN,
UNSPEC_FCPYNSD, UNSPEC_FCPYNSS, UNSPEC_FCPYSD and UNSPEC_FCPYSS.
* config/nds32/constraints.md: New constraints and checking for hard
float configuration.
* config/nds32/iterators.md: New mode iterator and attribute for hard
float configuration.
* config/nds32/nds32-doubleword.md: Use hard float alternatives and
patterns.
* config/nds32/nds32-fpu.md: New file.
* config/nds32/nds32-md-auxiliary.c: New functions and checkings to
deal with hard float code generation.
* config/nds32/nds32-opts.h (nds32_arch_type): Add ARCH_V3F and
ARCH_V3S.
(abi_type, float_reg_number): New enum type.
* config/nds32/nds32-predicates.c: New predicates for hard float.
* config/nds32/nds32-protos.h: Declare functions for hard float.
* config/nds32/nds32.c: Implementation for hard float configuration.
* config/nds32/nds32.h: Definitions for hard float configuration.
* config/nds32/nds32.md: Include hard float machine description and
modify patterns for hard float configuration.
* config/nds32/nds32.opt: New options for hard float configuration.
* config/nds32/predicates.md: New predicates for hard float
configuration.
Co-Authored-By: Chung-Ju Wu <jasonwucj@gmail.com>
From-SVN: r259161
PR c++/85209
* pt.c (tsubst_decomp_names): Don't fail or ICE if DECL_CHAIN (decl3)
is not prev, if prev == decl.
* g++.dg/cpp1z/decomp39.C: New test.
* g++.dg/cpp1z/decomp40.C: New test.
From-SVN: r259156
PR c++/85208
* decl.c (start_decl): For DECL_DECOMPOSITION_P decls, don't call
maybe_apply_pragma_weak here...
(cp_maybe_mangle_decomp): ... but call it here instead.
* g++.dg/cpp1z/decomp41.C: New test.
From-SVN: r259155
config/plugins.m4 has
if test "$plugins" = "yes"; then
AC_SEARCH_LIBS([dlopen], [dl])
fi
Plugin uses dlsym, but libasan.so only intercepts dlopen, not dlsym:
[hjl@gnu-tools-1 binutils-text]$ nm -D /lib64/libasan.so.4| grep " dl"
0000000000038580 W dlclose
U dl_iterate_phdr
000000000004dc50 W dlopen
U dlsym
U dlvsym
[hjl@gnu-tools-1 binutils-text]$
Testing dlopen for libdl leads to false negative when -fsanitize=address
is used. It results in link failure:
../bfd/.libs/libbfd.a(plugin.o): undefined reference to symbol 'dlsym@@GLIBC_2.16'
dlsym should be used to check if libdl is needed for plugin.
PR gas/22318
* plugins.m4 (AC_PLUGINS): Use dlsym to check if libdl is needed.
From-SVN: r259140
/cp
2018-04-05 Paolo Carlini <paolo.carlini@oracle.com>
PR c++/84792
* decl.c (grokdeclarator): Fix diagnostic about typedef name used
as nested-name-specifier, keep type and TREE_TYPE (decl) in sync.
/testsuite
2018-04-05 Paolo Carlini <paolo.carlini@oracle.com>
PR c++/84792
* g++.dg/other/pr84792-1.C: New.
* g++.dg/other/pr84792-2.C: Likewise.
From-SVN: r259136
2018-04-05 Tom de Vries <tom@codesourcery.com>
PR target/85204
* config/nvptx/nvptx.c (nvptx_single): Fix neutering of bb with only
cond jump.
* testsuite/libgomp.oacc-c-c++-common/broadcast-1.c: New test.
From-SVN: r259125
With concepts, we accept auto in explicit template arguments, but we
should only accept them for template classes. Passing them to
template functions or variables is not allowed. So, reject it, at
parse time if possible, at specialization time otherwise.
for gcc/cp/ChangeLog
PR c++/84979
* pt.c (check_auto_in_tmpl_args): New.
(tsubst_qualified_id): Use it to reject template args
referencing auto for non-type templates.
* parser.c (cp_parser_template_id): Likewise.
* cp-tree.h (check_auto_in_tmpl_args): Declare.
* typeck2.c (build_functional_cast): Report correct location
for invalid use of auto.
for gcc/testsuite/ChangeLog
PR c++/84979
* g++.dg/concepts/pr84979.C: New.
* g++.dg/concepts/pr84979-2.C: New.
* g++.dg/concepts/pr84979-3.C: New.
From-SVN: r259124