Message ID | CAEwic4YNNdBKQ=ENqzbH7THHwdc5Z06QM3zUGe++wmqfkxjZXw@mail.gmail.com |
---|---|
State | New |
Headers | show |
On 03/20/2015 10:53 AM, Kai Tietz wrote: > * tree.c (strip_typedefs): Ignore alignment > difference during processing template. > > + || (processing_template_decl > + && TYPE_ALIGN (t) != TYPE_ALIGN (result))) Your change is actually ignoring alignment differences when *not* processing a template, which isn't what we want. The problem is that the type is considered dependent in a template but is not actually dependent, so we can see the exact same type outside a template and it's not dependent. So, this code is creating the difference: > /* We can only call value_dependent_expression_p on integral constant > expressions; treat non-constant expressions as dependent, too. */ > if (processing_template_decl > && (type_dependent_expression_p (size) > || !TREE_CONSTANT (size) || value_dependent_expression_p (size))) Now that we have instantiation_dependent_expression_p, we should be able to use that instead of checking type/value dependency separately. Jason
Index: gcc/gcc/cp/tree.c =================================================================== --- gcc.orig/gcc/cp/tree.c +++ gcc/gcc/cp/tree.c @@ -1356,7 +1356,8 @@ strip_typedefs (tree t) if (!result) result = TYPE_MAIN_VARIANT (t); if (TYPE_USER_ALIGN (t) != TYPE_USER_ALIGN (result) - || TYPE_ALIGN (t) != TYPE_ALIGN (result)) + || (processing_template_decl + && TYPE_ALIGN (t) != TYPE_ALIGN (result))) { gcc_assert (TYPE_USER_ALIGN (t)); if (TYPE_ALIGN (t) == TYPE_ALIGN (result)) Index: gcc/gcc/testsuite/g++.dg/template/pr65390.C =================================================================== --- /dev/null +++ gcc/gcc/testsuite/g++.dg/template/pr65390.C @@ -0,0 +1,12 @@ +// { dg-do compile } +// { dg-options "-Wno-vla" } +template<typename T> struct shared_ptr { }; + +template<typename T, typename Arg> +shared_ptr<T> make_shared(Arg) { return shared_ptr<T>(); } // { dg-message "note" } +// { dg-warning "ignoring attributes" "template" { target *-*-* } 6 } + +void f(int n){ + make_shared<int[n]>(1); // { dg-error "no matching" } +}