summaryrefslogtreecommitdiffstats
path: root/clang/test
diff options
context:
space:
mode:
authorRichard Smith <richard-llvm@metafoo.co.uk>2015-02-23 21:16:05 +0000
committerRichard Smith <richard-llvm@metafoo.co.uk>2015-02-23 21:16:05 +0000
commit152a172899034b5f9c34420621cd9cfa74c68efa (patch)
tree047c268b46d9e8d7de38ab6bf228e03b5ca9fd4c /clang/test
parent0168d34e238cb928c05309caac4eb4d50e739b0c (diff)
downloadbcm5719-llvm-152a172899034b5f9c34420621cd9cfa74c68efa.tar.gz
bcm5719-llvm-152a172899034b5f9c34420621cd9cfa74c68efa.zip
Improve declaration / expression disambiguation around ptr-operators, and use
the presence of an abstract declarator with a ptr-operator as proof that a construct cannot parse as an expression to improve diagnostics along error recovery paths. llvm-svn: 230261
Diffstat (limited to 'clang/test')
-rw-r--r--clang/test/Parser/cxx-ambig-init-templ.cpp9
-rw-r--r--clang/test/Parser/cxx-variadic-func.cpp3
-rw-r--r--clang/test/Parser/recovery.cpp8
-rw-r--r--clang/test/SemaTemplate/rdar9173693.cpp4
4 files changed, 20 insertions, 4 deletions
diff --git a/clang/test/Parser/cxx-ambig-init-templ.cpp b/clang/test/Parser/cxx-ambig-init-templ.cpp
index 1f692664137..584262c9be4 100644
--- a/clang/test/Parser/cxx-ambig-init-templ.cpp
+++ b/clang/test/Parser/cxx-ambig-init-templ.cpp
@@ -170,6 +170,15 @@ namespace ElaboratedTypeSpecifiers {
};
}
+namespace AbstractPtrOperatorDeclarator {
+ template <int, typename> struct X {
+ operator int();
+ };
+ struct Y {
+ void f(int a = X<0, int (*)()>());
+ };
+}
+
namespace PR20459 {
template <typename EncTraits> struct A {
void foo(int = EncTraits::template TypeEnc<int, int>::val); // ok
diff --git a/clang/test/Parser/cxx-variadic-func.cpp b/clang/test/Parser/cxx-variadic-func.cpp
index 98a34d3e1bf..c0fad95e468 100644
--- a/clang/test/Parser/cxx-variadic-func.cpp
+++ b/clang/test/Parser/cxx-variadic-func.cpp
@@ -1,8 +1,7 @@
// RUN: %clang_cc1 -fsyntax-only -verify %s
void f(...) {
- // FIXME: There's no disambiguation here; this is unambiguous.
- int g(int(...)); // expected-warning {{disambiguated}} expected-note {{paren}}
+ int g(int(...)); // no warning, unambiguously a function declaration
}
void h(int n..., int m); // expected-error {{expected ')'}} expected-note {{to match}}
diff --git a/clang/test/Parser/recovery.cpp b/clang/test/Parser/recovery.cpp
index 2d5b518c691..f099473e04b 100644
--- a/clang/test/Parser/recovery.cpp
+++ b/clang/test/Parser/recovery.cpp
@@ -203,6 +203,14 @@ namespace pr15133 {
};
}
+namespace AbstractPtrOperator {
+ // A ptr-operator and no name means we have a declaration and not an
+ // expression.
+ template<typename T> int f(int*, T::type); // expected-error {{missing 'typename'}}
+ template<typename T> int f(int (T::*), T::type); // expected-error {{missing 'typename'}}
+ template<typename T> int f(int (*)(), T::type); // expected-error {{missing 'typename'}}
+}
+
namespace InvalidEmptyNames {
// These shouldn't crash, the diagnostics aren't important.
struct ::, struct ::; // expected-error 2 {{expected identifier}} expected-error 2 {{declaration of anonymous struct must be a definition}} expected-warning {{declaration does not declare anything}}
diff --git a/clang/test/SemaTemplate/rdar9173693.cpp b/clang/test/SemaTemplate/rdar9173693.cpp
index 86b49545a30..1e999cba670 100644
--- a/clang/test/SemaTemplate/rdar9173693.cpp
+++ b/clang/test/SemaTemplate/rdar9173693.cpp
@@ -2,5 +2,5 @@
// <rdar://problem/9173693>
template< bool C > struct assert { };
-template< bool > struct assert_arg_pred_impl { }; // expected-note 3 {{declared here}}
-template< typename Pred > assert<false> assert_not_arg( void (*)(Pred), typename assert_arg_pred<Pred>::type ); // expected-error 5 {{}}
+template< bool > struct assert_arg_pred_impl { }; // expected-note 2 {{declared here}}
+template< typename Pred > assert<false> assert_not_arg( void (*)(Pred), typename assert_arg_pred<Pred>::type ); // expected-error 3 {{}}
OpenPOWER on IntegriCloud