From eae04111d0a6eb30a300c2a02703a746ac3ff72f Mon Sep 17 00:00:00 2001 From: David Blaikie Date: Wed, 10 Oct 2012 23:15:05 +0000 Subject: [PATCH] Fix a crash-on-invalid when parsing a reference to an invalid auto declaration auto x((unknown)); int& y = x; would crash because we were not flagging 'x' as an invalid declaration here. llvm-svn: 165675 --- clang/lib/Parse/ParseDecl.cpp | 1 + clang/test/CXX/dcl.dcl/dcl.spec/dcl.type/dcl.spec.auto/p3.cpp | 3 +++ clang/test/SemaCXX/warn-unused-variables.cpp | 5 +++-- 3 files changed, 7 insertions(+), 2 deletions(-) diff --git a/clang/lib/Parse/ParseDecl.cpp b/clang/lib/Parse/ParseDecl.cpp index 52bd416..3ef4f38 100644 --- a/clang/lib/Parse/ParseDecl.cpp +++ b/clang/lib/Parse/ParseDecl.cpp @@ -1680,6 +1680,7 @@ Decl *Parser::ParseDeclarationAfterDeclaratorAndAttributes(Declarator &D, } if (ParseExpressionList(Exprs, CommaLocs)) { + Actions.ActOnInitializerError(ThisDecl); SkipUntil(tok::r_paren); if (getLangOpts().CPlusPlus && D.getCXXScopeSpec().isSet()) { diff --git a/clang/test/CXX/dcl.dcl/dcl.spec/dcl.type/dcl.spec.auto/p3.cpp b/clang/test/CXX/dcl.dcl/dcl.spec/dcl.type/dcl.spec.auto/p3.cpp index f732255..e91cacf 100644 --- a/clang/test/CXX/dcl.dcl/dcl.spec/dcl.type/dcl.spec.auto/p3.cpp +++ b/clang/test/CXX/dcl.dcl/dcl.spec/dcl.type/dcl.spec.auto/p3.cpp @@ -86,3 +86,6 @@ namespace PR13293 { template void h(); } #endif + +auto fail((unknown)); // expected-error{{use of undeclared identifier 'unknown'}} +int& crash = fail; diff --git a/clang/test/SemaCXX/warn-unused-variables.cpp b/clang/test/SemaCXX/warn-unused-variables.cpp index 5827019..8bf2560 100644 --- a/clang/test/SemaCXX/warn-unused-variables.cpp +++ b/clang/test/SemaCXX/warn-unused-variables.cpp @@ -42,10 +42,11 @@ void test_dependent_init(T *p) { } namespace PR6948 { - template class X; + template class X; // expected-note{{template is declared here}} void f() { - X str (read_from_file()); // expected-error{{use of undeclared identifier 'read_from_file'}} + X str (read_from_file()); // expected-error{{use of undeclared identifier 'read_from_file'}} \ + expected-error{{implicit instantiation of undefined template 'PR6948::X'}} } } -- 2.7.4