diff options
| author | Richard Smith <richard-llvm@metafoo.co.uk> | 2013-05-04 04:19:27 +0000 |
|---|---|---|
| committer | Richard Smith <richard-llvm@metafoo.co.uk> | 2013-05-04 04:19:27 +0000 |
| commit | 489e4e0369be714041a5ca2d9b4b4c84f77e4a97 (patch) | |
| tree | c7ac2b24bc2c6ef566b9fd3504996c8901dadbcf /clang | |
| parent | 287f18b4b82dd59c827b1f7b496b8f62dfcc1c7f (diff) | |
| download | bcm5719-llvm-489e4e0369be714041a5ca2d9b4b4c84f77e4a97.tar.gz bcm5719-llvm-489e4e0369be714041a5ca2d9b4b4c84f77e4a97.zip | |
Say 'decltype(auto)' not 'auto' as appropriate in mismatched-deduction diagnostic.
llvm-svn: 181103
Diffstat (limited to 'clang')
| -rw-r--r-- | clang/include/clang/Basic/DiagnosticSemaKinds.td | 3 | ||||
| -rw-r--r-- | clang/lib/Sema/SemaDecl.cpp | 1 | ||||
| -rw-r--r-- | clang/test/CXX/dcl.dcl/dcl.spec/dcl.type/dcl.spec.auto/p6-1y.cpp | 4 |
3 files changed, 7 insertions, 1 deletions
diff --git a/clang/include/clang/Basic/DiagnosticSemaKinds.td b/clang/include/clang/Basic/DiagnosticSemaKinds.td index f43a7d13384..d7347e9c316 100644 --- a/clang/include/clang/Basic/DiagnosticSemaKinds.td +++ b/clang/include/clang/Basic/DiagnosticSemaKinds.td @@ -1454,7 +1454,8 @@ def err_auto_var_deduction_failure_from_init_list : Error< def err_auto_new_deduction_failure : Error< "new expression for type %0 has incompatible constructor argument of type %1">; def err_auto_different_deductions : Error< - "'auto' deduced as %0 in declaration of %1 and deduced as %2 in declaration of %3">; + "'%select{auto|decltype(auto)}0' deduced as %1 in declaration of %2 and " + "deduced as %3 in declaration of %4">; def err_implied_std_initializer_list_not_found : Error< "cannot deduce type of initializer list because std::initializer_list was " "not found; include <initializer_list>">; diff --git a/clang/lib/Sema/SemaDecl.cpp b/clang/lib/Sema/SemaDecl.cpp index f5b4823fdb7..f7826771cc6 100644 --- a/clang/lib/Sema/SemaDecl.cpp +++ b/clang/lib/Sema/SemaDecl.cpp @@ -8212,6 +8212,7 @@ Sema::BuildDeclaratorGroup(Decl **Group, unsigned NumDecls, } else if (DeducedCanon != UCanon) { Diag(D->getTypeSourceInfo()->getTypeLoc().getBeginLoc(), diag::err_auto_different_deductions) + << (AT->isDecltypeAuto() ? 1 : 0) << Deduced << DeducedDecl->getDeclName() << U << D->getDeclName() << DeducedDecl->getInit()->getSourceRange() diff --git a/clang/test/CXX/dcl.dcl/dcl.spec/dcl.type/dcl.spec.auto/p6-1y.cpp b/clang/test/CXX/dcl.dcl/dcl.spec/dcl.type/dcl.spec.auto/p6-1y.cpp index cfaed71832e..25b5f1984c2 100644 --- a/clang/test/CXX/dcl.dcl/dcl.spec/dcl.type/dcl.spec.auto/p6-1y.cpp +++ b/clang/test/CXX/dcl.dcl/dcl.spec/dcl.type/dcl.spec.auto/p6-1y.cpp @@ -60,3 +60,7 @@ decltype(auto) ((((((v1)))))) = 0; // ok decltype(auto) v2[1] = { 0 }; // expected-error {{cannot form array of 'decltype(auto)'}} decltype(auto) &v3 = { 0 }; // expected-error {{cannot form reference to 'decltype(auto)'}} decltype(auto) *v4 = { 0 }; // expected-error {{cannot form pointer to 'decltype(auto)'}} + +auto multi1a = 0, &multi1b = multi1a; +auto multi1c = multi1a, multi1d = multi1b; +decltype(auto) multi1e = multi1a, multi1f = multi1b; // expected-error {{'decltype(auto)' deduced as 'int' in declaration of 'multi1e' and deduced as 'int &' in declaration of 'multi1f'}} |

