This is an archive of the discontinued LLVM Phabricator instance.

Fix PR8170: Clang does not check constructor declaration that uses a template-id
ClosedPublic

Authored by faisalv on Nov 25 2015, 7:54 PM.

Details

Summary

Clang currently does no real checking of the template argument list when a template-id is used to declare a constructor:

template<class T> struct X {

X<T*, T>(); // Clang erroneously accepts this.

};

Both gcc and edg emit an error on the above code (though one could claim the spec temp.local p1 is perhaps not as explicit as it could be in this regard)

See: https://llvm.org/bugs/show_bug.cgi?id=8170

Diff Detail

Repository
rL LLVM

Event Timeline

faisalv updated this revision to Diff 41206.Nov 25 2015, 7:54 PM
faisalv retitled this revision from to Fix PR8170: Clang does not check constructor declaration that uses a template-id.
faisalv updated this object.
faisalv added a reviewer: rsmith.
faisalv added a subscriber: cfe-commits.

*ping*
My main question is, does it make sense to suppress diagnostics when checking the template-id, and then rewording it as I do. If it does make sense to suppress and then report a new diagnostic - is my method of suppression a reasonable one (as opposed to SFINAETrap or passing a flag around that's checked prior to emitting a diagnostic)
Thanks!

majnemer added inline comments.
lib/Sema/SemaTemplate.cpp
528 ↗(On Diff #41206)

You could use StringifiedTemplateArgs.empty() instead.

529 ↗(On Diff #41206)

You could hoist this bit out of the std::for_each

faisalv added inline comments.Dec 7 2015, 2:58 PM
lib/Sema/SemaTemplate.cpp
528 ↗(On Diff #41206)

Aah yes - Will do - Thanks!

529 ↗(On Diff #41206)

Well - I would still need some way to know that this is not the first iteration. I was trying to avoid declaring another variable or checking that the string was equal to another string (I thought the empty check would be reasonable) -do you feel strongly about the hoist?

This revision was automatically updated to reflect the committed changes.

In case anyone comes here looking for rL300555 that should be D15006 no D15005.

Thanks

It won't let me revert the automatically updated diff to the previous one because I am not the author.
@faisalv are you able todo this and Sorry for the confusion.