2018-03-13 Jason Merrill <jason@redhat.com>
+ * parser.c (cp_parser_simple_type_specifier): Pedwarn about auto
+ parameter even without -Wpedantic.
+
PR c++/84798 - ICE with auto in abstract function declarator.
* parser.c (cp_parser_parameter_declaration_clause): Check
parser->default_arg_ok_p.
"only available with "
"-std=c++14 or -std=gnu++14");
else if (!flag_concepts)
- pedwarn (token->location, OPT_Wpedantic,
- "ISO C++ forbids use of %<auto%> in parameter "
- "declaration");
+ pedwarn (token->location, 0,
+ "use of %<auto%> in parameter declaration "
+ "only available with -fconcepts");
}
else
type = make_auto ();
--- /dev/null
+// PR c++/64969
+// { dg-do compile { target c++14 } }
+// { dg-additional-options "-fconcepts" }
+
+auto f1(auto x) { return *x; }
+decltype(auto) f2(auto x) { return *x; }
+auto f3(auto x) -> int { return *x; }
+
+int i;
+auto r1 = f1(&i);
+auto r2 = f2(&i);
+auto r3 = f3(&i);
--- /dev/null
+// PR c++/66197
+// { dg-do run { target c++14 } }
+// { dg-additional-options "-fconcepts" }
+
+extern "C" void abort();
+
+auto add_1(auto a, auto b) { return a + b; }
+auto add_2 = [](auto a, auto b) { return a + b; };
+
+int main()
+{
+ if (add_1(3.5, 4) != 7.5
+ || add_1(3, 4.5) != 7.5
+ || add_2(3.5, 4) != 7.5
+ || add_2(3, 4.5) != 7.5)
+ abort();
+}
--- /dev/null
+// Out-of-line generic member function definitions.
+// { dg-do compile { target c++14 } }
+// { dg-additional-options "-fconcepts" }
+
+struct A {
+ void f(auto x);
+};
+
+void A::f(auto x) {} // injects a new list
+
+template <typename T>
+struct B {
+ void f(auto x);
+};
+
+template <typename T>
+void B<T>::f(auto x) {} // injects a new list
+
+struct C {
+ template <int N>
+ void f(auto x);
+};
+
+template <int N>
+void C::f(auto x) {} // extends existing inner list
+
+template <typename T>
+struct D
+{
+ template <int N>
+ void f(auto x);
+};
+
+template <typename T>
+template <int N>
+void D<T>::f(auto x) {} // extends existing inner list
--- /dev/null
+// PR c++/58500
+// { dg-do compile { target c++14 } }
+// { dg-additional-options "-fconcepts" }
+
+struct A {};
+
+void foo(auto (A::*)());
--- /dev/null
+// PR c++/58534
+// { dg-do compile { target c++14 } }
+// { dg-additional-options "-fconcepts" }
+
+template<typename> void foo(const auto&) {}
+
+template<typename, typename...T> void foo(const auto&, T...) {}
--- /dev/null
+// PR c++/58535
+// { dg-do compile { target c++14 } }
+
+struct A
+{
+ virtual void foo(auto); // { dg-error "auto|templates" }
+};
--- /dev/null
+// PR c++/58536
+// { dg-do compile { target c++14 } }
+// { dg-additional-options "-fconcepts" }
+
+struct A
+{
+ A(auto);
+};
+
+A::A(auto) {}
--- /dev/null
+// PR c++/58548
+// { dg-do compile { target c++14 } }
+// { dg-additional-options "-fconcepts" }
+
+void foo(auto)
+{
+ struct A { int i; };
+}
--- /dev/null
+// PR c++/58549
+// { dg-do compile { target c++14 } }
+// { dg-additional-options "-fconcepts" }
+
+void foo(auto)
+{
+ void bar();
+}
--- /dev/null
+// PR c++/60052
+// { dg-do compile { target c++14 } }
+// { dg-additional-options "-fconcepts" }
+
+struct A
+{
+ void foo(auto);
+};
+
+void A::foo(auto) {}
+
+struct B
+{
+ void bar(auto);
+};
--- /dev/null
+// PR c++/60053
+// { dg-do compile { target c++14 } }
+// { dg-additional-options "-fconcepts" }
+
+struct A
+{
+ void foo(auto);
+};
+
+void A::foo(auto) {}
+
+template<typename> struct B
+{
+ template<typename T> void bar(auto);
+};
--- /dev/null
+// PR c++/60064
+// { dg-do compile { target c++14 } }
+// { dg-additional-options "-fconcepts" }
+
+class A
+{
+ int m;
+ friend void foo (auto) {}
+ friend void foo2 (auto);
+};
+
+void foo2 (auto i)
+{
+ A a;
+ a.m = i;
+}
+
+int main ()
+{
+ foo2 (7);
+}
--- /dev/null
+// PR c++/60065
+// { dg-do compile { target c++14 } }
+// { dg-additional-options "-fconcepts" }
+
+template <int> void foo(auto... x);
+template <typename> void foo2(auto... x);
+template <int> void foo3(auto... x, auto y, auto... z);
+template <typename> void foo4(auto... x, auto y, auto... z);
--- /dev/null
+// PR c++/60377
+// { dg-do compile { target c++14 } }
+
+void foo(auto, void (f*)()); // { dg-error "auto|expected" }
+
+struct A
+{
+ int i;
+};
--- /dev/null
+// PR c++/60390
+// { dg-do compile { target c++14 } }
+// { dg-additional-options "-fconcepts" }
+
+struct A
+{
+ void foo (auto);
+};
+
+class B
+{
+ int m;
+ friend void A::foo (auto);
+};
+
+void A::foo (auto i)
+{
+ B b;
+ b.m = i;
+}
+
+int main ()
+{
+ A a;
+ a.foo (7);
+}
--- /dev/null
+// PR c++/60391
+// { dg-do compile { target c++14 } }
+
+namespace N
+{
+ int operator"" _X(auto) {} // { dg-error "auto|invalid" }
+}
+
+namespace N {}
--- /dev/null
+// PR c++/60573
+// { dg-do compile { target c++14 } }
+// { dg-additional-options "-fconcepts" }
+
+struct A
+{
+ struct B
+ {
+ void foo(auto);
+ };
+
+ void B::foo(auto) {} // { dg-error "cannot define" }
+
+ struct X
+ {
+ struct Y
+ {
+ struct Z
+ {
+ void foo(auto);
+ };
+ };
+
+ void Y::Z::foo(auto) {} // { dg-error "cannot define" }
+ };
+
+ void X::Y::Z::foo(auto) {} // { dg-error "cannot define" }
+};
--- /dev/null
+// PR c++/80471
+// { dg-do compile { target c++14 } }
+// { dg-additional-options "-fconcepts" }
+
+template <class, class>
+constexpr bool is_same = false;
+template <class T>
+constexpr bool is_same<T, T> = true;
+
+template<class T>
+decltype(auto) f(T&& a){return a;}
+
+decltype(auto) g(auto&& a){return a;}
+
+auto z = [](auto&& a) -> decltype(auto) { return a; };
+
+int main()
+{
+ int i;
+ static_assert(is_same< decltype(f(i)), int& >, "");
+ static_assert(is_same< decltype(g(i)), int >, "");
+ static_assert(is_same< decltype(z(i)), int& >, "");
+}
--- /dev/null
+// PR c++/60626
+// { dg-do compile { target c++14 } }
+
+struct A {};
+
+void (*A::p)(auto) = 0; // { dg-error "auto|static data member|template" }
--- /dev/null
+// PR c++/84662
+// { dg-do compile { target c++14 } }
+
+double b;
+a (__attribute__((c (0 && int() - ([] {} && b) || auto)))); // { dg-error "auto|expected constructor, destructor, or type conversion before" }
+++ /dev/null
-// Out-of-line generic member function definitions.
-// { dg-do compile { target c++14 } }
-// { dg-options "" }
-
-struct A {
- void f(auto x);
-};
-
-void A::f(auto x) {} // injects a new list
-
-template <typename T>
-struct B {
- void f(auto x);
-};
-
-template <typename T>
-void B<T>::f(auto x) {} // injects a new list
-
-struct C {
- template <int N>
- void f(auto x);
-};
-
-template <int N>
-void C::f(auto x) {} // extends existing inner list
-
-template <typename T>
-struct D
-{
- template <int N>
- void f(auto x);
-};
-
-template <typename T>
-template <int N>
-void D<T>::f(auto x) {} // extends existing inner list
+++ /dev/null
-// PR c++/58500
-// { dg-do compile { target c++14 } }
-// { dg-options "" }
-
-struct A {};
-
-void foo(auto (A::*)());
+++ /dev/null
-// PR c++/58534
-// { dg-do compile { target c++14 } }
-// { dg-options "" }
-
-template<typename> void foo(const auto&) {}
-
-template<typename, typename...T> void foo(const auto&, T...) {}
+++ /dev/null
-// PR c++/58535
-// { dg-do compile { target c++14 } }
-// { dg-options "" }
-
-struct A
-{
- virtual void foo(auto); // { dg-error "templates" }
-};
+++ /dev/null
-// PR c++/58536
-// { dg-do compile { target c++14 } }
-// { dg-options "" }
-
-struct A
-{
- A(auto);
-};
-
-A::A(auto) {}
+++ /dev/null
-// PR c++/58548
-// { dg-do compile { target c++14 } }
-// { dg-options "" }
-
-void foo(auto)
-{
- struct A { int i; };
-}
+++ /dev/null
-// PR c++/58549
-// { dg-do compile { target c++14 } }
-// { dg-options "" }
-
-void foo(auto)
-{
- void bar();
-}
+++ /dev/null
-// PR c++/60052
-// { dg-do compile { target c++14 } }
-// { dg-options "" }
-
-struct A
-{
- void foo(auto);
-};
-
-void A::foo(auto) {}
-
-struct B
-{
- void bar(auto);
-};
+++ /dev/null
-// PR c++/60053
-// { dg-do compile { target c++14 } }
-// { dg-options "" }
-
-struct A
-{
- void foo(auto);
-};
-
-void A::foo(auto) {}
-
-template<typename> struct B
-{
- template<typename T> void bar(auto);
-};
+++ /dev/null
-// PR c++/60064
-// { dg-do compile { target c++14 } }
-// { dg-options "" }
-
-class A
-{
- int m;
- friend void foo (auto) {}
- friend void foo2 (auto);
-};
-
-void foo2 (auto i)
-{
- A a;
- a.m = i;
-}
-
-int main ()
-{
- foo2 (7);
-}
+++ /dev/null
-// PR c++/60065
-// { dg-do compile { target c++14 } }
-// { dg-options "" }
-
-template <int> void foo(auto... x);
-template <typename> void foo2(auto... x);
-template <int> void foo3(auto... x, auto y, auto... z);
-template <typename> void foo4(auto... x, auto y, auto... z);
+++ /dev/null
-// PR c++/60377
-// { dg-do compile { target c++14 } }
-// { dg-options "" }
-
-void foo(auto, void (f*)()); // { dg-error "expected" }
-
-struct A
-{
- int i;
-};
+++ /dev/null
-// PR c++/60390
-// { dg-do compile { target c++14 } }
-// { dg-options "" }
-
-struct A
-{
- void foo (auto);
-};
-
-class B
-{
- int m;
- friend void A::foo (auto);
-};
-
-void A::foo (auto i)
-{
- B b;
- b.m = i;
-}
-
-int main ()
-{
- A a;
- a.foo (7);
-}
+++ /dev/null
-// PR c++/60391
-// { dg-do compile { target c++14 } }
-// { dg-options "" }
-
-namespace N
-{
- int operator"" _X(auto) {} // { dg-error "invalid" }
-}
-
-namespace N {}
+++ /dev/null
-// PR c++/60573
-// { dg-do compile { target c++14 } }
-// { dg-options "" }
-
-struct A
-{
- struct B
- {
- void foo(auto);
- };
-
- void B::foo(auto) {} // { dg-error "cannot define" }
-
- struct X
- {
- struct Y
- {
- struct Z
- {
- void foo(auto);
- };
- };
-
- void Y::Z::foo(auto) {} // { dg-error "cannot define" }
- };
-
- void X::Y::Z::foo(auto) {} // { dg-error "cannot define" }
-};
+++ /dev/null
-// PR c++/60626
-// { dg-do compile { target c++14 } }
-// { dg-options "" }
-
-struct A {};
-
-void (*A::p)(auto) = 0; // { dg-error "static data member|template" }
+++ /dev/null
-// PR c++/80471
-// { dg-do compile { target c++14 } }
-// { dg-options "" }
-
-template <class, class>
-constexpr bool is_same = false;
-template <class T>
-constexpr bool is_same<T, T> = true;
-
-template<class T>
-decltype(auto) f(T&& a){return a;}
-
-decltype(auto) g(auto&& a){return a;}
-
-auto z = [](auto&& a) -> decltype(auto) { return a; };
-
-int main()
-{
- int i;
- static_assert(is_same< decltype(f(i)), int& >, "");
- static_assert(is_same< decltype(g(i)), int >, "");
- static_assert(is_same< decltype(z(i)), int& >, "");
-}
+++ /dev/null
-// PR c++/84662
-// { dg-do compile { target c++14 } }
-// { dg-options "" }
-
-double b;
-a (__attribute__((c (0 && int() - ([] {} && b) || auto)))); // { dg-error "expected constructor, destructor, or type conversion before" }
+++ /dev/null
-// PR c++/64969
-// { dg-options "-std=c++17" }
-
-auto f1(auto x) { return *x; }
-decltype(auto) f2(auto x) { return *x; }
-auto f3(auto x) -> int { return *x; }
-
-int i;
-auto r1 = f1(&i);
-auto r2 = f2(&i);
-auto r3 = f3(&i);
+++ /dev/null
-// PR c++/66197
-// { dg-do run }
-// { dg-options "-std=c++17" }
-
-extern "C" void abort();
-
-auto add_1(auto a, auto b) { return a + b; }
-auto add_2 = [](auto a, auto b) { return a + b; };
-
-int main()
-{
- if (add_1(3.5, 4) != 7.5
- || add_1(3, 4.5) != 7.5
- || add_2(3.5, 4) != 7.5
- || add_2(3, 4.5) != 7.5)
- abort();
-}
void
test2 (auto & [ p ] = bar ()) // { dg-error "'p' was not declared in this scope" }
-{
+{ // { dg-warning "auto" "" { target { ! concepts } } .-1 }
}
int arr[4];