Assertion Failure (!isIncompleteType() && "This doesn't make sense for incomplete types"); for int [] type

Hi All,

I am trying to fix the above mentioned assertion for a failing gcc testcase.
g++.dg/c++0x/variadic103.cpp testcase ( attached )

Patch added is as follows in TemplateDeclInstantiator::VisitVarDecl function of SemaTemplateInstantiateDecl.cpp

For the above testcases an error should be thrown for incomplete types having an initializer with zero elements.

if (!DI)
return 0;

  • Expr* Arg= D->getInit();

  • InitListExpr *ILE = dyn_cast(Arg);

  • if(!ILE || (ILE && ILE->getNumInits() == 0 )) {

  • if (DI->getType()->isIncompleteType() || DI->getType()->isIncompleteOrObjectType() ) {

  • if (SemaRef.RequireCompleteType(D->getLocation(), DI->getType(),

  • diag::err_typecheck_incomplete_array_needs_initializer)) {

  • D->setInvalidDecl();

  • return 0;

  • }

  • }

  • }

With above code, there is a diagnostic thrown for g++.dg/c++0x/variadic103.cpp testcase as expected and the "Assertion Failure (!isIncompleteType() && “This doesn’t make sense for incomplete types”); for int type " is resolved, however some other assertion in isa_impl_cl occurs while running clang regression on c++ googletests file ( gtest-all.cc )

Appreciate any inputs on this for me to proceed further.

Thanks.

  • Jyoti

bugreport.zip (693 KB)

I would like to add that, the assertion mentioned in the subject line (isIncompleteTypes()… related ) could be reporduced with a debug build of clang with following cmd line options
clang++ -std=c++0x variadic103.cpp

The second assertion related with isa_impl_cl occurs when clang is built with the patch added as shown above in SemaTemplateInstantiateDecl.cpp.
The bugreport attached contains preprocessed source and script used to run gtest-all.cc

Appreciate any inputs on this to proceed further.

Thanks !

  • Jyoti