From: David Blaikie Date: Wed, 10 Oct 2012 23:15:05 +0000 (+0000) Subject: Fix a crash-on-invalid when parsing a reference to an invalid auto declaration X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=3ea19c8307932655092235b57f04a5e6658bbc46;p=clang 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. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@165675 91177308-0d34-0410-b5e6-96231b3b80d8 --- diff --git a/lib/Parse/ParseDecl.cpp b/lib/Parse/ParseDecl.cpp index 52bd4166bb..3ef4f38ad0 100644 --- a/lib/Parse/ParseDecl.cpp +++ b/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/test/CXX/dcl.dcl/dcl.spec/dcl.type/dcl.spec.auto/p3.cpp b/test/CXX/dcl.dcl/dcl.spec/dcl.type/dcl.spec.auto/p3.cpp index f732255a8a..e91cacf104 100644 --- a/test/CXX/dcl.dcl/dcl.spec/dcl.type/dcl.spec.auto/p3.cpp +++ b/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/test/SemaCXX/warn-unused-variables.cpp b/test/SemaCXX/warn-unused-variables.cpp index 582701957e..8bf2560417 100644 --- a/test/SemaCXX/warn-unused-variables.cpp +++ b/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'}} } }