From 485b31292752252328de0a3db1d1cd39c87026c0 Mon Sep 17 00:00:00 2001 From: Richard Smith Date: Tue, 29 Jan 2013 02:49:47 +0000 Subject: [PATCH] PR15100: look through type sugar when determining whether we have one of the forms of 'main' which we accept as an extension. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@173758 91177308-0d34-0410-b5e6-96231b3b80d8 --- lib/Sema/SemaDecl.cpp | 3 ++- .../basic/basic.start/basic.start.main/p2.cpp | 23 +++++++++++++++++++ 2 files changed, 25 insertions(+), 1 deletion(-) diff --git a/lib/Sema/SemaDecl.cpp b/lib/Sema/SemaDecl.cpp index e8d14e6bef..9c3666413b 100644 --- a/lib/Sema/SemaDecl.cpp +++ b/lib/Sema/SemaDecl.cpp @@ -6647,7 +6647,8 @@ void Sema::CheckMain(FunctionDecl* FD, const DeclSpec& DS) { const PointerType* PT; if ((PT = qs.strip(AT)->getAs()) && (PT = qs.strip(PT->getPointeeType())->getAs()) && - (QualType(qs.strip(PT->getPointeeType()), 0) == Context.CharTy)) { + Context.hasSameType(QualType(qs.strip(PT->getPointeeType()), 0), + Context.CharTy)) { qs.removeConst(); mismatch = !qs.empty(); } diff --git a/test/CXX/basic/basic.start/basic.start.main/p2.cpp b/test/CXX/basic/basic.start/basic.start.main/p2.cpp index 38536e646f..a5386f1b92 100644 --- a/test/CXX/basic/basic.start/basic.start.main/p2.cpp +++ b/test/CXX/basic/basic.start/basic.start.main/p2.cpp @@ -12,6 +12,10 @@ // RUN: not %clang_cc1 -x c++ %t -std=c++11 -fixit -DTEST9 // RUN: %clang_cc1 -x c++ %t -std=c++11 -fsyntax-only -DTEST9 +// RUN: %clang_cc1 -fsyntax-only -verify %s -DTEST10 +// RUN: %clang_cc1 -fsyntax-only -verify %s -DTEST11 +// RUN: %clang_cc1 -fsyntax-only -verify %s -DTEST12 + #if TEST1 // expected-no-diagnostics @@ -71,6 +75,25 @@ int main() { } // expected-error{{'main' cannot be a template}} constexpr int main() { } // expected-error{{'main' is not allowed to be declared constexpr}} +#elif TEST10 + +// PR15100 +// expected-no-diagnostics +typedef char charT; +int main(int, const charT**) {} + +#elif TEST11 + +// expected-no-diagnostics +typedef char charT; +int main(int, charT* const *) {} + +#elif TEST12 + +// expected-no-diagnostics +typedef char charT; +int main(int, const charT* const *) {} + #else #error Unknown test mode -- 2.40.0